• Stars
    star
    230
  • Rank 174,053 (Top 4 %)
  • Language
    Python
  • Created almost 7 years ago
  • Updated almost 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple image retrival on deep-fashion dataset with pytorch - A course project

deep-fashion-retrieval

Simple image retrieval algorithm on deep-fashion dataset with pytorch

Capture

Dependencies

  • Python (Compatible with 2 and 3)
  • Pytorch
  • Torchvision
  • PIL
  • cv2(only for visualizing)

Anaconda is recommended.

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)

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..

Time cost

  • 2.854 sec for loading model
  • 0.078 sec for loading feature database
  • 0.519 sec for extracting feature of given image
  • 0.122 sec for doing naive query(139,709 features)
  • 0.038 sec for doing query with kmeans(139,709 features)

Environment

  • Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz with 32GB RAM
  • GeForce GTX TITAN X with CUDA 7.5
  • Ubuntu 14.04
  • Pytorch 0.2.0_4

Future works

  • Add web support
  • Add more models and fuse them

More Repositories

1

shadow-tls

A proxy to expose real tls handshake to the firewall
Rust
2,224
star
2

clean-dns-bpf

基于 Rust + eBPF 丢弃 GFW DNS 污染包
Rust
1,106
star
3

rabbit-tcp

A multi-connection TCP forwarder/accelerator
Go
495
star
4

miaomiaoji-tool

A python tool to control MiaoMiaoJi / Paperang / 喵喵机
Python
154
star
5

go-shadowsocks-magic

A shadowsocks implementation in golang with Multi-connection Acceleration
Go
153
star
6

rust2go

Call Golang from Rust
Rust
147
star
7

tg_channel_bot

Fetch and push to telegram channel/user/group !
Go
99
star
8

inner-shadowsocks

Shadowsocks -> socks5 on server. (Created for providing socks5 proxy for Telegram)
Go
90
star
9

small-map

An inline SIMD accelerated hashmap designed for small amount of data.
Rust
71
star
10

mini-rust-runtime

Rust
49
star
11

google-in-docker

A google reverse proxy in docker
46
star
12

telearia2

Rust
42
star
13

socks5-forwarder

Rust
42
star
14

NAS-tools

Some configure files and scripts for NAS
Shell
40
star
15

CNN_forward

CNN(Convolutional neural network) forward code which requires little dependency(Opencv, TBB-optional) and is easy to run on Windows(using caffe's model)
C++
34
star
16

shadowsocks-with-socks-auth

Shadowsocks with socks auth
Python
33
star
17

ddns-worker

Rust
32
star
18

cloudflare-kv-proxy

Cloudflare Worker KV Proxy
Rust
29
star
19

certain-map

A typed map which can make sure item exist.
Rust
29
star
20

GFHelper

Girl Frontline Helper
Go
25
star
21

rabbit-plugin

A rabbit-tcp plugin for shadowsocks
Go
25
star
22

AndroidSMSRelay

Script to forward and send android(with root) sms using adb
Python
22
star
23

subtitle

A cli tool to download subtitles.
Python
19
star
24

OneEncrypt

A Simple and Naive Encryptor for OneDrive(已投奔OSX,弃坑了!)
C
12
star
25

singleflight-async

Rust
11
star
26

service-async

A Service like tower in async style
Rust
10
star
27

thrift-parser

Rust Thrift Parser
Rust
9
star
28

aria2-rs

Yet Another Aria2 JSON-RPC Client.
Rust
8
star
29

xbox-nginx

xbox 国内加速代理
HTML
8
star
30

simple-ddns

A Simple Dynamic DNS Server for Personal Usage
Python
8
star
31

auto-const-array

Declare a const array without specify its length
Rust
8
star
32

simple-qq-bot

A simple QQ bot (Test account: 2404865065)
Python
7
star
33

HamsterRunning

Automatically log hamsters' running data and send to weibo
Python
7
star
34

trojan-caddy-docker-compose

Dockerfile
7
star
35

wol-homekit

WakeOnLAN with HomeKit
Rust
6
star
36

stinc

Shadowsocks + tinc + chnroute in docker
Shell
5
star
37

urlshorter

网址缩短 附带便笺条功能(On SAE)
CSS
5
star
38

cookieinjector

Wireshark cookie injector for tampermonkey
JavaScript
5
star
39

byte-style-encoder

Rust
4
star
40

static-blog-image-downloader

Rust
4
star
41

douban-api-proxy

豆瓣电影搜索API代理
JavaScript
4
star
42

must-done

An experimental Future that is guaranteed to be done
Rust
3
star
43

classifier-mt

Caffe classifier with multi-thread
C++
2
star
44

oj

做过的oj题目 顺手发上来
C++
2
star
45

bounded-pool

Rust
2
star
46

dorm_tools

寝室自用小工具
Python
1
star
47

XV6-OS

XV6 in OS_class
C
1
star
48

fdcard-captcha

复旦一卡通网站验证码识别(简易SVM
Python
1
star
49

pj

sww的PJ!
C#
1
star
50

MiniJava

MiniJava前端 编译原理Project
HTML
1
star
51

nas-bot

自用Telegram Bot
Go
1
star
52

FudanPTAutoDownloader

A script for auto download torrents of PT@Platform
Python
1
star
53

docker-ocserv

Shell
1
star
54

xk-database

某科学的张江大学选课系统-汪卫的数据库PJ
CSS
1
star