Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
c6fc4242a2
1 file changed
+261
-203
+261
-203
@@ -6,7 +6,6 @@
|
||||
"name": "YOLOv5 Tutorial",
|
||||
"provenance": [],
|
||||
"collapsed_sections": [],
|
||||
"toc_visible": true,
|
||||
"include_colab_link": true
|
||||
},
|
||||
"kernelspec": {
|
||||
@@ -35,7 +34,7 @@
|
||||
"source": [
|
||||
"<img src=\"https://user-images.githubusercontent.com/26833433/82952157-51b7db00-9f5d-11ea-8f4b-dda1ffecf992.jpg\">\n",
|
||||
"\n",
|
||||
"This notebook contains software developed by Ultralytics LLC, and **is freely available for redistribution under the GPL-3.0 license**. For more information please visit https://github.com/ultralytics/yolov5 and https://www.ultralytics.com."
|
||||
"This notebook was developed by Ultralytics LLC, and **is freely available for redistribution under the GPL-3.0 license**. For more information please visit https://github.com/ultralytics/yolov5 and https://www.ultralytics.com."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -47,7 +46,7 @@
|
||||
"source": [
|
||||
"#Initial Setup\n",
|
||||
"\n",
|
||||
"Clone repo, install dependencies and RESTART RUNTIME."
|
||||
"Clone repo, install dependencies, `%cd` into `./yolov5` folder and check GPU."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -59,87 +58,15 @@
|
||||
},
|
||||
"source": [
|
||||
"!git clone https://github.com/ultralytics/yolov5 # clone repo\n",
|
||||
"!pip install -U -r yolov5/requirements.txt # install dependencies and RESTART RUNTIME"
|
||||
],
|
||||
"execution_count": 0,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "3t8VD3WebfnI",
|
||||
"colab_type": "text"
|
||||
},
|
||||
"source": [
|
||||
"After restarting runtime, `%cd` back into `./yolov5` folder, import `torch` and check CUDA device."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"metadata": {
|
||||
"id": "s5TuwHPkKGY1",
|
||||
"colab_type": "code",
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/",
|
||||
"height": 33
|
||||
},
|
||||
"outputId": "e2648183-73d0-49e2-8361-7c8d65a1cfe8"
|
||||
},
|
||||
"source": [
|
||||
"%cd yolov5"
|
||||
],
|
||||
"execution_count": 64,
|
||||
"outputs": [
|
||||
{
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"/content/yolov5\n"
|
||||
],
|
||||
"name": "stdout"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"metadata": {
|
||||
"id": "Ij5L0B5FXA6g",
|
||||
"colab_type": "code",
|
||||
"outputId": "6ab14e8e-392b-48ed-c77d-167f5a9d4a13",
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/",
|
||||
"height": 53
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"import torch\n",
|
||||
"from IPython.display import Image # for displaying images\n",
|
||||
"from utils.google_utils import gdrive_download # for downloading models/datasets\n",
|
||||
"!pip install -r yolov5/requirements.txt # install dependencies\n",
|
||||
"%cd yolov5\n",
|
||||
"\n",
|
||||
"print('torch %s %s' % (torch.__version__, torch.cuda.get_device_properties(0) if torch.cuda.is_available() else 'CPU'))"
|
||||
],
|
||||
"execution_count": 66,
|
||||
"outputs": [
|
||||
{
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"torch 1.5.0+cu101 _CudaDeviceProperties(name='Tesla P100-PCIE-16GB', major=6, minor=0, total_memory=16280MB, multi_processor_count=56)\n"
|
||||
],
|
||||
"name": "stdout"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"metadata": {
|
||||
"id": "gI6NoBev8Ib1",
|
||||
"colab_type": "code",
|
||||
"colab": {}
|
||||
},
|
||||
"source": [
|
||||
"# Re-clone (only if necessary, not normally used)\n",
|
||||
"%cd ..\n",
|
||||
"!rm -rf yolov5 && git clone https://github.com/ultralytics/yolov5\n",
|
||||
"%cd yolov5"
|
||||
"import torch\n",
|
||||
"from IPython.display import Image, clear_output # to display images\n",
|
||||
"from utils.google_utils import gdrive_download # to download models/datasets\n",
|
||||
"\n",
|
||||
"clear_output()\n",
|
||||
"print('Setup complete. Using torch %s %s' % (torch.__version__, torch.cuda.get_device_properties(0) if torch.cuda.is_available() else 'CPU'))"
|
||||
],
|
||||
"execution_count": 0,
|
||||
"outputs": []
|
||||
@@ -153,7 +80,7 @@
|
||||
"source": [
|
||||
"#1. Inference\n",
|
||||
"\n",
|
||||
"Run inference with a pretrained checkpoint on contents of `inference/images` folder. Models are downloaded automatically from our Google Drive [folder](https://drive.google.com/open?id=1Drs_Aiu7xx6S-ix95f9kNsA6ueKRpN2J) if available."
|
||||
"Run inference with a pretrained checkpoint on contents of `/inference/images` folder. Models are downloaded automatically from our Google Drive [folder](https://drive.google.com/open?id=1Drs_Aiu7xx6S-ix95f9kNsA6ueKRpN2J) if available."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -161,36 +88,35 @@
|
||||
"metadata": {
|
||||
"id": "zR9ZbuQCH7FX",
|
||||
"colab_type": "code",
|
||||
"outputId": "9ae9f2bb-6cf6-4573-c755-1f5d194230c2",
|
||||
"outputId": "528fcc04-2393-437a-84d2-092becbaefbe",
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/",
|
||||
"height": 488
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"# Run inference\n",
|
||||
"!python detect.py --weights yolov5s.pt --img 640 --conf 0.4 --source ./inference/images/\n",
|
||||
"!python detect.py --weights yolov5s.pt --img 416 --conf 0.4 --source ./inference/images/\n",
|
||||
"Image(filename='inference/output/zidane.jpg', width=600)"
|
||||
],
|
||||
"execution_count": 0,
|
||||
"execution_count": 14,
|
||||
"outputs": [
|
||||
{
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Namespace(agnostic_nms=False, augment=False, classes=None, conf_thres=0.4, device='', fourcc='mp4v', half=False, img_size=640, iou_thres=0.5, output='inference/output', save_txt=False, source='./inference/images/', view_img=False, weights='yolov5s.pt')\n",
|
||||
"Namespace(agnostic_nms=False, augment=False, classes=None, conf_thres=0.4, device='', fourcc='mp4v', half=False, img_size=416, iou_thres=0.5, output='inference/output', save_txt=False, source='./inference/images/', view_img=False, weights='yolov5s.pt')\n",
|
||||
"Using CUDA device0 _CudaDeviceProperties(name='Tesla P100-PCIE-16GB', total_memory=16280MB)\n",
|
||||
"\n",
|
||||
"image 1/2 inference/images/bus.jpg: 640x512 3 persons, 1 buss, Done. (0.009s)\n",
|
||||
"image 2/2 inference/images/zidane.jpg: 384x640 2 persons, 2 ties, Done. (0.009s)\n",
|
||||
"image 1/2 inference/images/bus.jpg: 416x352 3 persons, 1 buss, Done. (0.009s)\n",
|
||||
"image 2/2 inference/images/zidane.jpg: 288x416 2 persons, 2 ties, Done. (0.009s)\n",
|
||||
"Results saved to /content/yolov5/inference/output\n",
|
||||
"Done. (0.118s)\n"
|
||||
"Done. (0.100s)\n"
|
||||
],
|
||||
"name": "stdout"
|
||||
},
|
||||
{
|
||||
"output_type": "execute_result",
|
||||
"data": {
|
||||
"image/jpeg": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAIBAQEBAQIBAQECAgICAgQDAgICAgUEBAMEBgUGBgYFBgYGBwkIBgcJBwYGCAsICQoKCgoKBggLDAsKDAkKCgr/2wBDAQICAgICAgUDAwUKBwYHCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgr/wAARCALQBQADASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1N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xk/vN8taxl9kr4vhM9YUt2SFJtq/8AXX5vlqb7PNdTPNM6r5iLsVf4f9qnzW8KM72yKpX+KrDWf7vYJtoXb95vmrS8fi5iPe5iCGSZrdYfObYvy7v7zLUNxcFVaNHaM/Mu3/ZqzInkxhGm+79xf7tZN1I7L9/HzfPu/irejTlUkYyqcseWRDM0Plu8kzfc+6v8VZ0cszN87qPm+fy/m2rVm6Z7iTyfl2xpt8yNdu6qk0nlqXh2hG+4y161GmeZWqSjL3SNpEZfJjhXb/D/ALVIq/ut83zf3fmpkbIrDftC7P4fvbqVVTCPHBtH8MbN/FXV7P7RjGt7xGq3O48Z2/N8vy7qfIszRq6Pj+9u+9VhbXbJs3/MqfP8u75qVbVMt5j/ADfe2rTfvfEbxqe5ykSXj/Y3DzSBv4Kt2zIsa70y+/dtb/0KmW8aW6tcvM21fl3bPutWlHYO1vvmhYf3JF/irel8ISrT5CssYM/7l2Rm/vfLUNxpsysNm4fLtfd92tVdI+UvezbXZP71egfs8/sq/GD9qfxfd+Cfgh4Ti1jULHT/ALddw3GoQ2yxwK6IWLSsoPzOowMnnOMAmujEY3C4DDSxGJqKEIq7lJpJLzb0Rwzqq9keQSaS+1jvZn3fL833ayL6xeS6mTYw2/Ltr7Wm/wCCL37e7lSvwfsCR1J8U2GP/R1Ub7/gih/wUEO37N8I7Bvlw3/FU2A/9rV4seO+Cf8AoZUP/BsP/kjiqUpy+y/uPhvVNJdbXe7NvX5kZa5rVNNLf7f3lr71vP8Agh9/wUPnBRPg7YYYZb/irNP6Line truncated
|
||||
"text/plain": [
|
||||
"<IPython.core.display.Image object>"
|
||||
]
|
||||
@@ -201,10 +127,39 @@
|
||||
"width": 600
|
||||
}
|
||||
},
|
||||
"execution_count": 4
|
||||
"execution_count": 14
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "4JnkELT0cIJg",
|
||||
"colab_type": "text"
|
||||
},
|
||||
"source": [
|
||||
"Inference can be run on a variety of sources: images, videos, directories, webcams, rtsp and http streams as shown in the example below."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"metadata": {
|
||||
"id": "WwosXmgDahte",
|
||||
"colab_type": "code",
|
||||
"colab": {}
|
||||
},
|
||||
"source": [
|
||||
"# Example syntax (do not run cell)\n",
|
||||
"!python detect.py --source ./file.jpg # image \n",
|
||||
" ./file.mp4 # video\n",
|
||||
" ./dir # directory\n",
|
||||
" 0 # webcam\n",
|
||||
" 'rtsp://170.93.143.139/rtplive/470011e600ef003a004ee33696235daa' # rtsp\n",
|
||||
" 'http://112.50.243.8/PLTV/88888888/224/3221225900/1.m3u8' # http"
|
||||
],
|
||||
"execution_count": 0,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
@@ -232,23 +187,23 @@
|
||||
"metadata": {
|
||||
"id": "WQPtK1QYVaD_",
|
||||
"colab_type": "code",
|
||||
"outputId": "6948ef69-40d6-434e-c5ba-cc67605a04cb",
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/",
|
||||
"height": 33
|
||||
}
|
||||
},
|
||||
"outputId": "e49d6899-0feb-4bc7-e384-513c7d384060"
|
||||
},
|
||||
"source": [
|
||||
"# Download COCO val2017\n",
|
||||
"gdrive_download('1Y6Kou6kEB0ZEMCCpJSKStCor4KAReE43','coco2017val.zip') # val2017 dataset\n",
|
||||
"!mv ./coco ../ # move folder alongside /yolov5"
|
||||
],
|
||||
"execution_count": 0,
|
||||
"execution_count": 7,
|
||||
"outputs": [
|
||||
{
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Downloading https://drive.google.com/uc?export=download&id=1Y6Kou6kEB0ZEMCCpJSKStCor4KAReE43 as coco2017val.zip... unzipping... Done (25.8s)\n"
|
||||
"Downloading https://drive.google.com/uc?export=download&id=1Y6Kou6kEB0ZEMCCpJSKStCor4KAReE43 as coco2017val.zip... unzipping... Done (37.1s)\n"
|
||||
],
|
||||
"name": "stdout"
|
||||
}
|
||||
@@ -257,59 +212,59 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"metadata": {
|
||||
"id": "LLb8HhnP1awM",
|
||||
"id": "WBWS_QSc__se",
|
||||
"colab_type": "code",
|
||||
"outputId": "279038a2-18af-46a9-ad12-9c3aeaf2fc33",
|
||||
"outputId": "02b54431-b993-4acd-c8a3-9c3231662718",
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/",
|
||||
"height": 622
|
||||
"height": 602
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"# Run yolov5s on COCO val2017\n",
|
||||
"!python test.py --weights yolov5s.pt --data ./data/coco.yaml"
|
||||
"# Run YOLOv5s on COCO val2017\n",
|
||||
"!python test.py --weights yolov5s.pt --data ./data/coco.yaml --img 640"
|
||||
],
|
||||
"execution_count": 56,
|
||||
"execution_count": 8,
|
||||
"outputs": [
|
||||
{
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Namespace(augment=False, batch_size=16, conf_thres=0.001, data='././data/coco.yaml', device='', img_size=640, iou_thres=0.65, save_json=True, single_cls=False, task='val', verbose=False, weights='yolov5s.pt')\n",
|
||||
"Using CUDA device0 _CudaDeviceProperties(name='Tesla P100-PCIE-16GB', total_memory=16280MB)\n",
|
||||
"Namespace(augment=False, batch_size=32, conf_thres=0.001, data='././data/coco.yaml', device='', img_size=640, iou_thres=0.65, save_json=True, single_cls=False, task='val', verbose=False, weights='yolov5s.pt')\n",
|
||||
"Using CUDA device0 _CudaDeviceProperties(name='Tesla T4', total_memory=15079MB)\n",
|
||||
"\n",
|
||||
"Downloading https://drive.google.com/uc?export=download&id=1R5T6rIyy3lLwgFXNms8whc-387H0tMQO as yolov5s.pt... Done (1.9s)\n",
|
||||
"Model Summary: 99 layers, 6.99302e+06 parameters, 6.99302e+06 gradients\n",
|
||||
"Caching labels ../coco/labels/val2017.npy (4952 found, 0 missing, 48 empty, 0 duplicate, for 5000 images): 100% 5000/5000 [00:00<00:00, 23176.56it/s]\n",
|
||||
" Class Images Targets P R mAP@.5 mAP@.5:.95: 100% 313/313 [01:41<00:00, 3.07it/s]\n",
|
||||
" all 5e+03 3.63e+04 0.317 0.621 0.52 0.314\n",
|
||||
"Speed: 3.1/2.8/5.8 ms inference/NMS/total per 640x640 image at batch-size 16\n",
|
||||
"Model Summary: 165 layers, 7.07417e+06 parameters, 7.07417e+06 gradients\n",
|
||||
"Caching labels ../coco/val2017.txt (4952 found, 48 missing, 0 empty, 0 duplicate, for 5000 images): 100% 5000/5000 [00:00<00:00, 7822.09it/s]\n",
|
||||
"Saving labels to ../coco/labels/val2017.npy for faster future loading\n",
|
||||
" Class Images Targets P R mAP@.5 mAP@.5:.95: 100% 157/157 [01:33<00:00, 1.67it/s]\n",
|
||||
" all 5e+03 3.63e+04 0.334 0.633 0.534 0.336\n",
|
||||
"Speed: 6.0/2.9/8.9 ms inference/NMS/total per 640x640 image at batch-size 32\n",
|
||||
"\n",
|
||||
"COCO mAP with pycocotools... saving detections_val2017_yolov5s_results.json...\n",
|
||||
"loading annotations into memory...\n",
|
||||
"Done (t=0.40s)\n",
|
||||
"Done (t=0.41s)\n",
|
||||
"creating index...\n",
|
||||
"index created!\n",
|
||||
"Loading and preparing results...\n",
|
||||
"DONE (t=13.01s)\n",
|
||||
"DONE (t=5.70s)\n",
|
||||
"creating index...\n",
|
||||
"index created!\n",
|
||||
"Running per image evaluation...\n",
|
||||
"Evaluate annotation type *bbox*\n",
|
||||
"DONE (t=130.84s).\n",
|
||||
"DONE (t=89.04s).\n",
|
||||
"Accumulating evaluation results...\n",
|
||||
"DONE (t=24.98s).\n",
|
||||
" Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.330\n",
|
||||
" Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.528\n",
|
||||
" Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.350\n",
|
||||
" Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.185\n",
|
||||
" Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.374\n",
|
||||
" Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.422\n",
|
||||
" Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.282\n",
|
||||
" Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.482\n",
|
||||
" Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.558\n",
|
||||
" Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.397\n",
|
||||
"DONE (t=14.04s).\n",
|
||||
" Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.352\n",
|
||||
" Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.544\n",
|
||||
" Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.378\n",
|
||||
" Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.188\n",
|
||||
" Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.397\n",
|
||||
" Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.459\n",
|
||||
" Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.296\n",
|
||||
" Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.496\n",
|
||||
" Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.557\n",
|
||||
" Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.358\n",
|
||||
" Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.618\n",
|
||||
" Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.691\n"
|
||||
" Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.700\n"
|
||||
],
|
||||
"name": "stdout"
|
||||
}
|
||||
@@ -318,20 +273,62 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"metadata": {
|
||||
"id": "kcJEsCk3PgQy",
|
||||
"id": "X58w8JLpMnjH",
|
||||
"colab_type": "code",
|
||||
"colab": {}
|
||||
"outputId": "1cc32887-1fe3-4079-f66e-b6b756f96527",
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/",
|
||||
"height": 586
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"# Run multiple models on COCO val2017\n",
|
||||
"%%shell\n",
|
||||
"for x in yolov5s yolov5m yolov5l yolov5x yolov3-spp\n",
|
||||
"do \n",
|
||||
" python test.py --weights $x.pt --data ./data/coco.yaml\n",
|
||||
"done"
|
||||
"# Run YOLOv5x on COCO val2017\n",
|
||||
"!python test.py --weights yolov5x.pt --data ./data/coco.yaml --img 640"
|
||||
],
|
||||
"execution_count": 0,
|
||||
"outputs": []
|
||||
"execution_count": 10,
|
||||
"outputs": [
|
||||
{
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Namespace(augment=False, batch_size=32, conf_thres=0.001, data='././data/coco.yaml', device='', img_size=640, iou_thres=0.65, save_json=True, single_cls=False, task='val', verbose=False, weights='yolov5x.pt')\n",
|
||||
"Using CUDA device0 _CudaDeviceProperties(name='Tesla T4', total_memory=15079MB)\n",
|
||||
"\n",
|
||||
"Model Summary: 381 layers, 9.59219e+07 parameters, 9.59219e+07 gradients\n",
|
||||
"Caching labels ../coco/labels/val2017.npy (4952 found, 0 missing, 48 empty, 0 duplicate, for 5000 images): 100% 5000/5000 [00:00<00:00, 16516.13it/s]\n",
|
||||
" Class Images Targets P R mAP@.5 mAP@.5:.95: 100% 157/157 [05:05<00:00, 1.95s/it]\n",
|
||||
" all 5e+03 3.63e+04 0.393 0.742 0.652 0.455\n",
|
||||
"Speed: 51.1/2.2/53.3 ms inference/NMS/total per 640x640 image at batch-size 32\n",
|
||||
"\n",
|
||||
"COCO mAP with pycocotools... saving detections_val2017_yolov5x_results.json...\n",
|
||||
"loading annotations into memory...\n",
|
||||
"Done (t=0.39s)\n",
|
||||
"creating index...\n",
|
||||
"index created!\n",
|
||||
"Loading and preparing results...\n",
|
||||
"DONE (t=3.59s)\n",
|
||||
"creating index...\n",
|
||||
"index created!\n",
|
||||
"Running per image evaluation...\n",
|
||||
"Evaluate annotation type *bbox*\n",
|
||||
"DONE (t=79.47s).\n",
|
||||
"Accumulating evaluation results...\n",
|
||||
"DONE (t=12.20s).\n",
|
||||
" Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.470\n",
|
||||
" Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.659\n",
|
||||
" Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.515\n",
|
||||
" Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.310\n",
|
||||
" Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.516\n",
|
||||
" Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.610\n",
|
||||
" Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.362\n",
|
||||
" Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.597\n",
|
||||
" Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.656\n",
|
||||
" Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.504\n",
|
||||
" Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.704\n",
|
||||
" Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.787\n"
|
||||
],
|
||||
"name": "stdout"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
@@ -349,11 +346,7 @@
|
||||
"metadata": {
|
||||
"id": "V0AJnSeCIHyJ",
|
||||
"colab_type": "code",
|
||||
"outputId": "de02afec-83ce-4be1-d007-65f773947ada",
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/",
|
||||
"height": 82
|
||||
}
|
||||
"colab": {}
|
||||
},
|
||||
"source": [
|
||||
"# Download COCO test-dev2017\n",
|
||||
@@ -362,18 +355,7 @@
|
||||
"!mv ./test2017 ./coco/images && mv ./coco ../ # move images into /coco and move /coco alongside /yolov5"
|
||||
],
|
||||
"execution_count": 0,
|
||||
"outputs": [
|
||||
{
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Downloading https://drive.google.com/uc?export=download&id=1cXZR_ckHki6nddOmcysCuuJFM--T-Q6L as coco2017labels.zip... unzipping... Done (9.3s)\n",
|
||||
" % Total % Received % Xferd Average Speed Time Time Time Current\n",
|
||||
" Dload Upload Total Spent Left Speed\n",
|
||||
"100 6339M 100 6339M 0 0 16.2M 0 0:06:30 0:06:30 --:--:-- 16.3M\n"
|
||||
],
|
||||
"name": "stdout"
|
||||
}
|
||||
]
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
@@ -383,7 +365,7 @@
|
||||
"colab": {}
|
||||
},
|
||||
"source": [
|
||||
"# Run yolov5s on COCO test-dev2017\n",
|
||||
"# Run YOLOv5s on COCO test-dev2017 with argument --task test\n",
|
||||
"!python test.py --weights yolov5s.pt --data ./data/coco.yaml --task test"
|
||||
],
|
||||
"execution_count": 0,
|
||||
@@ -406,10 +388,10 @@
|
||||
"metadata": {
|
||||
"id": "Knxi2ncxWffW",
|
||||
"colab_type": "code",
|
||||
"outputId": "b842bd43-67e3-4e0e-951a-7d80f3a6aa49",
|
||||
"outputId": "cbb574a9-861d-4f47-ca0c-32166bd3361e",
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/",
|
||||
"height": 53
|
||||
"height": 33
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
@@ -417,12 +399,12 @@
|
||||
"gdrive_download('1n_oKgR81BJtqk75b00eAjdv03qVCQn2f','coco128.zip') # tutorial dataset\n",
|
||||
"!mv ./coco128 ../ # move folder alongside /yolov5"
|
||||
],
|
||||
"execution_count": 57,
|
||||
"execution_count": 2,
|
||||
"outputs": [
|
||||
{
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Downloading https://drive.google.com/uc?export=download&id=1n_oKgR81BJtqk75b00eAjdv03qVCQn2f as coco128.zip... unzipping... Done (4.8s)\n"
|
||||
"Downloading https://drive.google.com/uc?export=download&id=1n_oKgR81BJtqk75b00eAjdv03qVCQn2f as coco128.zip... unzipping... Done (5.8s)\n"
|
||||
],
|
||||
"name": "stdout"
|
||||
}
|
||||
@@ -450,9 +432,7 @@
|
||||
"colab_type": "text"
|
||||
},
|
||||
"source": [
|
||||
"Train a yolov5s model on the coco128 dataset by specifying model configuration file `--cfg ./models/yolo5s.yaml`, and a dataset configuration file `--data ./data/coco128.yaml`. Start training from pretrained `--weights yolov5s.pt`, or from scratch (randomly initialized weights) using `--weights ''`\n",
|
||||
"\n",
|
||||
"Models are downloaded automatically from our Google Drive [folder](https://drive.google.com/open?id=1Drs_Aiu7xx6S-ix95f9kNsA6ueKRpN2J) if available.\n"
|
||||
"Train a YOLOv5s model on the coco128 dataset by specifying model configuration file `--cfg ./models/yolo5s.yaml`, and a dataset configuration file `--data ./data/coco128.yaml`. Start training from pretrained `--weights yolov5s.pt`, or from scratch (randomly initialized weights) using `--weights ''`. Pretrained checkpoints are downloaded automatically from our Google Drive [folder](https://drive.google.com/open?id=1Drs_Aiu7xx6S-ix95f9kNsA6ueKRpN2J) if available.\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -460,27 +440,27 @@
|
||||
"metadata": {
|
||||
"id": "1NcFxRcFdJ_O",
|
||||
"colab_type": "code",
|
||||
"outputId": "0a1d64d9-b3a6-4055-8487-9741c89c1140",
|
||||
"outputId": "836944be-b677-4614-889b-da120cda0304",
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/",
|
||||
"height": 1000
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"# Train yolov5s on coco128 for 5 epochs\n",
|
||||
"!python train.py --img 640 --batch 16 --epochs 5 --data ./data/coco128.yaml --cfg ./models/yolov5s.yaml --weights '' --name yolov5s_coco128 --nosave --cache"
|
||||
"# Train YOLOv5s on coco128 for 5 epochs\n",
|
||||
"!python train.py --img 640 --batch 16 --epochs 5 --data ./data/coco128.yaml --cfg ./models/yolov5s.yaml --weights yolov5s.pt --name tutorial --nosave --cache"
|
||||
],
|
||||
"execution_count": 62,
|
||||
"execution_count": 5,
|
||||
"outputs": [
|
||||
{
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Apex recommended for faster mixed precision training: https://github.com/NVIDIA/apex\n",
|
||||
"{'lr0': 0.01, 'momentum': 0.937, 'weight_decay': 0.0005, 'giou': 0.05, 'cls': 0.58, 'cls_pw': 1.0, 'obj': 1.0, 'obj_pw': 1.0, 'iou_t': 0.2, 'anchor_t': 4.0, 'fl_gamma': 0.0, 'hsv_h': 0.014, 'hsv_s': 0.68, 'hsv_v': 0.36, 'degrees': 0.0, 'translate': 0.0, 'scale': 0.5, 'shear': 0.0}\n",
|
||||
"Namespace(adam=False, batch_size=16, bucket='', cache_images=True, cfg='././models/yolov5s.yaml', data='././data/coco128.yaml', device='', epochs=5, evolve=False, img_size=[640], name='yolov5s_coco128', nosave=True, notest=False, rect=False, resume=False, single_cls=False, weights='')\n",
|
||||
"Using CUDA device0 _CudaDeviceProperties(name='Tesla P100-PCIE-16GB', total_memory=16280MB)\n",
|
||||
"Namespace(adam=False, batch_size=16, bucket='', cache_images=True, cfg='././models/yolov5s.yaml', data='././data/coco128.yaml', device='', epochs=5, evolve=False, img_size=[640], multi_scale=False, name='tutorial', nosave=True, notest=False, rect=False, resume=False, single_cls=False, weights='yolov5s.pt')\n",
|
||||
"Using CUDA device0 _CudaDeviceProperties(name='Tesla T4', total_memory=15079MB)\n",
|
||||
"\n",
|
||||
"2020-05-30 00:01:16.653829: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudart.so.10.1\n",
|
||||
"2020-06-14 19:45:19.668043: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudart.so.10.1\n",
|
||||
"Start Tensorboard with \"tensorboard --logdir=runs\", view at http://localhost:6006/\n",
|
||||
"\n",
|
||||
" from n params module arguments \n",
|
||||
@@ -488,62 +468,65 @@
|
||||
" 1 -1 1 18560 models.common.Conv [32, 64, 3, 2] \n",
|
||||
" 2 -1 1 20672 models.common.Bottleneck [64, 64] \n",
|
||||
" 3 -1 1 73984 models.common.Conv [64, 128, 3, 2] \n",
|
||||
" 4 -1 3 246912 models.common.Bottleneck [128, 128] \n",
|
||||
" 4 -1 1 161152 models.common.BottleneckCSP [128, 128, 3] \n",
|
||||
" 5 -1 1 295424 models.common.Conv [128, 256, 3, 2] \n",
|
||||
" 6 -1 3 985344 models.common.Bottleneck [256, 256] \n",
|
||||
" 6 -1 1 641792 models.common.BottleneckCSP [256, 256, 3] \n",
|
||||
" 7 -1 1 1180672 models.common.Conv [256, 512, 3, 2] \n",
|
||||
" 8 -1 1 656896 models.common.SPP [512, 512, [5, 9, 13]] \n",
|
||||
" 9 -1 1 1312256 models.common.Bottleneck [512, 512] \n",
|
||||
" 10 -1 1 1312256 models.common.Bottleneck [512, 512, False] \n",
|
||||
" 11 -1 1 130815 torch.nn.modules.conv.Conv2d [512, 255, 1, 1, 0] \n",
|
||||
" 9 -1 1 1905152 models.common.BottleneckCSP [512, 512, 2] \n",
|
||||
" 10 -1 1 1248768 models.common.BottleneckCSP [512, 512, 1, False] \n",
|
||||
" 11 -1 1 130815 torch.nn.modules.conv.Conv2d [512, 255, 1, 1] \n",
|
||||
" 12 -2 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest'] \n",
|
||||
" 13 [-1, 6] 1 0 models.common.Concat [1] \n",
|
||||
" 14 -1 1 197120 models.common.Conv [768, 256, 1, 1] \n",
|
||||
" 15 -1 1 328448 models.common.Bottleneck [256, 256, False] \n",
|
||||
" 16 -1 1 65535 torch.nn.modules.conv.Conv2d [256, 255, 1, 1, 0] \n",
|
||||
" 15 -1 1 313088 models.common.BottleneckCSP [256, 256, 1, False] \n",
|
||||
" 16 -1 1 65535 torch.nn.modules.conv.Conv2d [256, 255, 1, 1] \n",
|
||||
" 17 -2 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest'] \n",
|
||||
" 18 [-1, 4] 1 0 models.common.Concat [1] \n",
|
||||
" 19 -1 1 49408 models.common.Conv [384, 128, 1, 1] \n",
|
||||
" 20 -1 1 82304 models.common.Bottleneck [128, 128, False] \n",
|
||||
" 21 -1 1 32895 torch.nn.modules.conv.Conv2d [128, 255, 1, 1, 0] \n",
|
||||
" 20 -1 1 78720 models.common.BottleneckCSP [128, 128, 1, False] \n",
|
||||
" 21 -1 1 32895 torch.nn.modules.conv.Conv2d [128, 255, 1, 1] \n",
|
||||
" 22 [-1, 16, 11] 1 0 models.yolo.Detect [80, [[10, 13, 16, 30, 33, 23], [30, 61, 62, 45, 59, 119], [116, 90, 156, 198, 373, 326]]]\n",
|
||||
"Model Summary: 99 layers, 6.99302e+06 parameters, 6.99302e+06 gradients\n",
|
||||
"Model Summary: 165 layers, 7.07417e+06 parameters, 7.07417e+06 gradients\n",
|
||||
"\n",
|
||||
"Optimizer groups: 34 .bias, 34 conv.weight, 31 other\n",
|
||||
"Caching labels ../coco128/labels/train2017 (126 found, 0 missing, 2 empty, 0 duplicate, for 128 images): 100% 128/128 [00:00<00:00, 6595.06it/s]\n",
|
||||
"Caching images (0.1GB): 100% 128/128 [00:00<00:00, 154.24it/s]\n",
|
||||
"Caching labels ../coco128/labels/train2017 (126 found, 0 missing, 2 empty, 0 duplicate, for 128 images): 100% 128/128 [00:00<00:00, 9849.04it/s]\n",
|
||||
"Caching images (0.1GB): 100% 128/128 [00:00<00:00, 151.99it/s]\n",
|
||||
"Optimizer groups: 54 .bias, 60 conv.weight, 51 other\n",
|
||||
"Reading image shapes: 100% 128/128 [00:00<00:00, 8158.02it/s]\n",
|
||||
"Caching labels ../coco128/labels/train2017 (126 found, 0 missing, 2 empty, 0 duplicate, for 128 images): 100% 128/128 [00:00<00:00, 7608.18it/s]\n",
|
||||
"Caching images (0.1GB): 100% 128/128 [00:00<00:00, 149.70it/s]\n",
|
||||
"Caching labels ../coco128/labels/train2017 (126 found, 0 missing, 2 empty, 0 duplicate, for 128 images): 100% 128/128 [00:00<00:00, 8165.09it/s]\n",
|
||||
"Caching images (0.1GB): 100% 128/128 [00:00<00:00, 145.34it/s]\n",
|
||||
"Label width-height: n mean min max matching recall\n",
|
||||
" 929 105.8 1.23 640 0.4736 0.9903\n",
|
||||
"Image sizes 640 train, 640 test\n",
|
||||
"Using 2 dataloader workers\n",
|
||||
"Starting training for 5 epochs...\n",
|
||||
"\n",
|
||||
" Epoch gpu_mem GIoU obj cls total targets img_size\n",
|
||||
" 0/4 9.65G 0.1222 0.08038 0.1221 0.3248 223 640: 100% 8/8 [00:06<00:00, 1.14it/s]\n",
|
||||
" Class Images Targets P R mAP@.5 mAP@.5:.95: 100% 8/8 [00:03<00:00, 2.31it/s]\n",
|
||||
" all 128 929 0 0 0 0\n",
|
||||
" 0/4 7.3G 0.04362 0.07954 0.02032 0.1435 208 640: 100% 8/8 [00:09<00:00, 1.24s/it]\n",
|
||||
" Class Images Targets P R mAP@.5 mAP@.5:.95: 100% 8/8 [00:07<00:00, 1.03it/s]\n",
|
||||
" all 128 929 0.421 0.704 0.66 0.42\n",
|
||||
"\n",
|
||||
" Epoch gpu_mem GIoU obj cls total targets img_size\n",
|
||||
" 1/4 8.86G 0.1163 0.08987 0.1211 0.3273 348 640: 100% 8/8 [00:02<00:00, 3.64it/s]\n",
|
||||
" Class Images Targets P R mAP@.5 mAP@.5:.95: 100% 8/8 [00:00<00:00, 8.80it/s]\n",
|
||||
" all 128 929 0 0 0 0\n",
|
||||
" 1/4 13.9G 0.04609 0.07819 0.01886 0.1431 167 640: 100% 8/8 [00:03<00:00, 2.34it/s]\n",
|
||||
" Class Images Targets P R mAP@.5 mAP@.5:.95: 100% 8/8 [00:02<00:00, 3.34it/s]\n",
|
||||
" all 128 929 0.418 0.713 0.659 0.421\n",
|
||||
"\n",
|
||||
" Epoch gpu_mem GIoU obj cls total targets img_size\n",
|
||||
" 2/4 8.86G 0.1145 0.08071 0.1214 0.3166 187 640: 100% 8/8 [00:02<00:00, 3.62it/s]\n",
|
||||
" Class Images Targets P R mAP@.5 mAP@.5:.95: 100% 8/8 [00:00<00:00, 8.62it/s]\n",
|
||||
" all 128 929 0 0 0 0\n",
|
||||
" 2/4 13.9G 0.04508 0.07012 0.01977 0.135 198 640: 100% 8/8 [00:03<00:00, 2.33it/s]\n",
|
||||
" Class Images Targets P R mAP@.5 mAP@.5:.95: 100% 8/8 [00:02<00:00, 3.50it/s]\n",
|
||||
" all 128 929 0.409 0.71 0.664 0.421\n",
|
||||
"\n",
|
||||
" Epoch gpu_mem GIoU obj cls total targets img_size\n",
|
||||
" 3/4 8.86G 0.113 0.07988 0.1199 0.3128 236 640: 100% 8/8 [00:02<00:00, 3.53it/s]\n",
|
||||
" Class Images Targets P R mAP@.5 mAP@.5:.95: 100% 8/8 [00:00<00:00, 8.79it/s]\n",
|
||||
" all 128 929 0 0 0 0\n",
|
||||
" 3/4 13.9G 0.04577 0.08308 0.02038 0.1492 222 640: 100% 8/8 [00:03<00:00, 2.34it/s]\n",
|
||||
" Class Images Targets P R mAP@.5 mAP@.5:.95: 100% 8/8 [00:02<00:00, 3.50it/s]\n",
|
||||
" all 128 929 0.429 0.71 0.67 0.426\n",
|
||||
"\n",
|
||||
" Epoch gpu_mem GIoU obj cls total targets img_size\n",
|
||||
" 4/4 8.86G 0.1109 0.08885 0.1198 0.3196 257 640: 100% 8/8 [00:02<00:00, 3.62it/s]\n",
|
||||
" Class Images Targets P R mAP@.5 mAP@.5:.95: 100% 8/8 [00:00<00:00, 8.56it/s]\n",
|
||||
" all 128 929 0 0 0 0\n",
|
||||
"Optimizer stripped from weights/last_yolov5s_coco128.pt\n",
|
||||
"5 epochs completed in 0.007 hours.\n",
|
||||
" 4/4 13.9G 0.04608 0.07352 0.01855 0.1382 149 640: 100% 8/8 [00:03<00:00, 2.32it/s]\n",
|
||||
" Class Images Targets P R mAP@.5 mAP@.5:.95: 100% 8/8 [00:02<00:00, 3.46it/s]\n",
|
||||
" all 128 929 0.423 0.716 0.663 0.422\n",
|
||||
"Optimizer stripped from weights/last_tutorial.pt\n",
|
||||
"5 epochs completed in 0.012 hours.\n",
|
||||
"\n"
|
||||
],
|
||||
"name": "stdout"
|
||||
@@ -574,7 +557,7 @@
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"Image(filename='./train_batch1.jpg', width=900) # view augmented train images"
|
||||
"Image(filename='./train_batch1.jpg', width=900) # view augmented training mosaics"
|
||||
],
|
||||
"execution_count": 0,
|
||||
"outputs": [
|
||||
@@ -691,7 +674,7 @@
|
||||
"colab_type": "text"
|
||||
},
|
||||
"source": [
|
||||
"Training losses and performance metrics are saved to Tensorboard and also to a `results.txt` logfile. `results.txt` is plotted as `results.png` after training completes. Partially completed `results.txt` files can be plotted with `from utils.utils import plot_results; plot_results()`. Here we show yolov5s trained on coco128 to 100 epochs, starting from scratch (blue), and starting from pretrained `yolov5s.pt` weights (orange)."
|
||||
"Training losses and performance metrics are saved to Tensorboard and also to a `results.txt` logfile. `results.txt` is plotted as `results.png` after training completes. Partially completed `results.txt` files can be plotted with `from utils.utils import plot_results; plot_results()`. Here we show YOLOv5s trained on coco128 to 100 epochs, starting from scratch (orange), and starting from pretrained `yolov5s.pt` weights (blue)."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -728,6 +711,81 @@
|
||||
"execution_count": 9
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "IEijrePND_2I",
|
||||
"colab_type": "text"
|
||||
},
|
||||
"source": [
|
||||
"## 5. Appendix"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"metadata": {
|
||||
"id": "gI6NoBev8Ib1",
|
||||
"colab_type": "code",
|
||||
"colab": {}
|
||||
},
|
||||
"source": [
|
||||
"# Re-clone\n",
|
||||
"%cd ..\n",
|
||||
"!rm -rf yolov5 && git clone https://github.com/ultralytics/yolov5\n",
|
||||
"%cd yolov5"
|
||||
],
|
||||
"execution_count": 0,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"metadata": {
|
||||
"id": "5OGhWlyAYQlS",
|
||||
"colab_type": "code",
|
||||
"colab": {}
|
||||
},
|
||||
"source": [
|
||||
"# Apex install\n",
|
||||
"git clone https://github.com/NVIDIA/apex && cd apex && pip install -v --no-cache-dir --global-option=\"--cpp_ext\" --global-option=\"--cuda_ext\" . --user && cd .. && rm -rf apex"
|
||||
],
|
||||
"execution_count": 0,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"metadata": {
|
||||
"id": "JaTFNJHvFBy4",
|
||||
"colab_type": "code",
|
||||
"colab": {}
|
||||
},
|
||||
"source": [
|
||||
"# Test GCP checkpoint on COCO val2017\n",
|
||||
"%%shell\n",
|
||||
"x=best*.pt\n",
|
||||
"gsutil cp gs://*/*/weights/$x .\n",
|
||||
"python test.py --weights $x --data ./data/coco.yaml --img 736"
|
||||
],
|
||||
"execution_count": 0,
|
||||
"outputs": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"metadata": {
|
||||
"id": "wuVlYvfBVTuD",
|
||||
"colab_type": "code",
|
||||
"colab": {}
|
||||
},
|
||||
"source": [
|
||||
"# Test multiple models on COCO val2017\n",
|
||||
"%%shell\n",
|
||||
"for x in yolov5s yolov5m yolov5l yolov5x\n",
|
||||
"do \n",
|
||||
" python test.py --weights $x.pt --data ./data/coco.yaml --img 640 --conf 0.001\n",
|
||||
"done"
|
||||
],
|
||||
"execution_count": 0,
|
||||
"outputs": []
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in new issue
Block a user