私的AI研究会 > Colab
機械学習や Deep Learning の実行環境に「Google Colaboratory」を使ってみる
YOLO V7 を使ってカスタムデータによる学習を実行する
print("hello colaboratory!")入力欄(セル)の下に結果が表示され簡単に Python の実行環境が手に入る
!apt install lshw
!lshw : *-memory description: System memory physical id: 0 size: 12GiB *-cpu product: Intel(R) Xeon(R) CPU @ 2.20GHz vendor: Intel Corp. physical id: 1 bus info: cpu@0 width: 64 bits : *-display description: 3D controller product: TU104GL [Tesla T4] vendor: NVIDIA Corporation physical id: 4 bus info: pci@0000:00:04.0 version: a1 width: 64 bits clock: 33MHz :※「CPU Intel(R) Xeon(R) 2.20GHz」「メモリ 12GB」「GPU Tesla T4」の実行環境が確認できる
cd /content/drive/MyDrive/try・結果表示
/content/drive/MyDrive/try※ カレントディレクトリを確認するコマンド
!pwd
!git clone https://github.com/WongKinYiu/yolov7
cd yolov7
!pip install -r requirements.txt
!wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7-tiny.pt
!python detect.py --source inference/images/ --weights yolov7-tiny.pt --conf 0.25 --img-size 1280 --device 0
yolov7 ┗ data ┗ janken4_dataset
yolov7 ┠ data ┃ ┗ janken4_dataset ┗ janken4_dataset.yaml
cd /content/drive/MyDrive/try/yolov7
/content/drive/MyDrive/try/yolov7
!python train.py --workers 8 --batch-size 32 --data janken4_dataset.yaml --cfg cfg/training/yolov7-tiny.yaml --weights 'yolov7-tiny.pt' --name yolov7-tiny_jk4 --hyp data/hyp.scratch.tiny.yaml --epochs 50 --device 0
!pip install onnx
!python export.py --weights runs/train/yolov7-tiny_jk4/weights/best.pt
(py38a) PS > cd /anaconda_win/work/yolov7
入力ソース | コマンド |
カメラ画像 | python object_detect_yolo7.py -m ../yolov7-main/runs/train/yolov7-tiny_jk4/weights/best.onnx -l janken.names_jp -i cam -d GPU |
janken3.jpg | python object_detect_yolo7.py -m ../yolov7-main/runs/train/yolov7-tiny_jk4/weights/best.onnx -l janken.names_jp -i ../../Images/janken3.jpg -d GPU |
janken2.jpg | python object_detect_yolo7.py -m ../yolov7-main/runs/train/yolov7-tiny_jk4/weights/best.onnx -l janken.names_jp -i ../../Images/janken2.jpg -d GPU |
janken.jpg | python object_detect_yolo7.py -m ../yolov7-main/runs/train/yolov7-tiny_jk4/weights/best.onnx -l janken.names_jp -i ../../Images/janken.jpg -d GPU |
janken_test.mp4 | python object_detect_yolo7.py -m ../yolov7-main/runs/train/yolov7-tiny_jk4/weights/best.onnx -l janken.names_jp -i ../../Videos/janken_test.mp4 |
janken_test2.mp4 | python object_detect_yolo7.py -m ../yolov7-main/runs/train/yolov7-tiny_jk4/weights/best.onnx -l janken.names_jp -i ../../Videos/janken_test2.mp4 |