Code Monkey home page Code Monkey logo

meituan-food-recognition's Introduction

注意事项

1.请把train和val一起放在/dataset/MTFood-1000/data/train文件夹下,一共是85296张图片,test单独放在/dataset/MTFood-1000/data/test里

2.labels已经制作好了,注意那个test_lable.txt没有用,但不要删,如果要再次制作label需要删除以前的txt

3.我是在两块1080ti上训练的,大概30个epoch用了15个小时,根据自己服务器情况调整train.py里batch和numworkers

4.resnet50的预训练模型已经放在了moels里,其它模型的话请看config.py,并修改train.py相关参数

5.我设置的每1000个step评估一次val,并保存模型,没有评估train,print的信息被我改的比较混乱,重点看train的三个loss和val的top3_acc,可以自行修改

6.pytorch用的是0.4.0

7.训练直接运行train.py,验证val运行val.py,预测运行test.py,注意修改val.py和test.py的108行为自己训练保存的模型,运行完后手动将xls转为csv.

Destruction and Construction Learning for Fine-grained Image Recognition

By Yue Chen, Yalong Bai, Wei Zhang, Tao Mei

Speical thanks to Yuanzhi Liang for code refactoring.

UPDATE Jun. 21

Our solution for the FGVC Challenge 2019 (The Sixth Workshop on Fine-Grained Visual Categorization in CVPR 2019) is updated!

With ensemble of several DCL based classification models, we won:

Introduction

This project is a DCL pytorch implementation of Destruction and Construction Learning for Fine-grained Image Recognition, CVPR2019.

Requirements

  1. Python 3.6

  2. Pytorch 0.4.0 or 0.4.1

  3. CUDA 8.0 or higher

For docker environment:

docker pull pytorch/pytorch:0.4-cuda9-cudnn7-devel

For conda environment:

conda create --name DCL file conda_list.txt

For more backbone supports in DCL, please check pretrainmodels and install:

pip install pretrainedmodels

Datasets Prepare

  1. Download correspond dataset to folder 'datasets'

  2. Data organization: eg. CUB

    All the image data are in './datasets/CUB/data/' e.g. './datasets/CUB/data/*.jpg'

    The annotation files are in './datasets/CUB/anno/' e.g. './dataset/CUB/data/train.txt'

    In annotations:

    name_of_image.jpg label_num\n

    e.g. for CUB in repository:

    Black_Footed_Albatross_0009_34.jpg 0
    Black_Footed_Albatross_0014_89.jpg 0
    Laysan_Albatross_0044_784.jpg 1
    Sooty_Albatross_0021_796339.jpg 2
    ...

Some examples of datasets like CUB, Stanford Car, etc. are already given in our repository. You can use DCL to your datasets by simply converting annotations to train.txt/val.txt/test.txt and modify the class number in config.py as in line67: numcls=200.

Training

Run train.py to train DCL.

For training CUB / STCAR / AIR from scratch

python train.py --data CUB --epoch 360 --backbone resnet50 \
                    --tb 16 --tnw 16 --vb 512 --vnw 16 \
                    --lr 0.0008 --lr_step 60 \
                    --cls_lr_ratio 10 --start_epoch 0 \
                    --detail training_descibe --size 512 \
                    --crop 448 --cls_mul --swap_num 7 7

For training CUB / STCAR / AIR from trained checkpoint

python train.py --data CUB --epoch 360 --backbone resnet50 \
                    --tb 16 --tnw 16 --vb 512 --vnw 16 \
                    --lr 0.0008 --lr_step 60 \
                    --cls_lr_ratio 10 --start_epoch $LAST_EPOCH \
                    --detail training_descibe4checkpoint --size 512 \
                    --crop 448 --cls_mul --swap_num 7 7

For training FGVC product datasets from scratch

 python train.py --data product --epoch 60 --backbone senet154 \
                    --tb 96 --tnw 32 --vb 512 --vnw 32 \
                    --lr 0.01 --lr_step 12 \
                    --cls_lr_ratio 10 --start_epoch 0 \
                    --detail training_descibe --size 512 \
                    --crop 448 --cls_2 --swap_num 7 7

For training FGVC datasets from trained checkpoint

 python train.py --data product --epoch 60 --backbone senet154 \
                    --tb 96 --tnw 32 --vb 512 --vnw 32 \
                    --lr 0.01 --lr_step 12 \
                    --cls_lr_ratio 10 --start_epoch $LAST_EPOCH \
                    --detail training_descibe4checkpoint --size 512 \
                    --crop 448 --cls_2 --swap_num 7 7

To achieve the similar results of paper, please use the default parameter settings.

Citation

Please cite our CVPR19 paper if you use DCL in your work:

@InProceedings{Chen_2019_CVPR,
author = {Chen, Yue and Bai, Yalong and Zhang, Wei and Mei, Tao},
title = {Destruction and Construction Learning for Fine-Grained Image Recognition},
booktitle = {The IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
month = {June},
year = {2019}
}

meituan-food-recognition's People

Contributors

ludc506 avatar ultronai avatar zoeyuchao avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.