Skip to content

Instantly share code, notes, and snippets.

@adujardin
Last active July 18, 2022 09:41
Show Gist options
  • Save adujardin/9fa659882a71a304712c6090212c73a6 to your computer and use it in GitHub Desktop.
Save adujardin/9fa659882a71a304712c6090212c73a6 to your computer and use it in GitHub Desktop.
yolov7_val.sh
#docker run --gpus=all -it -v /:/host/ nvcr.io/nvidia/pytorch:22.02-py3
host_folder="/host/tmp/yolov7_results.txt"
rm ${host_folder}
git clone https://github.com/WongKinYiu/yolov7
cd yolov7
pip install -qr requirements.txt
pip uninstall opencv-python
pip install opencv-python-headless==4.4.0.40
# Download/unzip labels
d='./' # unzip directory
url=https://github.com/ultralytics/yolov5/releases/download/v1.0/
f='coco2017labels-segments.zip' # or 'coco2017labels.zip', 68 MB
echo 'Downloading' $url$f ' ...'
curl -L $url$f -o $f && unzip -q $f -d $d && rm $f & # download, unzip, remove in background
# Download/unzip images
d='./coco/images' # unzip directory
url=http://images.cocodataset.org/zips/
f2='val2017.zip' # 1G, 5k images
echo 'Downloading' $url$f2 '...'
curl -L $url$f2 -o $f2 && unzip -q $f2 -d $d && rm $f2
wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7.pt
wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7x.pt
wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7-tiny.pt
yolov7_variants=("yolov7-tiny" "yolov7" "yolov7x")
image_sizes=("320" "384" "416" "512" "608" "640")
for variant in "${yolov7_variants[@]}"; do
for size in "${image_sizes[@]}"; do
echo -e "------ ${variant} ${size} ------" >> ${host_folder} 2>&1
python test.py --weights ${variant}.pt --data data/coco.yaml --batch-size 8 --img ${size} --conf 0.001 --iou 0.65 --save-txt --verbose 2>&1 | tee -a ${host_folder} # mAP
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment