lawrence722 commited on
Commit
75215ce
1 Parent(s): 67013c7

Upload 5 files

Browse files
Files changed (5) hide show
  1. 409170191.v7.ipynb +1 -0
  2. app.py +146 -0
  3. best.pt +3 -0
  4. last.pt +3 -0
  5. requirements.txt +41 -0
409170191.v7.ipynb ADDED
@@ -0,0 +1 @@
 
 
1
+ {"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"provenance":[],"gpuType":"T4"},"kernelspec":{"name":"python3","display_name":"Python 3"},"language_info":{"name":"python"},"accelerator":"GPU"},"cells":[{"cell_type":"markdown","source":["## 1. 掛載雲端硬碟"],"metadata":{"id":"JvFnrA5V65pO"}},{"cell_type":"code","source":["from google.colab import drive\n","drive.mount('/content/drive')"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"vu6SEPk764ES","executionInfo":{"status":"ok","timestamp":1718263954899,"user_tz":-480,"elapsed":26444,"user":{"displayName":"黃致宇","userId":"05257376044901631491"}},"outputId":"9f1d7a68-f087-4b87-ec1d-47413057c232"},"execution_count":2,"outputs":[{"output_type":"stream","name":"stdout","text":["Mounted at /content/drive\n"]}]},{"cell_type":"markdown","source":["## 2. 安裝套件"],"metadata":{"id":"eOlb0q627EZI"}},{"cell_type":"code","source":["!pip install --upgrade pyyaml==5.3.1"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"5SCKBEDB7EFG","executionInfo":{"status":"ok","timestamp":1718263957162,"user_tz":-480,"elapsed":2268,"user":{"displayName":"黃致宇","userId":"05257376044901631491"}},"outputId":"d7c7230a-0d22-4348-9de4-9e1ee4d39b30"},"execution_count":3,"outputs":[{"output_type":"stream","name":"stdout","text":["Collecting pyyaml==5.3.1\n"," Downloading PyYAML-5.3.1.tar.gz (269 kB)\n","\u001b[?25l \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m0.0/269.4 kB\u001b[0m \u001b[31m?\u001b[0m eta \u001b[36m-:--:--\u001b[0m\r\u001b[2K \u001b[91m━━━━━━━━━━━━━\u001b[0m\u001b[91m╸\u001b[0m\u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m92.2/269.4 kB\u001b[0m \u001b[31m2.6 MB/s\u001b[0m eta \u001b[36m0:00:01\u001b[0m\r\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m269.4/269.4 kB\u001b[0m \u001b[31m5.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n","\u001b[?25h \u001b[1;31merror\u001b[0m: \u001b[1msubprocess-exited-with-error\u001b[0m\n"," \n"," \u001b[31m×\u001b[0m \u001b[32mpython setup.py egg_info\u001b[0m did not run successfully.\n"," \u001b[31m│\u001b[0m exit code: \u001b[1;36m1\u001b[0m\n"," \u001b[31m╰─>\u001b[0m See above for output.\n"," \n"," \u001b[1;35mnote\u001b[0m: This error originates from a subprocess, and is likely not a problem with pip.\n"," Preparing metadata (setup.py) ... \u001b[?25l\u001b[?25herror\n","\u001b[1;31merror\u001b[0m: \u001b[1mmetadata-generation-failed\u001b[0m\n","\n","\u001b[31m×\u001b[0m Encountered error while generating package metadata.\n","\u001b[31m╰─>\u001b[0m See above for output.\n","\n","\u001b[1;35mnote\u001b[0m: This is an issue with the package mentioned above, not pip.\n","\u001b[1;36mhint\u001b[0m: See above for details.\n"]}]},{"cell_type":"markdown","source":["## 3. 下載程式碼"],"metadata":{"id":"ngH7Q6Kx6f7m"}},{"cell_type":"code","execution_count":4,"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"QA5CaOZY6aMM","executionInfo":{"status":"ok","timestamp":1718263957163,"user_tz":-480,"elapsed":22,"user":{"displayName":"黃致宇","userId":"05257376044901631491"}},"outputId":"5043cf2d-c098-4711-fe52-8c1573dc315c"},"outputs":[{"output_type":"stream","name":"stdout","text":["/content\n","/content/drive/MyDrive/data3\n"]}],"source":["#顯示當前目錄\n","!pwd\n","\n","#切換目錄\n","%cd /content/drive/MyDrive/data3"]},{"cell_type":"code","source":["# 從git上面下載程式碼(只要執行一次)\n","!git clone https://github.com/WongKinYiu/yolov7.git"],"metadata":{"id":"VGe25V0bVkdb","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1718263957163,"user_tz":-480,"elapsed":19,"user":{"displayName":"黃致宇","userId":"05257376044901631491"}},"outputId":"61428a98-5a00-4ee8-c5b5-aa86c68e337a"},"execution_count":5,"outputs":[{"output_type":"stream","name":"stdout","text":["fatal: destination path 'yolov7' already exists and is not an empty directory.\n"]}]},{"cell_type":"markdown","source":["## 4. 下載已經使用coco dataset預先訓練好的權重\n","* 從 https://github.com/WongKinYiu/yolov7.git 上面去尋找連結"],"metadata":{"id":"zdM561AuAUZc"}},{"cell_type":"code","source":["!wget https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7.pt"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"ffh4H-2E6eEo","executionInfo":{"status":"ok","timestamp":1718263960458,"user_tz":-480,"elapsed":3312,"user":{"displayName":"黃致宇","userId":"05257376044901631491"}},"outputId":"fa564d2c-0ce8-492e-9888-96413319d8b3"},"execution_count":6,"outputs":[{"output_type":"stream","name":"stdout","text":["--2024-06-13 07:32:36-- https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7.pt\n","Resolving github.com (github.com)... 20.205.243.166\n","Connecting to github.com (github.com)|20.205.243.166|:443... connected.\n","HTTP request sent, awaiting response... 302 Found\n","Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/511187726/b0243edf-9fb0-4337-95e1-42555f1b37cf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20240613%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240613T073236Z&X-Amz-Expires=300&X-Amz-Signature=fedc5bb14cb442783ac47bd5c56b16a49c0532d5acaf9a495b8c19e615cf1cb2&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=511187726&response-content-disposition=attachment%3B%20filename%3Dyolov7.pt&response-content-type=application%2Foctet-stream [following]\n","--2024-06-13 07:32:36-- https://objects.githubusercontent.com/github-production-release-asset-2e65be/511187726/b0243edf-9fb0-4337-95e1-42555f1b37cf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20240613%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240613T073236Z&X-Amz-Expires=300&X-Amz-Signature=fedc5bb14cb442783ac47bd5c56b16a49c0532d5acaf9a495b8c19e615cf1cb2&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=511187726&response-content-disposition=attachment%3B%20filename%3Dyolov7.pt&response-content-type=application%2Foctet-stream\n","Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.108.133, 185.199.109.133, 185.199.110.133, ...\n","Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.108.133|:443... connected.\n","HTTP request sent, awaiting response... 200 OK\n","Length: 75587165 (72M) [application/octet-stream]\n","Saving to: ‘yolov7.pt.2’\n","\n","yolov7.pt.2 100%[===================>] 72.08M 39.1MB/s in 1.8s \n","\n","2024-06-13 07:32:39 (39.1 MB/s) - ‘yolov7.pt.2’ saved [75587165/75587165]\n","\n"]}]},{"cell_type":"markdown","source":["## 5. 上傳資料與新增設定檔"],"metadata":{"id":"usnmC9u8AtTw"}},{"cell_type":"code","source":["#切換目錄到剛下載的git專案\n","%cd yolov7"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"0FaLnNRP6eB9","executionInfo":{"status":"ok","timestamp":1718263960458,"user_tz":-480,"elapsed":5,"user":{"displayName":"黃致宇","userId":"05257376044901631491"}},"outputId":"dcd37812-f866-40bb-ec2e-7610153e6aa0"},"execution_count":7,"outputs":[{"output_type":"stream","name":"stdout","text":["/content/drive/MyDrive/data3/yolov7\n"]}]},{"cell_type":"markdown","source":["## 6-1. 在./yolo/data/目錄底下手動建立資料夾 [project名稱]\n","## 6-2. 上傳訓練資料到./yolo/data/train跟 ./yolo/data/val/\n","## 6-3. 複製data目錄底下的coco.yaml, 改名為[project名稱].yaml\n","## 6-4. 編輯[project名稱].yaml裡面的參數\n","* train: ./data/[project名稱]/train\n","* val: ./data/[project名稱]/val\n","* test: ./data/[project名稱]/test\n","* nc: [總共有多少類別]\n","* names: [每個類別代表的英文名稱]\n","\n","## 6-5. 複製cfg/training目錄底下的yolov7.yaml 並改名為yolov7_[project名稱].yaml\n","## 6-6. 編輯yolov7_[project名稱].yaml\n","* nc: [總共有多少類別]"],"metadata":{"id":"px5Ui1z691Gf"}},{"cell_type":"markdown","source":["## 7. 訓練模型"],"metadata":{"id":"o1qlx6w0BIY4"}},{"cell_type":"code","source":["!pwd\n","\n","%cd /content/drive/MyDrive/data3/yolov7"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"Z-vgRl_mVUGk","executionInfo":{"status":"ok","timestamp":1718263961320,"user_tz":-480,"elapsed":865,"user":{"displayName":"黃致宇","userId":"05257376044901631491"}},"outputId":"2c7c4bf2-a7b6-415c-f4e5-fe7c02d623ff"},"execution_count":8,"outputs":[{"output_type":"stream","name":"stdout","text":["/content/drive/MyDrive/data3/yolov7\n","/content/drive/MyDrive/data3/yolov7\n"]}]},{"cell_type":"code","source":["!python train.py --device 0 --batch-size 16 --epochs 100 --data /content/drive/MyDrive/data3/data.yaml --img 640 640 --hyp data/hyp.scratch.custom.yaml --cfg /content/drive/MyDrive/data3/yolov7/cfg/training/triffict.yaml --weights 'yolov7.pt' --name yolov7-fish"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"TtHOAGy56c2Q","outputId":"ee71429e-56bd-496d-c370-3db0b973adbc","executionInfo":{"status":"ok","timestamp":1718267228144,"user_tz":-480,"elapsed":3266826,"user":{"displayName":"黃致宇","userId":"05257376044901631491"}}},"execution_count":9,"outputs":[{"output_type":"stream","name":"stdout","text":["2024-06-13 07:32:45.970999: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:9261] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered\n","2024-06-13 07:32:45.971073: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:607] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered\n","2024-06-13 07:32:45.972920: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1515] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered\n","2024-06-13 07:32:45.983169: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.\n","To enable the following instructions: AVX2 AVX512F FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.\n","2024-06-13 07:32:47.516969: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT\n","YOLOR 🚀 v0.1-128-ga207844 torch 2.3.0+cu121 CUDA:0 (Tesla T4, 15102.0625MB)\n","\n","Namespace(weights='yolov7.pt', cfg='/content/drive/MyDrive/data3/yolov7/cfg/training/triffict.yaml', data='/content/drive/MyDrive/data3/data.yaml', hyp='data/hyp.scratch.custom.yaml', epochs=100, batch_size=16, img_size=[640, 640], rect=False, resume=False, nosave=False, notest=False, noautoanchor=False, evolve=False, bucket='', cache_images=False, image_weights=False, device='0', multi_scale=False, single_cls=False, adam=False, sync_bn=False, local_rank=-1, workers=8, project='runs/train', entity=None, name='yolov7-fish', exist_ok=False, quad=False, linear_lr=False, label_smoothing=0.0, upload_dataset=False, bbox_interval=-1, save_period=-1, artifact_alias='latest', freeze=[0], v5_metric=False, world_size=1, global_rank=-1, save_dir='runs/train/yolov7-fish3', total_batch_size=16)\n","\u001b[34m\u001b[1mtensorboard: \u001b[0mStart with 'tensorboard --logdir runs/train', view at http://localhost:6006/\n","\u001b[34m\u001b[1mhyperparameters: \u001b[0mlr0=0.01, lrf=0.1, momentum=0.937, weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1, box=0.05, cls=0.3, cls_pw=1.0, obj=0.7, obj_pw=1.0, iou_t=0.2, anchor_t=4.0, fl_gamma=0.0, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.2, scale=0.5, shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, mosaic=1.0, mixup=0.0, copy_paste=0.0, paste_in=0.0, loss_ota=1\n","\u001b[34m\u001b[1mwandb: \u001b[0mInstall Weights & Biases for YOLOR logging with 'pip install wandb' (recommended)\n","\n"," from n params module arguments \n"," 0 -1 1 928 models.common.Conv [3, 32, 3, 1] \n"," 1 -1 1 18560 models.common.Conv [32, 64, 3, 2] \n"," 2 -1 1 36992 models.common.Conv [64, 64, 3, 1] \n"," 3 -1 1 73984 models.common.Conv [64, 128, 3, 2] \n"," 4 -1 1 8320 models.common.Conv [128, 64, 1, 1] \n"," 5 -2 1 8320 models.common.Conv [128, 64, 1, 1] \n"," 6 -1 1 36992 models.common.Conv [64, 64, 3, 1] \n"," 7 -1 1 36992 models.common.Conv [64, 64, 3, 1] \n"," 8 -1 1 36992 models.common.Conv [64, 64, 3, 1] \n"," 9 -1 1 36992 models.common.Conv [64, 64, 3, 1] \n"," 10 [-1, -3, -5, -6] 1 0 models.common.Concat [1] \n"," 11 -1 1 66048 models.common.Conv [256, 256, 1, 1] \n"," 12 -1 1 0 models.common.MP [] \n"," 13 -1 1 33024 models.common.Conv [256, 128, 1, 1] \n"," 14 -3 1 33024 models.common.Conv [256, 128, 1, 1] \n"," 15 -1 1 147712 models.common.Conv [128, 128, 3, 2] \n"," 16 [-1, -3] 1 0 models.common.Concat [1] \n"," 17 -1 1 33024 models.common.Conv [256, 128, 1, 1] \n"," 18 -2 1 33024 models.common.Conv [256, 128, 1, 1] \n"," 19 -1 1 147712 models.common.Conv [128, 128, 3, 1] \n"," 20 -1 1 147712 models.common.Conv [128, 128, 3, 1] \n"," 21 -1 1 147712 models.common.Conv [128, 128, 3, 1] \n"," 22 -1 1 147712 models.common.Conv [128, 128, 3, 1] \n"," 23 [-1, -3, -5, -6] 1 0 models.common.Concat [1] \n"," 24 -1 1 263168 models.common.Conv [512, 512, 1, 1] \n"," 25 -1 1 0 models.common.MP [] \n"," 26 -1 1 131584 models.common.Conv [512, 256, 1, 1] \n"," 27 -3 1 131584 models.common.Conv [512, 256, 1, 1] \n"," 28 -1 1 590336 models.common.Conv [256, 256, 3, 2] \n"," 29 [-1, -3] 1 0 models.common.Concat [1] \n"," 30 -1 1 131584 models.common.Conv [512, 256, 1, 1] \n"," 31 -2 1 131584 models.common.Conv [512, 256, 1, 1] \n"," 32 -1 1 590336 models.common.Conv [256, 256, 3, 1] \n"," 33 -1 1 590336 models.common.Conv [256, 256, 3, 1] \n"," 34 -1 1 590336 models.common.Conv [256, 256, 3, 1] \n"," 35 -1 1 590336 models.common.Conv [256, 256, 3, 1] \n"," 36 [-1, -3, -5, -6] 1 0 models.common.Concat [1] \n"," 37 -1 1 1050624 models.common.Conv [1024, 1024, 1, 1] \n"," 38 -1 1 0 models.common.MP [] \n"," 39 -1 1 525312 models.common.Conv [1024, 512, 1, 1] \n"," 40 -3 1 525312 models.common.Conv [1024, 512, 1, 1] \n"," 41 -1 1 2360320 models.common.Conv [512, 512, 3, 2] \n"," 42 [-1, -3] 1 0 models.common.Concat [1] \n"," 43 -1 1 262656 models.common.Conv [1024, 256, 1, 1] \n"," 44 -2 1 262656 models.common.Conv [1024, 256, 1, 1] \n"," 45 -1 1 590336 models.common.Conv [256, 256, 3, 1] \n"," 46 -1 1 590336 models.common.Conv [256, 256, 3, 1] \n"," 47 -1 1 590336 models.common.Conv [256, 256, 3, 1] \n"," 48 -1 1 590336 models.common.Conv [256, 256, 3, 1] \n"," 49 [-1, -3, -5, -6] 1 0 models.common.Concat [1] \n"," 50 -1 1 1050624 models.common.Conv [1024, 1024, 1, 1] \n"," 51 -1 1 7609344 models.common.SPPCSPC [1024, 512, 1] \n"," 52 -1 1 131584 models.common.Conv [512, 256, 1, 1] \n"," 53 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest'] \n"," 54 37 1 262656 models.common.Conv [1024, 256, 1, 1] \n"," 55 [-1, -2] 1 0 models.common.Concat [1] \n"," 56 -1 1 131584 models.common.Conv [512, 256, 1, 1] \n"," 57 -2 1 131584 models.common.Conv [512, 256, 1, 1] \n"," 58 -1 1 295168 models.common.Conv [256, 128, 3, 1] \n"," 59 -1 1 147712 models.common.Conv [128, 128, 3, 1] \n"," 60 -1 1 147712 models.common.Conv [128, 128, 3, 1] \n"," 61 -1 1 147712 models.common.Conv [128, 128, 3, 1] \n"," 62[-1, -2, -3, -4, -5, -6] 1 0 models.common.Concat [1] \n"," 63 -1 1 262656 models.common.Conv [1024, 256, 1, 1] \n"," 64 -1 1 33024 models.common.Conv [256, 128, 1, 1] \n"," 65 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest'] \n"," 66 24 1 65792 models.common.Conv [512, 128, 1, 1] \n"," 67 [-1, -2] 1 0 models.common.Concat [1] \n"," 68 -1 1 33024 models.common.Conv [256, 128, 1, 1] \n"," 69 -2 1 33024 models.common.Conv [256, 128, 1, 1] \n"," 70 -1 1 73856 models.common.Conv [128, 64, 3, 1] \n"," 71 -1 1 36992 models.common.Conv [64, 64, 3, 1] \n"," 72 -1 1 36992 models.common.Conv [64, 64, 3, 1] \n"," 73 -1 1 36992 models.common.Conv [64, 64, 3, 1] \n"," 74[-1, -2, -3, -4, -5, -6] 1 0 models.common.Concat [1] \n"," 75 -1 1 65792 models.common.Conv [512, 128, 1, 1] \n"," 76 -1 1 0 models.common.MP [] \n"," 77 -1 1 16640 models.common.Conv [128, 128, 1, 1] \n"," 78 -3 1 16640 models.common.Conv [128, 128, 1, 1] \n"," 79 -1 1 147712 models.common.Conv [128, 128, 3, 2] \n"," 80 [-1, -3, 63] 1 0 models.common.Concat [1] \n"," 81 -1 1 131584 models.common.Conv [512, 256, 1, 1] \n"," 82 -2 1 131584 models.common.Conv [512, 256, 1, 1] \n"," 83 -1 1 295168 models.common.Conv [256, 128, 3, 1] \n"," 84 -1 1 147712 models.common.Conv [128, 128, 3, 1] \n"," 85 -1 1 147712 models.common.Conv [128, 128, 3, 1] \n"," 86 -1 1 147712 models.common.Conv [128, 128, 3, 1] \n"," 87[-1, -2, -3, -4, -5, -6] 1 0 models.common.Concat [1] \n"," 88 -1 1 262656 models.common.Conv [1024, 256, 1, 1] \n"," 89 -1 1 0 models.common.MP [] \n"," 90 -1 1 66048 models.common.Conv [256, 256, 1, 1] \n"," 91 -3 1 66048 models.common.Conv [256, 256, 1, 1] \n"," 92 -1 1 590336 models.common.Conv [256, 256, 3, 2] \n"," 93 [-1, -3, 51] 1 0 models.common.Concat [1] \n"," 94 -1 1 525312 models.common.Conv [1024, 512, 1, 1] \n"," 95 -2 1 525312 models.common.Conv [1024, 512, 1, 1] \n"," 96 -1 1 1180160 models.common.Conv [512, 256, 3, 1] \n"," 97 -1 1 590336 models.common.Conv [256, 256, 3, 1] \n"," 98 -1 1 590336 models.common.Conv [256, 256, 3, 1] \n"," 99 -1 1 590336 models.common.Conv [256, 256, 3, 1] \n","100[-1, -2, -3, -4, -5, -6] 1 0 models.common.Concat [1] \n","101 -1 1 1049600 models.common.Conv [2048, 512, 1, 1] \n","102 75 1 328704 models.common.RepConv [128, 256, 3, 1] \n","103 88 1 1312768 models.common.RepConv [256, 512, 3, 1] \n","104 101 1 5246976 models.common.RepConv [512, 1024, 3, 1] \n","105 [102, 103, 104] 1 61126 models.yolo.IDetect [6, [[12, 16, 19, 36, 40, 28], [36, 75, 76, 55, 72, 146], [142, 110, 192, 243, 459, 401]], [256, 512, 1024]]\n","Model Summary: 415 layers, 37223526 parameters, 37223526 gradients\n","\n","Transferred 552/566 items from yolov7.pt\n","Scaled weight_decay = 0.0005\n","Optimizer groups: 95 .bias, 95 conv.weight, 98 other\n","\u001b[34m\u001b[1mtrain: \u001b[0mScanning '/content/drive/MyDrive/data3/train/labels.cache' images and labels... 338 found, 0 missing, 0 empty, 0 corrupted: 100% 338/338 [00:00<?, ?it/s]\n","/usr/lib/python3.10/multiprocessing/popen_fork.py:66: RuntimeWarning: os.fork() was called. os.fork() is incompatible with multithreaded code, and JAX is multithreaded, so this will likely lead to a deadlock.\n"," self.pid = os.fork()\n","\u001b[34m\u001b[1mval: \u001b[0mScanning '/content/drive/MyDrive/data3/valid/labels.cache' images and labels... 100 found, 0 missing, 0 empty, 0 corrupted: 100% 100/100 [00:00<?, ?it/s]\n","\n","\u001b[34m\u001b[1mautoanchor: \u001b[0mAnalyzing anchors... anchors/target = 4.11, Best Possible Recall (BPR) = 1.0000\n","Image sizes 640 train, 640 test\n","Using 2 dataloader workers\n","Logging results to runs/train/yolov7-fish3\n","Starting training for 100 epochs...\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 0/99 1.12G 0.07343 0.01657 0.03208 0.1221 5 640: 100% 22/22 [01:11<00:00, 3.26s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 0% 0/4 [00:00<?, ?it/s]/usr/local/lib/python3.10/dist-packages/torch/functional.py:512: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:3587.)\n"," return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:10<00:00, 2.61s/it]\n"," all 100 288 0.00314 0.0332 0.000673 0.000163\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 1/99 12.5G 0.06626 0.01606 0.02921 0.1115 10 640: 100% 22/22 [00:26<00:00, 1.20s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:05<00:00, 1.26s/it]\n"," all 100 288 0.0134 0.0245 0.00623 0.00101\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 2/99 11.1G 0.05859 0.01656 0.02625 0.1014 11 640: 100% 22/22 [00:24<00:00, 1.09s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:03<00:00, 1.03it/s]\n"," all 100 288 0.862 0.0633 0.0484 0.0138\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 3/99 11.1G 0.0537 0.01596 0.02283 0.09249 9 640: 100% 22/22 [00:25<00:00, 1.15s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:04<00:00, 1.21s/it]\n"," all 100 288 0.88 0.0691 0.0716 0.024\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 4/99 11.1G 0.05165 0.01497 0.02024 0.08686 9 640: 100% 22/22 [00:24<00:00, 1.13s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.46it/s]\n"," all 100 288 0.918 0.0949 0.119 0.0374\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 5/99 11.1G 0.04925 0.0137 0.01858 0.08153 4 640: 100% 22/22 [00:26<00:00, 1.21s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:04<00:00, 1.12s/it]\n"," all 100 288 0.918 0.102 0.154 0.0492\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 6/99 11.1G 0.04989 0.01371 0.01779 0.0814 17 640: 100% 22/22 [00:25<00:00, 1.15s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.55it/s]\n"," all 100 288 0.361 0.433 0.177 0.0493\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 7/99 11.1G 0.04817 0.01208 0.01614 0.07639 2 640: 100% 22/22 [00:26<00:00, 1.21s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.43it/s]\n"," all 100 288 0.384 0.281 0.202 0.0494\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 8/99 11.1G 0.05058 0.01266 0.01611 0.07935 14 640: 100% 22/22 [00:25<00:00, 1.18s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:04<00:00, 1.16s/it]\n"," all 100 288 0.436 0.446 0.306 0.104\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 9/99 11.1G 0.04952 0.01155 0.01434 0.0754 2 640: 100% 22/22 [00:24<00:00, 1.12s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:03<00:00, 1.29it/s]\n"," all 100 288 0.651 0.226 0.213 0.0692\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 10/99 11.1G 0.05071 0.01238 0.01597 0.07907 12 640: 100% 22/22 [00:24<00:00, 1.13s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.40it/s]\n"," all 100 288 0.533 0.423 0.34 0.129\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 11/99 11.1G 0.04892 0.01149 0.01567 0.07607 6 640: 100% 22/22 [00:27<00:00, 1.26s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:03<00:00, 1.13it/s]\n"," all 100 288 0.72 0.304 0.308 0.127\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 12/99 11.1G 0.05012 0.01233 0.01369 0.07614 9 640: 100% 22/22 [00:23<00:00, 1.08s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:03<00:00, 1.04it/s]\n"," all 100 288 0.657 0.354 0.367 0.155\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 13/99 11.1G 0.05234 0.01163 0.01401 0.07798 7 640: 100% 22/22 [00:24<00:00, 1.12s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.43it/s]\n"," all 100 288 0.781 0.408 0.404 0.155\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 14/99 11.1G 0.04692 0.01152 0.01176 0.0702 3 640: 100% 22/22 [00:29<00:00, 1.35s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.45it/s]\n"," all 100 288 0.588 0.352 0.278 0.0931\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 15/99 11.1G 0.05109 0.0118 0.01345 0.07634 6 640: 100% 22/22 [00:24<00:00, 1.09s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:03<00:00, 1.07it/s]\n"," all 100 288 0.604 0.441 0.336 0.136\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 16/99 11.1G 0.04412 0.012 0.01314 0.06925 10 640: 100% 22/22 [00:25<00:00, 1.14s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.43it/s]\n"," all 100 288 0.495 0.27 0.205 0.0824\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 17/99 11.1G 0.04513 0.01139 0.01171 0.06823 10 640: 100% 22/22 [00:24<00:00, 1.13s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:04<00:00, 1.14s/it]\n"," all 100 288 0.661 0.345 0.348 0.13\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 18/99 11.1G 0.04013 0.01212 0.01091 0.06316 6 640: 100% 22/22 [00:23<00:00, 1.08s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.38it/s]\n"," all 100 288 0.287 0.235 0.0476 0.0158\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 19/99 11.1G 0.04957 0.01165 0.01278 0.074 14 640: 100% 22/22 [00:25<00:00, 1.17s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.52it/s]\n"," all 100 288 0.552 0.201 0.16 0.0534\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 20/99 11.1G 0.0432 0.01099 0.01003 0.06421 6 640: 100% 22/22 [00:23<00:00, 1.07s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:03<00:00, 1.03it/s]\n"," all 100 288 0.742 0.425 0.436 0.172\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 21/99 11.1G 0.04771 0.01147 0.01063 0.06981 7 640: 100% 22/22 [00:24<00:00, 1.12s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:03<00:00, 1.21it/s]\n"," all 100 288 0.652 0.393 0.377 0.151\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 22/99 11.1G 0.04425 0.01208 0.01183 0.06816 5 640: 100% 22/22 [00:25<00:00, 1.15s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:03<00:00, 1.32it/s]\n"," all 100 288 0.5 0.259 0.167 0.0529\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 23/99 11.1G 0.048 0.01277 0.01482 0.07559 7 640: 100% 22/22 [00:23<00:00, 1.08s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:04<00:00, 1.04s/it]\n"," all 100 288 0.246 0.0255 0.0052 0.000953\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 24/99 12.5G 0.04232 0.01214 0.01148 0.06595 3 640: 100% 22/22 [00:24<00:00, 1.10s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.65it/s]\n"," all 100 288 0.203 0.0129 0.000624 0.000163\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 25/99 12.5G 0.04772 0.01205 0.01165 0.07142 8 640: 100% 22/22 [00:25<00:00, 1.18s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:03<00:00, 1.06it/s]\n"," all 100 288 0.222 0.0632 0.0099 0.00151\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 26/99 12.5G 0.04478 0.01225 0.01105 0.06808 16 640: 100% 22/22 [00:24<00:00, 1.10s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.36it/s]\n"," all 100 288 0.0144 0.0585 0.00311 0.000925\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 27/99 12.5G 0.04159 0.01187 0.01049 0.06394 8 640: 100% 22/22 [00:24<00:00, 1.13s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.36it/s]\n"," all 100 288 0.669 0.333 0.331 0.131\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 28/99 12.5G 0.04176 0.0119 0.009673 0.06334 15 640: 100% 22/22 [00:23<00:00, 1.07s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.45it/s]\n"," all 100 288 0.66 0.331 0.325 0.123\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 29/99 12.5G 0.03409 0.01088 0.007783 0.05274 5 640: 100% 22/22 [00:25<00:00, 1.17s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.35it/s]\n"," all 100 288 0.608 0.396 0.366 0.156\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 30/99 12.5G 0.0388 0.0115 0.009283 0.05958 10 640: 100% 22/22 [00:22<00:00, 1.03s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:03<00:00, 1.08it/s]\n"," all 100 288 0.709 0.431 0.439 0.178\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 31/99 12.5G 0.0423 0.01166 0.009611 0.06357 11 640: 100% 22/22 [00:23<00:00, 1.07s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:03<00:00, 1.26it/s]\n"," all 100 288 0.615 0.448 0.36 0.115\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 32/99 12.5G 0.04047 0.01151 0.008159 0.06014 5 640: 100% 22/22 [00:25<00:00, 1.16s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:03<00:00, 1.26it/s]\n"," all 100 288 0.719 0.509 0.491 0.21\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 33/99 12.5G 0.03315 0.01125 0.006074 0.05048 7 640: 100% 22/22 [00:26<00:00, 1.22s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:04<00:00, 1.09s/it]\n"," all 100 288 0.752 0.462 0.484 0.197\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 34/99 12.5G 0.03997 0.01078 0.00829 0.05904 5 640: 100% 22/22 [00:23<00:00, 1.08s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.45it/s]\n"," all 100 288 0.754 0.488 0.485 0.194\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 35/99 12.5G 0.03453 0.01095 0.006492 0.05196 3 640: 100% 22/22 [00:23<00:00, 1.08s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:05<00:00, 1.29s/it]\n"," all 100 288 0.693 0.508 0.48 0.196\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 36/99 12.5G 0.03006 0.01114 0.005025 0.04622 10 640: 100% 22/22 [00:22<00:00, 1.03s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.53it/s]\n"," all 100 288 0.782 0.58 0.562 0.238\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 37/99 12.5G 0.03526 0.01159 0.005378 0.05223 13 640: 100% 22/22 [00:25<00:00, 1.17s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:03<00:00, 1.05it/s]\n"," all 100 288 0.787 0.553 0.565 0.245\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 38/99 12.5G 0.03932 0.01064 0.007064 0.05703 2 640: 100% 22/22 [00:23<00:00, 1.07s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:03<00:00, 1.08it/s]\n"," all 100 288 0.762 0.522 0.522 0.219\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 39/99 12.5G 0.03437 0.01116 0.007261 0.0528 8 640: 100% 22/22 [00:23<00:00, 1.06s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.48it/s]\n"," all 100 288 0.661 0.425 0.393 0.157\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 40/99 12.5G 0.03686 0.01142 0.007929 0.05621 7 640: 100% 22/22 [00:23<00:00, 1.07s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:04<00:00, 1.18s/it]\n"," all 100 288 0.682 0.435 0.424 0.181\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 41/99 12.5G 0.03994 0.01121 0.008274 0.05943 7 640: 100% 22/22 [00:23<00:00, 1.08s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.44it/s]\n"," all 100 288 0.547 0.378 0.307 0.108\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 42/99 12.5G 0.04126 0.01123 0.00747 0.05996 17 640: 100% 22/22 [00:29<00:00, 1.34s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.45it/s]\n"," all 100 288 0.618 0.512 0.418 0.167\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 43/99 12.5G 0.0383 0.01129 0.008437 0.05802 7 640: 100% 22/22 [00:23<00:00, 1.05s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:03<00:00, 1.15it/s]\n"," all 100 288 0.635 0.365 0.341 0.155\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 44/99 12.5G 0.03607 0.01165 0.008139 0.05586 17 640: 100% 22/22 [00:23<00:00, 1.06s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.57it/s]\n"," all 100 288 0.617 0.429 0.388 0.15\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 45/99 12.5G 0.03057 0.01103 0.006084 0.04768 3 640: 100% 22/22 [00:23<00:00, 1.06s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:04<00:00, 1.01s/it]\n"," all 100 288 0.493 0.256 0.227 0.0803\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 46/99 12.5G 0.03219 0.01143 0.005667 0.04929 8 640: 100% 22/22 [00:23<00:00, 1.06s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.53it/s]\n"," all 100 288 0.516 0.412 0.302 0.12\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 47/99 12.5G 0.03642 0.01104 0.007334 0.05479 8 640: 100% 22/22 [00:23<00:00, 1.08s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:04<00:00, 1.16s/it]\n"," all 100 288 0.447 0.266 0.185 0.0716\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 48/99 12.5G 0.03508 0.01072 0.006626 0.05243 3 640: 100% 22/22 [00:23<00:00, 1.05s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.47it/s]\n"," all 100 288 0.697 0.519 0.491 0.203\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 49/99 12.5G 0.03671 0.01109 0.008408 0.0562 8 640: 100% 22/22 [00:23<00:00, 1.06s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:04<00:00, 1.17s/it]\n"," all 100 288 0.63 0.377 0.355 0.142\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 50/99 12.5G 0.03919 0.01119 0.009259 0.05964 9 640: 100% 22/22 [00:23<00:00, 1.08s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:03<00:00, 1.21it/s]\n"," all 100 288 0.668 0.398 0.36 0.154\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 51/99 12.5G 0.04162 0.0117 0.006991 0.06031 6 640: 100% 22/22 [00:24<00:00, 1.13s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:04<00:00, 1.17s/it]\n"," all 100 288 0.486 0.394 0.299 0.129\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 52/99 12.5G 0.03476 0.01171 0.008199 0.05466 5 640: 100% 22/22 [00:24<00:00, 1.10s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:05<00:00, 1.28s/it]\n"," all 100 288 0.589 0.424 0.381 0.152\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 53/99 12.5G 0.03457 0.012 0.006016 0.05258 8 640: 100% 22/22 [00:23<00:00, 1.07s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.44it/s]\n"," all 100 288 0.636 0.453 0.436 0.19\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 54/99 12.5G 0.03861 0.01102 0.006828 0.05646 6 640: 100% 22/22 [00:25<00:00, 1.15s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:03<00:00, 1.32it/s]\n"," all 100 288 0.727 0.516 0.516 0.232\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 55/99 12.5G 0.03131 0.01063 0.006179 0.04812 9 640: 100% 22/22 [00:23<00:00, 1.07s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:03<00:00, 1.20it/s]\n"," all 100 288 0.707 0.553 0.543 0.246\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 56/99 12.5G 0.03279 0.01064 0.005051 0.04848 7 640: 100% 22/22 [00:24<00:00, 1.12s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.39it/s]\n"," all 100 288 0.706 0.612 0.559 0.255\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 57/99 12.5G 0.03458 0.01118 0.00592 0.05168 7 640: 100% 22/22 [00:24<00:00, 1.11s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:03<00:00, 1.04it/s]\n"," all 100 288 0.748 0.601 0.563 0.265\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 58/99 12.5G 0.03083 0.01102 0.004703 0.04655 14 640: 100% 22/22 [00:25<00:00, 1.14s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:03<00:00, 1.14it/s]\n"," all 100 288 0.793 0.576 0.59 0.278\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 59/99 12.5G 0.0329 0.01115 0.005283 0.04933 7 640: 100% 22/22 [00:24<00:00, 1.11s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.45it/s]\n"," all 100 288 0.768 0.579 0.58 0.281\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 60/99 12.5G 0.03244 0.01114 0.005445 0.04902 5 640: 100% 22/22 [00:27<00:00, 1.27s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:04<00:00, 1.10s/it]\n"," all 100 288 0.76 0.632 0.596 0.283\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 61/99 12.5G 0.02782 0.01129 0.003955 0.04307 6 640: 100% 22/22 [00:24<00:00, 1.10s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:03<00:00, 1.27it/s]\n"," all 100 288 0.768 0.609 0.598 0.291\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 62/99 12.5G 0.03529 0.01113 0.006207 0.05263 13 640: 100% 22/22 [00:23<00:00, 1.09s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.46it/s]\n"," all 100 288 0.789 0.591 0.579 0.283\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 63/99 12.5G 0.0314 0.01119 0.004977 0.04756 11 640: 100% 22/22 [00:24<00:00, 1.09s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:04<00:00, 1.12s/it]\n"," all 100 288 0.801 0.589 0.595 0.288\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 64/99 12.5G 0.02789 0.01062 0.004013 0.04253 6 640: 100% 22/22 [00:23<00:00, 1.05s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.51it/s]\n"," all 100 288 0.824 0.582 0.614 0.31\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 65/99 12.5G 0.02664 0.01145 0.00424 0.04233 10 640: 100% 22/22 [00:25<00:00, 1.16s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.41it/s]\n"," all 100 288 0.811 0.609 0.612 0.309\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 66/99 12.5G 0.03078 0.01069 0.005281 0.04675 15 640: 100% 22/22 [00:25<00:00, 1.16s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:04<00:00, 1.14s/it]\n"," all 100 288 0.811 0.617 0.622 0.304\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 67/99 12.5G 0.02811 0.01095 0.003605 0.04266 8 640: 100% 22/22 [00:24<00:00, 1.10s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.53it/s]\n"," all 100 288 0.833 0.578 0.599 0.294\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 68/99 12.5G 0.02922 0.01112 0.004176 0.04451 11 640: 100% 22/22 [00:26<00:00, 1.22s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.43it/s]\n"," all 100 288 0.801 0.646 0.617 0.298\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 69/99 12.5G 0.03134 0.0106 0.005991 0.04793 9 640: 100% 22/22 [00:27<00:00, 1.23s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:04<00:00, 1.19s/it]\n"," all 100 288 0.79 0.675 0.62 0.302\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 70/99 14.8G 0.02842 0.01061 0.003721 0.04275 6 640: 100% 22/22 [00:24<00:00, 1.12s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.46it/s]\n"," all 100 288 0.855 0.629 0.628 0.313\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 71/99 14.8G 0.03367 0.01046 0.005545 0.04968 7 640: 100% 22/22 [00:26<00:00, 1.20s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.42it/s]\n"," all 100 288 0.846 0.654 0.629 0.321\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 72/99 14.8G 0.02641 0.01142 0.003645 0.04147 19 640: 100% 22/22 [00:27<00:00, 1.25s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.38it/s]\n"," all 100 288 0.824 0.668 0.632 0.323\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 73/99 14.8G 0.02626 0.01099 0.00332 0.04057 12 640: 100% 22/22 [00:24<00:00, 1.13s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:04<00:00, 1.22s/it]\n"," all 100 288 0.826 0.646 0.633 0.317\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 74/99 14.8G 0.02931 0.01049 0.003847 0.04364 3 640: 100% 22/22 [00:23<00:00, 1.08s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.43it/s]\n"," all 100 288 0.842 0.645 0.632 0.316\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 75/99 14.8G 0.03672 0.01061 0.005893 0.05323 15 640: 100% 22/22 [00:27<00:00, 1.27s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.45it/s]\n"," all 100 288 0.816 0.666 0.631 0.311\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 76/99 14.8G 0.02999 0.01056 0.004733 0.04529 12 640: 100% 22/22 [00:23<00:00, 1.08s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:03<00:00, 1.01it/s]\n"," all 100 288 0.846 0.616 0.639 0.327\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 77/99 14.8G 0.033 0.01089 0.005566 0.04946 8 640: 100% 22/22 [00:26<00:00, 1.21s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:03<00:00, 1.06it/s]\n"," all 100 288 0.807 0.66 0.633 0.314\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 78/99 14.8G 0.02847 0.01014 0.004611 0.04322 2 640: 100% 22/22 [00:23<00:00, 1.08s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.47it/s]\n"," all 100 288 0.803 0.659 0.631 0.322\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 79/99 14.8G 0.02719 0.01045 0.004324 0.04197 11 640: 100% 22/22 [00:23<00:00, 1.05s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:04<00:00, 1.22s/it]\n"," all 100 288 0.839 0.629 0.634 0.321\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 80/99 14.8G 0.02886 0.01071 0.005248 0.04482 7 640: 100% 22/22 [00:23<00:00, 1.06s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.62it/s]\n"," all 100 288 0.857 0.63 0.639 0.314\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 81/99 14.8G 0.0261 0.01059 0.003542 0.04023 11 640: 100% 22/22 [00:24<00:00, 1.10s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:03<00:00, 1.01it/s]\n"," all 100 288 0.848 0.644 0.634 0.316\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 82/99 14.8G 0.03742 0.01067 0.005535 0.05363 10 640: 100% 22/22 [00:23<00:00, 1.08s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.53it/s]\n"," all 100 288 0.845 0.639 0.635 0.323\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 83/99 14.8G 0.02991 0.01021 0.004426 0.04455 3 640: 100% 22/22 [00:25<00:00, 1.14s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:03<00:00, 1.20it/s]\n"," all 100 288 0.831 0.628 0.632 0.318\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 84/99 14.8G 0.02378 0.01066 0.002875 0.03732 12 640: 100% 22/22 [00:23<00:00, 1.06s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.52it/s]\n"," all 100 288 0.827 0.624 0.63 0.317\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 85/99 14.8G 0.03177 0.01046 0.004875 0.04711 6 640: 100% 22/22 [00:25<00:00, 1.15s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:03<00:00, 1.33it/s]\n"," all 100 288 0.836 0.631 0.647 0.329\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 86/99 14.8G 0.0245 0.01024 0.003688 0.03843 10 640: 100% 22/22 [00:24<00:00, 1.11s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:03<00:00, 1.06it/s]\n"," all 100 288 0.807 0.666 0.644 0.331\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 87/99 14.8G 0.03064 0.01092 0.005272 0.04684 13 640: 100% 22/22 [00:26<00:00, 1.18s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.39it/s]\n"," all 100 288 0.81 0.654 0.63 0.325\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 88/99 14.8G 0.02701 0.01033 0.003986 0.04133 7 640: 100% 22/22 [00:25<00:00, 1.15s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.60it/s]\n"," all 100 288 0.834 0.633 0.642 0.328\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 89/99 14.8G 0.02786 0.01021 0.004346 0.04242 3 640: 100% 22/22 [00:22<00:00, 1.04s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.39it/s]\n"," all 100 288 0.831 0.624 0.624 0.319\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 90/99 14.8G 0.031 0.01031 0.004724 0.04604 5 640: 100% 22/22 [00:24<00:00, 1.13s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.48it/s]\n"," all 100 288 0.848 0.644 0.64 0.325\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 91/99 14.8G 0.02931 0.01104 0.004801 0.04515 13 640: 100% 22/22 [00:23<00:00, 1.08s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:04<00:00, 1.06s/it]\n"," all 100 288 0.841 0.653 0.633 0.32\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 92/99 14.8G 0.02845 0.01081 0.005574 0.04484 8 640: 100% 22/22 [00:23<00:00, 1.08s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.47it/s]\n"," all 100 288 0.841 0.636 0.626 0.318\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 93/99 14.8G 0.02426 0.01077 0.003498 0.03853 7 640: 100% 22/22 [00:24<00:00, 1.11s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:04<00:00, 1.14s/it]\n"," all 100 288 0.82 0.668 0.643 0.325\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 94/99 14.8G 0.0277 0.01062 0.004119 0.04245 19 640: 100% 22/22 [00:23<00:00, 1.07s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.52it/s]\n"," all 100 288 0.833 0.673 0.649 0.325\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 95/99 14.8G 0.03311 0.01075 0.005632 0.04949 11 640: 100% 22/22 [00:25<00:00, 1.18s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:02<00:00, 1.44it/s]\n"," all 100 288 0.832 0.665 0.64 0.334\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 96/99 14.8G 0.02373 0.01063 0.003614 0.03798 6 640: 100% 22/22 [00:27<00:00, 1.26s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:03<00:00, 1.08it/s]\n"," all 100 288 0.82 0.678 0.647 0.335\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 97/99 14.8G 0.02934 0.01058 0.005722 0.04564 12 640: 100% 22/22 [00:24<00:00, 1.13s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:04<00:00, 1.25s/it]\n"," all 100 288 0.847 0.651 0.652 0.337\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 98/99 14.8G 0.03193 0.01042 0.005847 0.04819 12 640: 100% 22/22 [00:24<00:00, 1.10s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:03<00:00, 1.29it/s]\n"," all 100 288 0.843 0.644 0.65 0.332\n","\n"," Epoch gpu_mem box obj cls total labels img_size\n"," 99/99 14.8G 0.03232 0.01093 0.006601 0.04985 15 640: 100% 22/22 [00:24<00:00, 1.13s/it]\n"," Class Images Labels P R mAP@.5 mAP@.5:.95: 100% 4/4 [00:04<00:00, 1.14s/it]\n"," all 100 288 0.842 0.644 0.648 0.342\n"," green-lights 100 41 0.836 0.902 0.859 0.459\n"," red-lights 100 64 0.746 0.891 0.81 0.406\n"," traffic-lights 100 139 0.866 0.806 0.861 0.488\n"," turn-left 100 2 1 0 0 0\n"," yellow-lights 100 42 0.764 0.619 0.708 0.357\n","100 epochs completed in 0.889 hours.\n","\n","Optimizer stripped from runs/train/yolov7-fish3/weights/last.pt, 74.9MB\n","Optimizer stripped from runs/train/yolov7-fish3/weights/best.pt, 74.9MB\n"]}]},{"cell_type":"code","source":[],"metadata":{"id":"NQKA4hYUX-CE","executionInfo":{"status":"ok","timestamp":1718267228145,"user_tz":-480,"elapsed":4,"user":{"displayName":"黃致宇","userId":"05257376044901631491"}}},"execution_count":9,"outputs":[]},{"cell_type":"markdown","source":["## 8. 預測影像"],"metadata":{"id":"dAiCCP5SE5TR"}},{"cell_type":"code","source":["!python detect.py --weight /content/drive/MyDrive/data3/yolov7/runs/train/yolov7-fish/weights/best.pt --conf 0.04 --img-size 640 --source /content/drive/MyDrive/OIP.jpg --no-trace"],"metadata":{"id":"fRG73MdTE6zT","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1718267455532,"user_tz":-480,"elapsed":9250,"user":{"displayName":"黃致宇","userId":"05257376044901631491"}},"outputId":"41f69cb7-ee36-4806-f60b-6930c78b9406"},"execution_count":11,"outputs":[{"output_type":"stream","name":"stdout","text":["Namespace(weights=['/content/drive/MyDrive/data3/yolov7/runs/train/yolov7-fish/weights/best.pt'], source='/content/drive/MyDrive/OIP.jpg', img_size=640, conf_thres=0.04, iou_thres=0.45, device='', view_img=False, save_txt=False, save_conf=False, nosave=False, classes=None, agnostic_nms=False, augment=False, update=False, project='runs/detect', name='exp', exist_ok=False, no_trace=True)\n","YOLOR 🚀 v0.1-128-ga207844 torch 2.3.0+cu121 CUDA:0 (Tesla T4, 15102.0625MB)\n","\n","Fusing layers... \n","RepConv.fuse_repvgg_block\n","RepConv.fuse_repvgg_block\n","RepConv.fuse_repvgg_block\n","IDetect.fuse\n","Model Summary: 314 layers, 36508742 parameters, 6194944 gradients\n","/usr/local/lib/python3.10/dist-packages/torch/functional.py:512: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:3587.)\n"," return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined]\n","1 green-lights, 1 red-lights, 3 traffic-lightss, 1 yellow-lights, Done. (15.3ms) Inference, (567.1ms) NMS\n"," The image with the result is saved in: runs/detect/exp4/OIP.jpg\n","Done. (0.854s)\n"]}]}]}
app.py ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastai.vision.all import *
2
+ from io import BytesIO
3
+ import requests
4
+ import streamlit as st
5
+
6
+ import numpy as np
7
+ import torch
8
+ import time
9
+ import cv2
10
+ from numpy import random
11
+ from models.experimental import attempt_load
12
+ from utils.general import check_img_size, check_requirements, check_imshow, non_max_suppression, apply_classifier, \
13
+ scale_coords, xyxy2xywh, strip_optimizer, set_logging, increment_path
14
+ from utils.plots import plot_one_box
15
+
16
+ def letterbox(img, new_shape=(640, 640), color=(114, 114, 114), auto=True, scaleFill=False, scaleup=True, stride=32):
17
+ # Resize and pad image while meeting stride-multiple constraints
18
+ shape = img.shape[:2] # current shape [height, width]
19
+ if isinstance(new_shape, int):
20
+ new_shape = (new_shape, new_shape)
21
+
22
+ # Scale ratio (new / old)
23
+ r = min(new_shape[0] / shape[0], new_shape[1] / shape[1])
24
+ if not scaleup: # only scale down, do not scale up (for better test mAP)
25
+ r = min(r, 1.0)
26
+
27
+ # Compute padding
28
+ ratio = r, r # width, height ratios
29
+ new_unpad = int(round(shape[1] * r)), int(round(shape[0] * r))
30
+ dw, dh = new_shape[1] - new_unpad[0], new_shape[0] - new_unpad[1] # wh padding
31
+ if auto: # minimum rectangle
32
+ dw, dh = np.mod(dw, stride), np.mod(dh, stride) # wh padding
33
+ elif scaleFill: # stretch
34
+ dw, dh = 0.0, 0.0
35
+ new_unpad = (new_shape[1], new_shape[0])
36
+ ratio = new_shape[1] / shape[1], new_shape[0] / shape[0] # width, height ratios
37
+
38
+ dw /= 2 # divide padding into 2 sides
39
+ dh /= 2
40
+
41
+ if shape[::-1] != new_unpad: # resize
42
+ img = cv2.resize(img, new_unpad, interpolation=cv2.INTER_LINEAR)
43
+ top, bottom = int(round(dh - 0.1)), int(round(dh + 0.1))
44
+ left, right = int(round(dw - 0.1)), int(round(dw + 0.1))
45
+ img = cv2.copyMakeBorder(img, top, bottom, left, right, cv2.BORDER_CONSTANT, value=color) # add border
46
+ return img, ratio, (dw, dh)
47
+
48
+ def detect_modify(img0, model, conf=0.4, imgsz=640, conf_thres = 0.25, iou_thres=0.45):
49
+ st.image(img0, caption="Your image", use_column_width=True)
50
+
51
+ stride = int(model.stride.max()) # model stride
52
+ imgsz = check_img_size(imgsz, s=stride) # check img_size
53
+
54
+ # Padded resize
55
+ img0 = cv2.cvtColor(np.asarray(img0), cv2.COLOR_RGB2BGR)
56
+ img = letterbox(img0, imgsz, stride=stride)[0]
57
+ # Convert
58
+ img = img[:, :, ::-1].transpose(2, 0, 1) # BGR to RGB, to 3x416x416
59
+ img = np.ascontiguousarray(img)
60
+
61
+
62
+ # Get names and colors
63
+ names = model.module.names if hasattr(model, 'module') else model.names
64
+ colors = [[random.randint(0, 255) for _ in range(3)] for _ in names]
65
+
66
+ # Run inference
67
+ old_img_w = old_img_h = imgsz
68
+ old_img_b = 1
69
+
70
+ t0 = time.time()
71
+ img = torch.from_numpy(img).to(device)
72
+ # img /= 255.0 # 0 - 255 to 0.0 - 1.0
73
+ img = img/255.0
74
+ if img.ndimension() == 3:
75
+ img = img.unsqueeze(0)
76
+
77
+ # Inference
78
+ # t1 = time_synchronized()
79
+ with torch.no_grad(): # Calculating gradients would cause a GPU memory leak
80
+ pred = model(img)[0]
81
+ # t2 = time_synchronized()
82
+
83
+ # Apply NMS
84
+ pred = non_max_suppression(pred, conf_thres, iou_thres)
85
+ # t3 = time_synchronized()
86
+
87
+ # Process detections
88
+ # for i, det in enumerate(pred): # detections per image
89
+
90
+ gn = torch.tensor(img0.shape)[[1, 0, 1, 0]] # normalization gain whwh
91
+
92
+ det = pred[0]
93
+ if len(det):
94
+ # Rescale boxes from img_size to im0 size
95
+ det[:, :4] = scale_coords(img.shape[2:], det[:, :4], img0.shape).round()
96
+
97
+ # Print results
98
+ s = ''
99
+ for c in det[:, -1].unique():
100
+ n = (det[:, -1] == c).sum() # detections per class
101
+ s += f"{n} {names[int(c)]}{'s' * (n > 1)}, " # add to string
102
+
103
+ # Write results
104
+ for *xyxy, conf, cls in reversed(det):
105
+ label = f'{names[int(cls)]} {conf:.2f}'
106
+ plot_one_box(xyxy, img0, label=label, color=colors[int(cls)], line_thickness=1)
107
+
108
+ f"""
109
+ ### Prediction result:
110
+ """
111
+ img0 = cv2.cvtColor(np.asarray(img0), cv2.COLOR_BGR2RGB)
112
+ st.image(img0, caption="Prediction Result", use_column_width=True)
113
+
114
+ #set paramters
115
+ weight_path = './yolov7.pt'
116
+ imgsz = 640
117
+ conf = 0.4
118
+ conf_thres = 0.25
119
+ iou_thres=0.45
120
+ device = torch.device("cpu")
121
+ path = "./"
122
+
123
+ # Load model
124
+ model = attempt_load(weight_path, map_location=torch.device('cpu')) # load FP32 model
125
+
126
+ """
127
+ # YOLOv7
128
+ This is a object detection model for [Objects].
129
+ """
130
+ option = st.radio("", ["Upload Image", "Image URL"])
131
+
132
+ if option == "Upload Image":
133
+ uploaded_file = st.file_uploader("Please upload an image.")
134
+
135
+ if uploaded_file is not None:
136
+ img = PILImage.create(uploaded_file)
137
+ detect_modify(img, model, conf=conf, imgsz=imgsz, conf_thres=conf_thres, iou_thres=iou_thres)
138
+ else:
139
+ url = st.text_input("Please input a url.")
140
+ if url != "":
141
+ try:
142
+ response = requests.get(url)
143
+ pil_img = PILImage.create(BytesIO(response.content))
144
+ detect_modify(pil_img, model, conf=conf, imgsz=imgsz, conf_thres=conf_thres, iou_thres=iou_thres)
145
+ except:
146
+ st.text("Problem reading image from", url)
best.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:510a427645eb8de1901c0b7dc6ace586351edfc56bf01a88517f007cabf0966b
3
+ size 74861754
last.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1716d47b53a738efb415e42afd04a2459851824391586e9816010b9ed6a3c240
3
+ size 74861754
requirements.txt ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Usage: pip install -r requirements.txt
2
+ fastbook
3
+ altair<5
4
+
5
+ # Base ----------------------------------------
6
+ matplotlib>=3.2.2
7
+ numpy>=1.18.5,<1.24.0
8
+ opencv-python>=4.1.1
9
+ Pillow>=7.1.2
10
+ PyYAML>=5.3.1
11
+ requests>=2.23.0
12
+ scipy>=1.4.1
13
+ torch>=1.7.0,!=1.12.0
14
+ torchvision>=0.8.1,!=0.13.0
15
+ tqdm>=4.41.0
16
+ protobuf<4.21.3
17
+
18
+ # Logging -------------------------------------
19
+ tensorboard>=2.4.1
20
+ # wandb
21
+
22
+ # Plotting ------------------------------------
23
+ pandas>=1.1.4
24
+ seaborn>=0.11.0
25
+
26
+ # Export --------------------------------------
27
+ # coremltools>=4.1 # CoreML export
28
+ # onnx>=1.9.0 # ONNX export
29
+ # onnx-simplifier>=0.3.6 # ONNX simplifier
30
+ # scikit-learn==0.19.2 # CoreML quantization
31
+ # tensorflow>=2.4.1 # TFLite export
32
+ # tensorflowjs>=3.9.0 # TF.js export
33
+ # openvino-dev # OpenVINO export
34
+
35
+ # Extras --------------------------------------
36
+ ipython # interactive notebook
37
+ psutil # system utilization
38
+ thop # FLOPs computation
39
+ # albumentations>=1.0.3
40
+ # pycocotools>=2.0 # COCO mAP
41
+ # roboflow