{ "cells": [ { "cell_type": "code", "execution_count": 28, "metadata": { "tags": [] }, "outputs": [ { "ename": "ImportError", "evalue": "cannot import name 'data_path' from 'utils' (/Users/yonglinwu/dev/image-search-playground/utils.py)", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mImportError\u001b[0m Traceback (most recent call last)", "Cell \u001b[0;32mIn[28], line 9\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39mtorch\u001b[39;00m\n\u001b[1;32m 7\u001b[0m torch\u001b[39m.\u001b[39mset_printoptions(precision\u001b[39m=\u001b[39m\u001b[39m10\u001b[39m)\n\u001b[0;32m----> 9\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mutils\u001b[39;00m \u001b[39mimport\u001b[39;00m get_image_embeddings, model_name_to_ids, load_models, model_dict, data_path\n\u001b[1;32m 11\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39mwarnings\u001b[39;00m\n\u001b[1;32m 12\u001b[0m warnings\u001b[39m.\u001b[39msimplefilter(action\u001b[39m=\u001b[39m\u001b[39m'\u001b[39m\u001b[39mignore\u001b[39m\u001b[39m'\u001b[39m, category\u001b[39m=\u001b[39m\u001b[39mFutureWarning\u001b[39;00m)\n", "\u001b[0;31mImportError\u001b[0m: cannot import name 'data_path' from 'utils' (/Users/yonglinwu/dev/image-search-playground/utils.py)" ] } ], "source": [ "from sentence_transformers import SentenceTransformer, util\n", "from PIL import Image\n", "import pandas as pd\n", "import os\n", "import numpy as np\n", "import torch\n", "torch.set_printoptions(precision=10)\n", "\n", "from utils import get_image_embeddings, model_name_to_ids, load_models, model_dict, data_path\n", "\n", "import warnings\n", "warnings.simplefilter(action='ignore', category=FutureWarning)\n", "\n", "%load_ext autoreload\n", "%autoreload 2\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 3, "metadata": { "tags": [] }, "outputs": [], "source": [ "patagonia_df = pd.read_csv(data_path + 'metadata/patagonia_losGatos.tsv', sep='\\t')" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "tags": [] }, "outputs": [ { "data": { "text/html": [ "
\n", " | brand | \n", "title | \n", "product_url | \n", "price | \n", "description | \n", "size | \n", "category | \n", "colors | \n", "Poshmark | \n", "Unnamed: 9 | \n", "... | \n", "Unnamed: 38 | \n", "Unnamed: 39 | \n", "Unnamed: 40 | \n", "Unnamed: 41 | \n", "Unnamed: 42 | \n", "Unnamed: 43 | \n", "Unnamed: 44 | \n", "Unnamed: 45 | \n", "Unnamed: 46 | \n", "Unnamed: 47 | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "Patagonia | \n", "Patagonia Women's Los Gatos Fleece 1/4-Zip Smo... | \n", "https://poshmark.com/listing/63d4821f2fbf1afe8... | \n", "$36.00 | \n", "A soft, warm and versatile quarter-zip pullove... | \n", "M | \n", "Tops | \n", "[{'name': 'Gray', 'rgb': '#929292', 'message_i... | \n", "Poshmark | \n", "False | \n", "... | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "
1 | \n", "Patagonia | \n", "Patagonia Los Gatos 1/4 Zip Pullover M Beech B... | \n", "https://poshmark.com/listing/63fcd7709f212bd48... | \n", "$59.00 | \n", "High pile, quarter zip pulllover\\nMeasurements... | \n", "M | \n", "Tops | \n", "[{'name': 'Brown', 'rgb': '#663509', 'message_... | \n", "Poshmark | \n", "False | \n", "... | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "
2 | \n", "Patagonia | \n", "PATAGONIA Women's Los Gatos Fleece 1/4-Zip Pul... | \n", "https://poshmark.com/listing/642b9bbcfed51f812... | \n", "$59.00 | \n", "PATAGONIA Women's Los Gatos Fleece 1/4-Zip Pul... | \n", "S | \n", "Tops | \n", "[{'name': 'White', 'rgb': '#FFFFFF', 'message_... | \n", "Poshmark | \n", "False | \n", "... | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "
3 | \n", "Patagonia | \n", "Girl’s Patagonia Los Gatos Fleece 1/4 Zip XS | \n", "https://poshmark.com/listing/63f4f459c5df6c7f8... | \n", "$30.00 | \n", "Girl’s Patagonia Los Gatos 1/4 Zip Fleece\\n\\n-... | \n", "XSG | \n", "Other | \n", "[{'name': 'Tan', 'rgb': '#d1b48e', 'message_id... | \n", "Poshmark | \n", "False | \n", "... | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "
4 | \n", "Patagonia | \n", "Patagonia Los Gatos Quarter Zip Grey | \n", "https://poshmark.com/listing/622cc43d3a0db900b... | \n", "$59.00 | \n", "Patagonia Los Gatos Quarter Zip Grey \\nWomen’s... | \n", "M | \n", "Tops | \n", "[{'name': 'Gray', 'rgb': '#929292', 'message_i... | \n", "Poshmark | \n", "False | \n", "... | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "
5 rows × 48 columns
\n", "\n", " | name | \n", "sentence-transformer-clip-ViT-L-14-embedding | \n", "fashion-embedding | \n", "openai-clip-embedding | \n", "
---|---|---|---|---|
0 | \n", "Women's Under Armour Hustle Fleece Hoodie pull... | \n", "[1.0734258, 0.99022365, 0.32032806, 0.2895219,... | \n", "[0.23177437, -1.9268938, 0.273342, -0.02474568... | \n", "[-0.32902592, -0.09434131, 0.3055967, 0.229937... | \n", "
1 | \n", "Patagonia Los Gatos Fleece Grey Pullover.jpg | \n", "[0.6227796, 0.026531212, 0.45240527, -0.488214... | \n", "[0.38133767, -1.3040155, 1.1697398, -0.3085520... | \n", "[-0.1695469, 0.5067289, 0.31120676, -0.0083701... | \n", "
2 | \n", "REI Women's Down With It Quilted Hooded Parka ... | \n", "[0.8497103, 1.2925782, -0.21685322, 0.24116844... | \n", "[-0.30043703, -1.3144073, -0.33848628, 0.24008... | \n", "[-0.24841668, 0.4876942, 0.39810008, -0.141552... | \n", "
3 | \n", "Chanel Haute Couture Navy Blue Dress Semi Shee... | \n", "[0.536018, 0.60787296, -0.2751825, 1.0325747, ... | \n", "[-0.101031125, 0.033914, -0.44531134, -0.64656... | \n", "[-0.08328074, 0.19443086, 0.14361368, 0.259305... | \n", "
4 | \n", "Patagonia Women’s S Los Gatos Quarter-Zip Flee... | \n", "[0.79398394, 1.3899276, -0.21383175, 0.0109823... | \n", "[0.60070944, -1.1051046, 1.0572466, 0.47092092... | \n", "[-0.27894062, -0.09589732, 0.5556799, -0.13458... | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
326 | \n", "Women's REI Elements Jacket Size M.jpg | \n", "[0.6310029, 0.9942212, 0.009293936, 0.7862729,... | \n", "[0.19858713, -1.8665266, -0.3323754, 0.0465058... | \n", "[-0.0952643, 0.8016211, 0.08129032, 0.15187423... | \n", "
327 | \n", "CHANEL Black cotton bodycon tank dress with zi... | \n", "[1.0761135, 0.18927886, -0.007131472, 0.625682... | \n", "[0.07516122, -0.1886161, 0.1334078, -0.2829321... | \n", "[-0.12297699, 0.026368856, 0.04415588, 0.26031... | \n", "
328 | \n", "Reformation X Veda Women's Bad Leather Jacket ... | \n", "[0.79690784, 1.2895226, 0.22802149, -0.2736021... | \n", "[-0.12224964, -0.38734418, 0.35824925, 0.95855... | \n", "[0.6507246, 0.27751687, 0.36114892, -0.0831387... | \n", "
329 | \n", "DISNEY HER UNIVERSE LILO AND STICH Rainbow Qua... | \n", "[1.1617887, 0.19193622, 0.046035454, 0.4334900... | \n", "[-0.20762922, 0.1754938, -0.7334341, -0.106492... | \n", "[-0.31946087, 0.19534132, 0.37351555, -0.09741... | \n", "
330 | \n", "PATAGONIA Nano Puff Jacket Zip Primaloft Insul... | \n", "[0.2912089, 0.72192264, -0.01620815, 0.0022971... | \n", "[0.0026952028, -1.6660439, 0.03839147, -0.2164... | \n", "[0.12799336, 0.75828236, 0.10943861, -0.036647... | \n", "
331 rows × 4 columns
\n", "\n", " | name | \n", "sentence-transformer-clip-ViT-L-14-embedding | \n", "fashion-embedding | \n", "openai-clip-embedding | \n", "
---|---|---|---|---|
0 | \n", "Women's Under Armour Hustle Fleece Hoodie pull... | \n", "[1.0734258, 0.99022365, 0.32032806, 0.2895219,... | \n", "[0.23177437, -1.9268938, 0.273342, -0.02474568... | \n", "[-0.32902592, -0.09434131, 0.3055967, 0.229937... | \n", "
1 | \n", "Patagonia Los Gatos Fleece Grey Pullover.jpg | \n", "[0.6227796, 0.026531212, 0.45240527, -0.488214... | \n", "[0.38133767, -1.3040155, 1.1697398, -0.3085520... | \n", "[-0.1695469, 0.5067289, 0.31120676, -0.0083701... | \n", "
2 | \n", "REI Women's Down With It Quilted Hooded Parka ... | \n", "[0.8497103, 1.2925782, -0.21685322, 0.24116844... | \n", "[-0.30043703, -1.3144073, -0.33848628, 0.24008... | \n", "[-0.24841668, 0.4876942, 0.39810008, -0.141552... | \n", "
3 | \n", "Chanel Haute Couture Navy Blue Dress Semi Shee... | \n", "[0.536018, 0.60787296, -0.2751825, 1.0325747, ... | \n", "[-0.101031125, 0.033914, -0.44531134, -0.64656... | \n", "[-0.08328074, 0.19443086, 0.14361368, 0.259305... | \n", "
4 | \n", "Patagonia Women’s S Los Gatos Quarter-Zip Flee... | \n", "[0.79398394, 1.3899276, -0.21383175, 0.0109823... | \n", "[0.60070944, -1.1051046, 1.0572466, 0.47092092... | \n", "[-0.27894062, -0.09589732, 0.5556799, -0.13458... | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
326 | \n", "Women's REI Elements Jacket Size M.jpg | \n", "[0.6310029, 0.9942212, 0.009293936, 0.7862729,... | \n", "[0.19858713, -1.8665266, -0.3323754, 0.0465058... | \n", "[-0.0952643, 0.8016211, 0.08129032, 0.15187423... | \n", "
327 | \n", "CHANEL Black cotton bodycon tank dress with zi... | \n", "[1.0761135, 0.18927886, -0.007131472, 0.625682... | \n", "[0.07516122, -0.1886161, 0.1334078, -0.2829321... | \n", "[-0.12297699, 0.026368856, 0.04415588, 0.26031... | \n", "
328 | \n", "Reformation X Veda Women's Bad Leather Jacket ... | \n", "[0.79690784, 1.2895226, 0.22802149, -0.2736021... | \n", "[-0.12224964, -0.38734418, 0.35824925, 0.95855... | \n", "[0.6507246, 0.27751687, 0.36114892, -0.0831387... | \n", "
329 | \n", "DISNEY HER UNIVERSE LILO AND STICH Rainbow Qua... | \n", "[1.1617887, 0.19193622, 0.046035454, 0.4334900... | \n", "[-0.20762922, 0.1754938, -0.7334341, -0.106492... | \n", "[-0.31946087, 0.19534132, 0.37351555, -0.09741... | \n", "
330 | \n", "PATAGONIA Nano Puff Jacket Zip Primaloft Insul... | \n", "[0.2912089, 0.72192264, -0.01620815, 0.0022971... | \n", "[0.0026952028, -1.6660439, 0.03839147, -0.2164... | \n", "[0.12799336, 0.75828236, 0.10943861, -0.036647... | \n", "
331 rows × 4 columns
\n", "