The latest technology and digital news on the web

To use this API, you’ll want to:

, I’ll acclaim entire outfits.

To use this API, you’ll want to:

  1. Uploading your closet photos to Cloud Storage
  2. Create a new Artefact Set using the Artefact Search API
  3. Create a new artefact for each item in your closet
  4. Upload (multiple) pictures of those products

At first I attempted this using the official Google Python client library, but it was a bit clunky, so I ended up autograph my own Python Artefact Search adhesive library, which you can find here (on PyPi). Here’s what it looks like in code:

Note this adhesive library handles uploading photos to a Cloud Storage bucket automatically, so you can upload a new accouterment item to your artefact set from a local image file:

If you, dear reader, want to make your own artefact set from your own closet pics, I wrote a Python script to help you make a artefact set from a folder on your desktop. Just:

  1. Download the code from GitHub and cross to the instafashion/scripts folder:

  1. Create a new folder on your computer to store all your accouterment items (mine’s called my_closet):

  1. Create a new folder for each accouterment item and put all of your pictures of that item in the folder:

So in the gif above, all my black bomber pics are in a folder named black_bomber_jacket.

To use my script, you’ll have to name your artefact folders using the afterward convention: name_of_your_item_shoe where shoe can be any of [skirt, dress, jacket, top, shoe, shorts, scarf, pants].

  1. After creating your agenda of artefact photos, you’ll need to set up some config by alteration the `.env_template` file:

(Oh, by the way: you need to have a Google Cloud annual to use this API! Once you do, you can create a new activity and download a accreditation file.)

  1. Then install the accordant Python libraries and run the script product_set_from_dir.py:

Phew, that was more steps than I thought!

When you run that Python script, product_set_from_dir.py, your accouterment photos get uploaded to the cloud and then candy or “indexed” by the Artefact Search API. The indexing action can take up to 30 minutes, so go fly a kite or something.

Searching for agnate items

Once your artefact set is done indexing, you can start using it to search for agnate items. Woohoo! ????

In code, just run:

The acknowledgment contains lots of data, including which items were accustomed in a the source photo (i.e. “skirt”, “top”) and what items in your activity set akin with them. The API also allotment a “score” field for each match which tells you how assured the the API is that an item in your artefact set akin the picture.

From analogous items to boot outfits

The Artefact Search API looks at an afflatus account (in this case, Laura’s appearance pics) and finds agnate items in my wardrobe. But what I really want to do is put calm whole , which abide of a single top, a single pair of pants, a single set of shoes, etc. Sometimes the Artefact Search API doesn’t return a analytic outfit. For example, if Laura is cutting a long shirt that looks like it could  be a dress, the API might return both a agnate shirt and dress in my wardrobe. To get around that, I had to write my own outfit logic algorithm to build an outfit from the Search API results:

Scoring outfits

Naturally, I couldn’t charm every one of Laura’s apparel using only items in my bound wardrobe. So I absitively my access would be to look at the apparel I could most accurately charm (using the aplomb scores alternate by the Artefact Search API) and create a “score” to sort the recommended outfits.

Figuring out how to “score” an outfit is a artistic botheration that has no single answer! Here are a couple of score functions I wrote. They give apparel absolute items that have high aplomb matches more gravitas, and give a bonus to apparel that akin more items in my closet:

If you want to see all this code calm alive in action, check out this Jupyter notebook.

Putting it all together

Once I had accounting all the logic for making apparel in a Python script, I ran the script and wrote all the after-effects to Firestore. Firestore is a serverless database that’s advised to be used easily in apps, so once I had all my outfit matches accounting there, it was easy to write a frontend around it that made aggregate look pretty. I absitively to build a React web app, but you could just easily affectation this data in a Flutter or iOS or Android app!

And that’s pretty much it! Take that, big-ticket stylist.


This commodity was accounting by Dale Markowitz, an Applied AI Engineer at Google based in Austin, Texas, where she works on applying apparatus acquirements to new fields and industries. She also likes analytic her own life problems with AI, and talks about it on YouTube.

Published November 7, 2020 — 14:00 UTC

Hottest related news