מערכת Vision API Google Product Search יכולה לזהות ולמצוא מוצרים תואמים למוצר יחיד בתמונה לחיפוש, או לזהות ולרשום מוצרים תואמים לכמה מוצרים אם הם מופיעים בתמונה.
תמונות של מוצר בודד ותגובה
תמונת החיפוש הזו מכילה מוצר אחד.
gs://cloud-ai-vision-data/product-search-tutorial/images/468f782e70ba11e8941fd20059124800.jpgחיפוש מוצרים דומים באמצעות Vision API Google Product Search מחזיר תגובה שמציינת שתי תיבות תוחמות (bounding box) בתמונה: תיבה אחת סביב המוצר ותיבה נוספת סביב התמונה כולה.
כדי לראות את התשובה המלאה, מרחיבים את הקטע שבהמשך.
תשובה מלאה
{ "responses": [ { "productSearchResults": { "indexTime": "2018-12-04T22:33:53.673600055Z", "results": [ { "product": { "name": "projects/project-id/locations/location-id/products/product_id16", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "dress" } ] }, "score": 1, "image": "projects/project-id/locations/location-id/products/product_id16/referenceImages/image16" }, { "product": { "name": "projects/project-id/locations/location-id/products/product_id29", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "dress" } ] }, "score": 0.34263745, "image": "projects/project-id/locations/location-id/products/product_id29/referenceImages/image29" }, ... { "product": { "name": "projects/project-id/locations/location-id/products/product_id89", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "dress" } ] }, "score": 0.20485385, "image": "projects/project-id/locations/location-id/products/product_id89/referenceImages/image89" } ], "productGroupedResults": [ { "boundingPoly": { "normalizedVertices": [ { "x": 0.25610325, "y": 0.1357359 }, { "x": 0.77213204, "y": 0.1357359 }, { "x": 0.77213204, "y": 0.9287346 }, { "x": 0.25610325, "y": 0.9287346 } ] }, "results": [ { "product": { "name": "projects/project-id/locations/location-id/products/product_id16", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "dress" } ] }, "score": 1, "image": "projects/project-id/locations/location-id/products/product_id16/referenceImages/image16" }, { "product": { "name": "projects/project-id/locations/location-id/products/product_id29", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "dress" } ] }, "score": 0.3345438, "image": "projects/project-id/locations/location-id/products/product_id29/referenceImages/image29" }, ... { "product": { "name": "projects/project-id/locations/location-id/products/product_id76", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "shoe" } ] }, "score": 0.20218614, "image": "projects/project-id/locations/location-id/products/product_id76/referenceImages/image76" } ] }, { "boundingPoly": { "normalizedVertices": [ {}, { "x": 1 }, { "x": 1, "y": 1 }, { "y": 1 } ] }, "results": [ { "product": { "name": "projects/project-id/locations/location-id/products/product_id16", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "dress" } ] }, "score": 1, "image": "projects/project-id/locations/location-id/products/product_id16/referenceImages/image16" }, { "product": { "name": "projects/project-id/locations/location-id/products/product_id29", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "dress" } ] }, "score": 0.3507311, "image": "projects/project-id/locations/location-id/products/product_id29/referenceImages/image29" }, { "product": { "name": "projects/project-id/locations/location-id/products/product_id8", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "dress" } ] }, "score": 0.26709077, "image": "projects/project-id/locations/location-id/products/product_id8/referenceImages/image8" }, ... { "product": { "name": "projects/project-id/locations/location-id/products/product_id51", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "dress" } ] }, "score": 0.21597815, "image": "projects/project-id/locations/location-id/products/product_id51/referenceImages/image51" } ] } ] } } ] }
תיבות תוחמות ומוצרים תואמים
שני המוצרים הבאים (תיבות תוחמות) בתמונה מצוינים על ידי שני מערכי הקודקודים שמוחזרים מהבקשה.
מוצרים תואמים מופיעים בכל תיבה שמזוהה על ידי Google Product Search.
gs://cloud-samples-data/product_search/multiple_dresses.jpgבתיבות התוחמות של תגובת ה-API, התוצאות של המוצרים התואמים מפורטות בשדה productGroupedResults. הם מקובצים לפי מוצרים
שזוהו בתמונה. כל רשומה של boundingPoly מפרטת את האזור שצוין עם קודקודים מנורמלים (בסולם של 0 עד 1, שלא תואם לערכי הפיקסלים בפועל של התמונה). אחרי כן מוצגים המוצרים התואמים לאזור הספציפי הזה.
הקטע הבא מהתשובה מתאים לתיבת התוחמת סביב השמלה.
קטע התגובה של תיבת מוצר יחיד
.... "productGroupedResults": [ { "boundingPoly": { "normalizedVertices": [ { "x": 0.25610325, "y": 0.1357359 }, { "x": 0.77213204, "y": 0.1357359 }, { "x": 0.77213204, "y": 0.9287346 }, { "x": 0.25610325, "y": 0.9287346 } ] }, "results": [ { "product": { "name": "projects/project-id/locations/location-id/products/product_id16", "displayName": " ", "productCategory": "apparel", "productLabels":... "score": 1, ...
המוצרים התואמים מופיעים אחרי השדה results, והם מדורגים לפי ציון ההתאמה בסדר יורד. הציונים נעים בין 0 (ללא מהימנות) ל-1 (מהימנות מלאה).
Several matching products for the dressהמסגרת השנייה boundingPoly שמופיעה בתשובה מקיפה את כל התמונה.
הקודקודים המנורמלים שלו מפורטים כך:
[{},{"x": 1},{"x": 1,"y": 1},{"y": 1}]
אם ערכי הקואורדינטות הם 0, הם מושמטים. לכן, הפוליגון התוחם שצוין למעלה מתאים ל:
[{"x": 0,"y": 0},{"x": 1, "y": 0},{"x": 1,"y": 1},{"y": 1}]
לאחר מכן, מוצגת רשימה דומה של מוצרים תואמים לתיבת התוחמת הזו (התמונה כולה).
תמונות של כמה מוצרים (זיהוי מרובה) ותגובה
תמונת החיפוש הבאה מכילה כמה מוצרים.
gs://cloud-samples-data/product_search/multiple_dresses.jpgשימוש ב-Vision API Google Product Search כדי לחפש מוצרים דומים מחזיר תגובה שמזהה כמה תיבות תוחמות (bounding box) בתמונה, אחת לכל התמונה ועוד שלוש תיבות לכל אחת משלוש השמלות.
כדי לראות את התשובה המלאה, מרחיבים את הקטע שבהמשך.
תשובה מלאה
{ "responses": [ { "productSearchResults": { "indexTime": "2018-12-05T18:34:22.231193168Z", "results": [ { "product": { "name": "projects/project-id/locations/location-id/products/product_id89", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "dress" } ] }, "score": 0.40636745, "image": "projects/project-id/locations/location-id/products/product_id89/referenceImages/image89" }, { "product": { "name": "projects/project-id/locations/location-id/products/product_id56", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "dress" } ] }, "score": 0.35433072, "image": "projects/project-id/locations/location-id/products/product_id56/referenceImages/image56" }, ... { "product": { "name": "projects/project-id/locations/location-id/products/product_id92", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "dress" } ] }, "score": 0.30736163, "image": "projects/project-id/locations/location-id/products/product_id92/referenceImages/image92" } ], "productGroupedResults": [ { "boundingPoly": { "normalizedVertices": [ { "x": 0.38727918, "y": 0.10391616 }, { "x": 0.57177967, "y": 0.10391616 }, { "x": 0.57177967, "y": 0.94973093 }, { "x": 0.38727918, "y": 0.94973093 } ] }, "results": [ { "product": { "name": "projects/project-id/locations/location-id/products/product_id39", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "dress" } ] }, "score": 0.36689043, "image": "projects/project-id/locations/location-id/products/product_id39/referenceImages/image39" }, { "boundingPoly": { "normalizedVertices": [ { "x": 0.63010275, "y": 0.08650439 }, { "x": 0.88989735, "y": 0.08650439 }, { "x": 0.88989735, "y": 0.9285545 }, { "x": 0.63010275, "y": 0.9285545 } ] }, "results": [ { "product": { "name": "projects/project-id/locations/location-id/products/product_id89", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "dress" } ] }, "score": 0.4007347, "image": "projects/project-id/locations/location-id/products/product_id89/referenceImages/image89" }, ... { "product": { "name": "projects/project-id/locations/location-id/products/product_id30", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "dress" } ] }, "score": 0.27045864, "image": "projects/project-id/locations/location-id/products/product_id30/referenceImages/image30" }, ... { "product": { "name": "projects/project-id/locations/location-id/products/product_id63", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "dress" } ] }, "score": 0.23139484, "image": "projects/project-id/locations/location-id/products/product_id63/referenceImages/image63" } ] }, ... { "boundingPoly": { "normalizedVertices": [ {}, { "x": 1 }, { "x": 1, "y": 1 }, { "y": 1 } ] }, "results": [ { "product": { "name": "projects/project-id/locations/location-id/products/product_id30", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "dress" } ] }, "score": 0.39522344, "image": "projects/project-id/locations/location-id/products/product_id30/referenceImages/image30" }, ... { "product": { "name": "projects/project-id/locations/location-id/products/product_id4", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "dress" } ] }, "score": 0.34226564, "image": "projects/project-id/locations/location-id/products/product_id4/referenceImages/image4" } ] }, { "boundingPoly": { "normalizedVertices": [ { "x": 0.030102689, "y": 0.067680866 }, { "x": 0.28942674, "y": 0.067680866 }, { "x": 0.28942674, "y": 0.94973093 }, { "x": 0.030102689, "y": 0.94973093 } ] }, "results": [ { "product": { "name": "projects/project-id/locations/location-id/products/product_id89", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "dress" } ] }, "score": 0.42439392, "image": "projects/project-id/locations/location-id/products/product_id89/referenceImages/image89" }, ... { "product": { "name": "projects/project-id/locations/location-id/products/product_id51", "displayName": " ", "productCategory": "apparel", "productLabels": [ { "key": "style", "value": "women" }, { "key": "category", "value": "dress" } ] }, "score": 0.26797917, "image": "projects/project-id/locations/location-id/products/product_id51/referenceImages/image51" } ] } ] } } ] }
תיבות תוחמות ומוצרים תואמים
בתמונה הבאה מוצגות כל תיבות התוחמות שזוהו על ידי Google Product Search ב-Vision API בתמונה הזו עם כמה מוצרים.
gs://cloud-samples-data/product_search/multiple_dresses.jpgבדומה לתמונה של מוצר בודד, בתגובה של תמונה עם כמה מוצרים מופיעים תיבות תוחמות ותוצאות של מוצרים תואמים בשדה productGroupedResults. כל מוצר מזוהה על ידי פוליגון תחום, וההתאמות מקובצות לפי כל מוצר שזוהה.
הקטע הבא מהתשובה מתאים לתיבת התוחמת סביב השמלה האמצעית.
קטע התגובה של תיבת המוצר (השמלה האמצעית)
"productGroupedResults": [ { "boundingPoly": { "normalizedVertices": [ { "x": 0.38727918, "y": 0.10391616 }, { "x": 0.57177967, "y": 0.10391616 }, { "x": 0.57177967, "y": 0.94973093 }, { "x": 0.38727918, "y": 0.94973093 } ] }, "results": [ { "product": { "name":... "score": 0.36689043, ...
בתמונה הבאה אפשר לראות חלק מההתאמות לשמלה האמצעית שהוחזרו על ידי Vision API Google Product Search.
Several matching products for the middle dressהתמונות הבאות מכילות תיבות תוחמות אחרות, שלכל אחת מהן יש רשימה משלה של מוצרים תואמים (לא כלולה כאן):
- שמלה שמאלית:
{"x":0.03, "y":0.07},{"x":0.29, "y":0.07},{"x":0.29, "y":0.95},{"x":0.03, "y":0.95} - right dress:
{"x":0.63, "y":0.09},{"x":0.89, "y":0.09},{"x":0.89, "y":0.93},{"x":0.63, "y":0.93} - כל התמונה:
-
{},{"x": 1},{"x": 1,"y": 1},{"y": 1}, אפשר גם לכתוב: {"x": 0, "y": 0},{"x": 1,"y:0"},{"x": 1,"y": 1},{"x": 0,"y": 1}
-