/FashionClass

Classifying fashion images

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

FashionCLIP Image Classifier

This Demo provides a tool to classify images using the FashionCLIP model. It processes an image and classifies it based on predefined vocabulary sets. The results are the top classes (categories) that the image likely belongs to, based on the similarity scores computed by the CLIP model.

Model and Vocabulary:

  • Utilizes the pretrained CLIP model from patrickjohncyh/fashion-clip.
  • Supports custom vocabulary sets for classification. We provide vocabulary for Parts/Types, Colours/Patterns, Brands and Fabrics.
  • Allows users to specify the maximum number of words per category, the path to the vocabulary directory, and the number of top classes to be printed per category.

Usage:

python clip_image_classifier.py -f <path_to_image> [-v <max_vocab>] [-d <vocab_directory>] [-n <number_of_top_classes>]

Arguments:

  • -f, --file IMG: Specify the path to the image file. (Required)
  • -v, --maxvocab: Maximum number of words per category. Default is 600.
  • -d, --dir DIR: Path to the vocabulary directory. Default is vocab/.
  • -n, --number: Number of top classes to be printed per category. Default is 5.

Sample Results:

Image Types / Parts Colour / Patterns Brands Fabric
0.305, Bouffant gown
0.252, Fur clothing
0.077, Mantle (royal garment)
0.058, Reconstructed clothing
0.039, Haute couture
0.559, Blue-violet
0.111, Blue
0.071, Electric blue
0.062, Cobalt blue
0.055, Indigo
0.371, Zara
0.222, Elie Saab
0.100, Net-a-Porter
0.042, ASOS
0.036, Furla
0.687, Fur clothing
0.269, chiffon
0.022, velvet
0.011, Rayon
0.004, Silk
0.917, Polo shirt
0.024, Shirt
0.010, Henley shirt
0.008, Hem
0.006, Collar
0.472, Stripes
0.122, Retro
0.084, Tan
0.078, Designer
0.034, Lemon
0.750, Lacoste
0.050, ASOS
0.028, Nike
0.028, Tommy Hilfiger
0.024, Patagonia
0.760, Silk
0.073, velvet
0.060, Cotton
0.021, Linen
0.021, chiffon

Image sources for the examples:

Ricardo Acevedo: https://www.pexels.com/de-de/foto/frau-die-blauen-pelzmantel-und-kleid-tragt-1375736/

Wikimedia: https://commons.wikimedia.org/wiki/File:Tennis-shirt-lacoste.jpg

Dependencies:

  • PIL for image processing.
  • transformers for utilizing the FashionCLIP model and processor.

License

Copyright (C) 2023 by Jules Kreuer - @not_a_feature
This piece of software is published unter the GNU General Public License v3.0
TLDR:

| Permissions      | Conditions                   | Limitations |
| ---------------- | ---------------------------- | ----------- |
| ✓ Commercial use | Disclose source              | ✕ Liability |
| ✓ Distribution   | License and copyright notice | ✕ Warranty  |
| ✓ Modification   | Same license                 |             |
| ✓ Patent use     | State changes                |             |
| ✓ Private use    |                              |             |

Go to LICENSE.md to see the full version.