Skip to content

MachineLP/Pytorch_multi_task_classifier

Repository files navigation

Image multi-task classfication

Easy-to-use/Easy-to-deploy/Easy-to-develop

图片名称 图片名称

*** example
models (...等) 1
metric (Swish/ArcMarginProduct_subcenter/ArcFaceLossAdaptiveMargin/...) 2
data aug (rotate/flip/...、mixup/cutmix) 3
loss (ce_loss/ce_smothing_loss/focal_loss/bce_loss/...) 4
deploy (flask/grpc/BentoML等) 5
onnx/trt () 6

train/test/deploy

0、Data format transform

git clone https://github.com/MachineLP/PyTorch_image_classifier
pip install -r requirements.txt
cd PyTorch_image_classifier
python tools/data_preprocess_multi_task.py --data_dir "./data/data.csv" --n_splits 3 --output_dir "./data/train.csv" --random_state 2020

resnet18

1、Modify configuration file

cp conf/resnet18.yaml conf/resnet18.yaml
vim conf/resnet18.yaml

2、Train:

python train_multi_task.py --config_path conf/resnet18.yaml

3、Infer

    python infer_multi_task.py --config_path "conf/resnet18.yaml" --img_path "./data/img/0male/1_2.jpg" --fold "0"
    pre>>>>> [0] [0.6254628] [2] [0.8546583]
    python infer_multi_task.py --config_path "conf/resnet18.yaml" --img_path "./data/img/1female/2_5.jpg" --fold "1"

4、Models transform ( https://github.com/NVIDIA-AI-IOT/torch2trt ) (Tensorrt installation guide on Ubuntu1804)

    onnx:python tools/pytorch_to_onnx_multi_task.py --config_path "conf/resnet18.yaml" --img_path "./data/img/0male/1_2.jpg" --batch_size 4 --fold 0 --save_path "lp.onnx"

    tensorrt:python tools/onnx_to_tensorrt_multi_task.py --config_path "conf/resnet18.yaml" --img_path "./data/img/0male/1_2.jpg" --batch_size 4 --fold 0 --save_path "lp_pp.onnx" --trt_save_path "lp.trt"

5、Deploying models serving

ref

(1)https://github.com/haqishen/SIIM-ISIC-Melanoma-Classification-1st-Place-Solution
(2)https://github.com/BADBADBADBOY/pytorchOCR
(3)https://github.com/MachineLP/QDServing
(4)https://github.com/bentoml/BentoML
(5)mixup-cutmix:https://blog.csdn.net/u014365862/article/details/104216086
(7)focalloss:https://blog.csdn.net/u014365862/article/details/104216192
(8)https://blog.csdn.net/u014365862/article/details/106728375 / https://blog.csdn.net/u014365862/article/details/106728402 

About

multi-task classifier

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages