Skip to content

This is an updated implementation of Simple image retrieval algorithm on deep-fashion dataset with pytorch

License

Notifications You must be signed in to change notification settings

sunn-e/DeepFashion-retrieval-2019

Repository files navigation

DeepFashion Retrieval 2020

This is an updated implementation of Simple image retrieval algorithm on deep-fashion dataset with pytorch

Dependencies

  • Python (Compatible with 2 and 3) (I prefer 2.7 for compatibility reasons though 3 will work just fine)
  • Pytorch
  • Torchvision (installed with pytorch, so don't worry)
  • PIL
  • cv2(only for visualizing)

Anaconda is recommended.

Get started now with preefined weights

Generating feature databases

  • Feature extraction

    • Set DUMPED_MODEL in config.py as trained model
    • Run feature_extractor.py

    The feature will be saved to DATASET_BASE/all_feat.npy, DATASET_BASE/all_color_feat.npy and DATASET_BASE/all_feat.list.

  • Accelerating querying by clustering

    • Run kmeans.py to train the models, default 50 clusters.

      The model will be saved as DATABASE/models/kmeans.m

Query with a picture

  • Run retrieval.py img_path, for example:

    python retrieval.py img/Sheer_Pleated-Front_Blouse/img_00000005.jpg.

    Set DISTANCE_METRIC in config.py to use different metrics such as cosine, euclidean on deep feature and color feature..

output

Capture

For training on your own (unless you have a good GPU, don't even try)

Training

  1. Download dataset from DeepFashion: Attribute Prediction
  2. Unzip all files and set DATASET_BASE in config.py
  3. Run train.py

The models will be saved to DATASET_BASE/models.

My model: Download from Google Drive

Deep Feature: ResNet50 - (Linear 1024 to 512) - (Linear 512 to 20), the 512-dim vector is regarded as images' identical features.

Loss: CrossEntropyLoss + TripletMarginLoss * Weight

Color Feature: Get ResNet50 final conv layer output(N * C * 7 * 7), then do avg_pooling on channel dim. Choose the max-N responses and extract the corresponding blocks on avg_pooling map of original image.

Training details: Freeze the conv parameters and train net until a stable accuracy and loss, then set FREEZE to False and train it again.

If you applied the DeepFashion: In-shop Clothes Retrieval, you can set ENABLE_INSHOP_DATASET to True.

Directory structure:

  • DATASET_BASE
    • Anno
    • Eval
    • img
    • models(generated)
    • in_shop(optional)
      • list_bbox_inshop.txt
      • list_eval_partition.txt
      • img
    • all_feat.list(generated)
    • all_feat.npy(generated)
    • all_color_feat.npy(generated)

Environment

  • Intel(R) Core(TM) i7-7700HQ CPU with 16GB RAM
  • GeForce GTX 1060 Ti with CUDA 10
  • Ubuntu 16.04
  • Pytorch 1.1 (Stable)

Acknowledgement

(https://github.com/ihciah/deep-fashion-retrieval)Warning: Not maintained anymore.

About

This is an updated implementation of Simple image retrieval algorithm on deep-fashion dataset with pytorch

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages