{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# <center> Quick Tuto <br>Using 🎨 WikiArt dataset</center> ","metadata":{"papermill":{"duration":0.006631,"end_time":"2021-11-22T14:46:20.420392","exception":false,"start_time":"2021-11-22T14:46:20.413761","status":"completed"},"tags":[]}},{"cell_type":"code","source":"# Libraries\nimport numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport cv2\nimport urllib.request\n\n# DataFrame\nwikiart = pd.read_csv('../input/-wikiart-all-images-120k-link/wikiart_scraped.csv')","metadata":{"papermill":{"duration":0.766786,"end_time":"2021-11-22T14:46:21.194298","exception":false,"start_time":"2021-11-22T14:46:20.427512","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-11-22T14:59:09.308854Z","iopub.execute_input":"2021-11-22T14:59:09.309493Z","iopub.status.idle":"2021-11-22T14:59:09.776916Z","shell.execute_reply.started":"2021-11-22T14:59:09.309437Z","shell.execute_reply":"2021-11-22T14:59:09.775838Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Looking for Mona Lisa ?","metadata":{"execution":{"iopub.execute_input":"2021-11-22T14:31:08.120076Z","iopub.status.busy":"2021-11-22T14:31:08.119208Z","iopub.status.idle":"2021-11-22T14:31:08.125683Z","shell.execute_reply":"2021-11-22T14:31:08.124699Z","shell.execute_reply.started":"2021-11-22T14:31:08.120012Z"},"papermill":{"duration":0.004965,"end_time":"2021-11-22T14:46:21.204808","exception":false,"start_time":"2021-11-22T14:46:21.199843","status":"completed"},"tags":[]}},{"cell_type":"markdown","source":"- Searching for 'mona lisa' in the *Artwork* column in order to find the original one","metadata":{"papermill":{"duration":0.004846,"end_time":"2021-11-22T14:46:21.214594","exception":false,"start_time":"2021-11-22T14:46:21.209748","status":"completed"},"tags":[]}},{"cell_type":"code","source":"df_mona_lisa = wikiart[wikiart['Artwork'].apply(lambda x: 'mona lisa' in x.lower())]\ndf_mona_lisa","metadata":{"papermill":{"duration":0.099468,"end_time":"2021-11-22T14:46:21.318955","exception":false,"start_time":"2021-11-22T14:46:21.219487","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-11-22T14:59:09.819867Z","iopub.execute_input":"2021-11-22T14:59:09.820728Z","iopub.status.idle":"2021-11-22T14:59:09.895191Z","shell.execute_reply.started":"2021-11-22T14:59:09.820676Z","shell.execute_reply":"2021-11-22T14:59:09.894039Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"- We can see the original is the one in the first row, with Leonardo da Vinci as the artist, let's plot it !\n\n- Note: matplotlib requires RGB ordering whereas OpenCV (perversely) uses BGR","metadata":{"papermill":{"duration":0.006202,"end_time":"2021-11-22T14:46:21.332958","exception":false,"start_time":"2021-11-22T14:46:21.326756","status":"completed"},"tags":[]}},{"cell_type":"code","source":"url_response = urllib.request.urlopen(df_mona_lisa.iloc[0]['Link'])\nimg = cv2.imdecode(np.array(bytearray(url_response.read()), dtype=np.uint8), -1)\nimageRGB = cv2.cvtColor(img , cv2.COLOR_BGR2RGB)\nplt.imshow(imageRGB);","metadata":{"papermill":{"duration":1.488627,"end_time":"2021-11-22T14:46:22.827764","exception":false,"start_time":"2021-11-22T14:46:21.339137","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2021-11-22T14:59:10.720234Z","iopub.execute_input":"2021-11-22T14:59:10.720564Z","iopub.status.idle":"2021-11-22T14:59:12.086256Z","shell.execute_reply.started":"2021-11-22T14:59:10.720524Z","shell.execute_reply":"2021-11-22T14:59:12.085136Z"},"trusted":true},"execution_count":null,"outputs":[]}]}