Training (You can refer to YOLOv5 website)
I train YOLOv5 model locally, just follow the steps below (use cmd command line)
git clone https://github.com/ultralytics/yolov5.git
pip install -r requirements.txt
# you can also use "JSON_to_txt.py" if you need to convert json file into txt file
- Place your datasets under the folder you want to use
- Modify the path setting in the hw1.yaml under the data folder
- Go to YOLOv5 website, download the pretrain model (I use the YOLOv5x)
# run main.py to train the model
python3 train.py --img 640 --epochs 200 --batch-size 12 --data hw1.yaml --weights yolov5x.pt # this is the hyperparameter I use, can be modify yourself
You can follow the steps just like hw1.sh
Just using the detect.py (you can modify the path and weight)
python3 detect.py --weights ../YOLOv5_checkpoint.pt --source ../yolov5_datasets/test_image
Training (You can refer to DETR website)
I train DETR model locally, just follow the steps below (use cmd command line)
git clone https://github.com/facebookresearch/detr.git
pip install -r requirements.txt
- Place your datasets under the folder you want to use, and don't forget to modify the path setting in the main.py
- Modify the class numbers under the models/detr.py
- Go to DETR website, download the pretrain model (I use the DETR-R50)
# Convert the class numbers in pretrain model (you can modify the class numbers you want in "detr_pretrain_convert_class_to_8.py")
python3 detr_pretrain_convert_class_to_8.py
# run main.py to train the model
python3 main.py --coco_path ../detr_datasets/train/ --epochs 150 --batch_size 2 --resume detr-r50_8.pth # this is the hyperparameter i use, can be modify yourself
You can follow the steps just like hw1.sh
Just using the DETR_BBOX_img.py (you can modify the path, weight and class numbers)
python3 DETR_BBOX_img.py