Object detection tests
Now develops 2 ways for solution 'object detection purpose':
Torchvision pipeline
YOLO pipeline like submodules
Main pipelines is available in Wolf SSH server with path /data/CNN_object_detectors
.
Data for import exists in Label studio server in VLG Navmii Label Studio
Project gitlab : https://gitlab.navmii.com/AI/cnn_object_detectors
Labels is in proj/configs_for_models/datasetYolo.yaml
- for yolo (imported labels is in proj/projDataset/yolo/classes.txt
)proj/customModel/config.py
- for custom
Labels:
Training /data/CNN_object_detectors
:
docker build -f ./Dockerfile -t image_detector .
docker run -p 8888:8888 -v $(pwd)/proj:/proj --gpus=all --ipc=host -it --rm image_detector /bin/bash
Torchvision (custom) pipeline:
cd ./proj
python3 ./train.py
YOLO:
cd proj/YOLOv5
python3 train.py --img 800 --batch 8 --epochs 100 --workers 0 --name yolov5-custom --data ../configs_for_models/datasetYolo.yaml --weights ../pretrained_weights/yolov5s.pt
Between trainings with different yolo versions, dont forget clean dataset cache
Test /data/CNN_object_detectors
:
docker run -p 8888:8888 -v $(pwd)/proj:/proj --ipc=host -it --rm image_detector /bin/bash
Torchvision (custom) pipeline:
cd ./proj/customModel
python3 ./optim.py #for quatize and getting onnx model
python3 ./inference.py #for inference pt model
python3 ./inference_onnx.py #for inference onnx quant model
python3 ./export_to_mobile.py #for tracing model and export to android and kotlin
If you want testing model with own data, insert path to VALID_DS_DIR
in config.py
YOLO(detect.py
as test script):
actual on WolfSSH yolov5 model - yolov5-custom3
cd proj/YOLOv5
python3 export.py --weights ./runs/train/yolov5-custom3/weights/best.pt --topk-all 100 --iou-thres 0.5 --conf-thres 0.35 --img-size 800 --data ../configs_for_models/datasetYolo.yaml -include onnx coreml tflite
python3 detect.py --weights ./runs/train/yolov5-custom3/weights/best.pt --source ../projDataset/validate/
If you want testing model with own data, insert path to --source
cd proj/YOLOv7
python3 train.py --img 800 --batch 8 --epochs 100 --workers 0 --name yolov5-custom --data ../configs_for_models/datasetYolo.yaml --weights ../pretrained_weights/yolov5s.pt
python3 export.py --weights ./runs/train/yolov7-custom/weights/best.pt --grid --end2end --topk-all 100 --iou-thres 0.5 --conf-thres 0.35 --img-size 900 900 --max-wh 900
python3 detect.py --source ../projDataset/validate/ --weights ./runs/train/yolov7-custom/weights/best.pt
Or after successful ONNX stage in export.py
:
cd proj/utils
python3 ./YoloCustomOnnxTest.py
Please choose VALID_DS_DIR
, OUT_INF_DIR
, YOLO_VERSION
and Sizes
for using YoloCustomOnnxTest.py
in there