From 7398d2d77cbac9f66259926d49c26bfa3c257a9b Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Tue, 22 Nov 2022 21:27:33 +0100 Subject: [PATCH] Created using Colaboratory --- classify/tutorial.ipynb | 63 +++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/classify/tutorial.ipynb b/classify/tutorial.ipynb index a3da0dbd3..c6f5d0d88 100644 --- a/classify/tutorial.ipynb +++ b/classify/tutorial.ipynb @@ -42,14 +42,14 @@ "base_uri": "https://localhost:8080/" }, "id": "wbvMlHd_QwMG", - "outputId": "43b2e1b5-78d9-4e1d-8530-ee9779bba160" + "outputId": "0806e375-610d-4ec0-c867-763dbb518279" }, "outputs": [ { "output_type": "stream", "name": "stderr", "text": [ - "YOLOv5 ๐Ÿš€ v6.2-258-g7fc7ed7 Python-3.7.15 torch-1.12.1+cu113 CUDA:0 (Tesla T4, 15110MiB)\n" + "YOLOv5 ๐Ÿš€ v7.0-3-g61ebf5e Python-3.7.15 torch-1.12.1+cu113 CUDA:0 (Tesla T4, 15110MiB)\n" ] }, { @@ -100,24 +100,24 @@ "base_uri": "https://localhost:8080/" }, "id": "zR9ZbuQCH7FX", - "outputId": "1b610787-7cf7-4c33-aac2-aa50fbb84a94" + "outputId": "50504ef7-aa3e-4281-a4e3-d0c7df3c0ffe" }, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ - "\u001b[34m\u001b[1mclassify/predict: \u001b[0mweights=['yolov5s-cls.pt'], source=data/images, data=data/coco128.yaml, imgsz=[224, 224], device=, view_img=False, save_txt=True, nosave=False, augment=False, visualize=False, update=False, project=runs/predict-cls, name=exp, exist_ok=False, half=False, dnn=False, vid_stride=1\n", - "YOLOv5 ๐Ÿš€ v6.2-258-g7fc7ed7 Python-3.7.15 torch-1.12.1+cu113 CUDA:0 (Tesla T4, 15110MiB)\n", + "\u001b[34m\u001b[1mclassify/predict: \u001b[0mweights=['yolov5s-cls.pt'], source=data/images, data=data/coco128.yaml, imgsz=[224, 224], device=, view_img=False, save_txt=False, nosave=False, augment=False, visualize=False, update=False, project=runs/predict-cls, name=exp, exist_ok=False, half=False, dnn=False, vid_stride=1\n", + "YOLOv5 ๐Ÿš€ v7.0-3-g61ebf5e Python-3.7.15 torch-1.12.1+cu113 CUDA:0 (Tesla T4, 15110MiB)\n", "\n", - "Downloading https://github.com/ultralytics/yolov5/releases/download/v6.2/yolov5s-cls.pt to yolov5s-cls.pt...\n", - "100% 10.5M/10.5M [00:03<00:00, 2.94MB/s]\n", + "Downloading https://github.com/ultralytics/yolov5/releases/download/v7.0/yolov5s-cls.pt to yolov5s-cls.pt...\n", + "100% 10.5M/10.5M [00:00<00:00, 12.3MB/s]\n", "\n", "Fusing layers... \n", "Model summary: 117 layers, 5447688 parameters, 0 gradients, 11.4 GFLOPs\n", "image 1/2 /content/yolov5/data/images/bus.jpg: 224x224 minibus 0.39, police van 0.24, amphibious vehicle 0.05, recreational vehicle 0.04, trolleybus 0.03, 3.9ms\n", - "image 2/2 /content/yolov5/data/images/zidane.jpg: 224x224 suit 0.38, bow tie 0.19, bridegroom 0.18, rugby ball 0.04, stage 0.02, 4.1ms\n", - "Speed: 0.3ms pre-process, 4.0ms inference, 1.5ms NMS per image at shape (1, 3, 224, 224)\n", + "image 2/2 /content/yolov5/data/images/zidane.jpg: 224x224 suit 0.38, bow tie 0.19, bridegroom 0.18, rugby ball 0.04, stage 0.02, 4.6ms\n", + "Speed: 0.3ms pre-process, 4.3ms inference, 1.5ms NMS per image at shape (1, 3, 224, 224)\n", "Results saved to \u001b[1mruns/predict-cls/exp\u001b[0m\n" ] } @@ -155,23 +155,23 @@ "base_uri": "https://localhost:8080/" }, "id": "WQPtK1QYVaD_", - "outputId": "92de5f34-cf41-49e7-b679-41db94e995ac" + "outputId": "20fc0630-141e-4a90-ea06-342cbd7ce496" }, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ - "--2022-11-18 21:48:38-- https://image-net.org/data/ILSVRC/2012/ILSVRC2012_img_val.tar\n", + "--2022-11-22 19:53:40-- https://image-net.org/data/ILSVRC/2012/ILSVRC2012_img_val.tar\n", "Resolving image-net.org (image-net.org)... 171.64.68.16\n", "Connecting to image-net.org (image-net.org)|171.64.68.16|:443... connected.\n", "HTTP request sent, awaiting response... 200 OK\n", "Length: 6744924160 (6.3G) [application/x-tar]\n", "Saving to: โ€˜ILSVRC2012_img_val.tarโ€™\n", "\n", - "ILSVRC2012_img_val. 100%[===================>] 6.28G 7.15MB/s in 11m 13s \n", + "ILSVRC2012_img_val. 100%[===================>] 6.28G 16.1MB/s in 10m 52s \n", "\n", - "2022-11-18 21:59:52 (9.55 MB/s) - โ€˜ILSVRC2012_img_val.tarโ€™ saved [6744924160/6744924160]\n", + "2022-11-22 20:04:32 (9.87 MB/s) - โ€˜ILSVRC2012_img_val.tarโ€™ saved [6744924160/6744924160]\n", "\n" ] } @@ -189,7 +189,7 @@ "base_uri": "https://localhost:8080/" }, "id": "X58w8JLpMnjH", - "outputId": "9961ad87-d639-4489-b578-0a0578fefaab" + "outputId": "41843132-98e2-4c25-d474-4cd7b246fb8e" }, "outputs": [ { @@ -197,11 +197,11 @@ "name": "stdout", "text": [ "\u001b[34m\u001b[1mclassify/val: \u001b[0mdata=../datasets/imagenet, weights=['yolov5s-cls.pt'], batch_size=128, imgsz=224, device=, workers=8, verbose=True, project=runs/val-cls, name=exp, exist_ok=False, half=True, dnn=False\n", - "YOLOv5 ๐Ÿš€ v6.2-258-g7fc7ed7 Python-3.7.15 torch-1.12.1+cu113 CUDA:0 (Tesla T4, 15110MiB)\n", + "YOLOv5 ๐Ÿš€ v7.0-3-g61ebf5e Python-3.7.15 torch-1.12.1+cu113 CUDA:0 (Tesla T4, 15110MiB)\n", "\n", "Fusing layers... \n", "Model summary: 117 layers, 5447688 parameters, 0 gradients, 11.4 GFLOPs\n", - "validating: 100% 391/391 [04:48<00:00, 1.35it/s]\n", + "validating: 100% 391/391 [04:57<00:00, 1.31it/s]\n", " Class Images top1_acc top5_acc\n", " all 50000 0.715 0.902\n", " tench 50 0.94 0.98\n", @@ -1269,30 +1269,30 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 10, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "1NcFxRcFdJ_O", - "outputId": "638c55b1-dc45-4eee-cabc-4921dc61faf5" + "outputId": "77c8d487-16db-4073-b3ea-06cabf2e7766" }, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ - "\u001b[34m\u001b[1mclassify/train: \u001b[0mmodel=yolov5s-cls.pt, data=imagenette160, epochs=3, batch_size=16, imgsz=224, nosave=False, cache=ram, device=, workers=8, project=runs/train-cls, name=exp, exist_ok=False, pretrained=True, optimizer=Adam, lr0=0.001, decay=5e-05, label_smoothing=0.1, cutoff=None, dropout=None, verbose=False, seed=0, local_rank=-1\n", + "\u001b[34m\u001b[1mclassify/train: \u001b[0mmodel=yolov5s-cls.pt, data=imagenette160, epochs=5, batch_size=64, imgsz=224, nosave=False, cache=ram, device=, workers=8, project=runs/train-cls, name=exp, exist_ok=False, pretrained=True, optimizer=Adam, lr0=0.001, decay=5e-05, label_smoothing=0.1, cutoff=None, dropout=None, verbose=False, seed=0, local_rank=-1\n", "\u001b[34m\u001b[1mgithub: \u001b[0mup to date with https://github.com/ultralytics/yolov5 โœ…\n", - "YOLOv5 ๐Ÿš€ v6.2-258-g7fc7ed7 Python-3.7.15 torch-1.12.1+cu113 CUDA:0 (Tesla T4, 15110MiB)\n", + "YOLOv5 ๐Ÿš€ v7.0-3-g61ebf5e Python-3.7.15 torch-1.12.1+cu113 CUDA:0 (Tesla T4, 15110MiB)\n", "\n", "\u001b[34m\u001b[1mTensorBoard: \u001b[0mStart with 'tensorboard --logdir runs/train-cls', view at http://localhost:6006/\n", "\n", "Dataset not found โš ๏ธ, missing path /content/datasets/imagenette160, attempting download...\n", "Downloading https://github.com/ultralytics/yolov5/releases/download/v1.0/imagenette160.zip to /content/datasets/imagenette160.zip...\n", - "100% 103M/103M [00:09<00:00, 11.1MB/s]\n", + "100% 103M/103M [00:00<00:00, 347MB/s] \n", "Unzipping /content/datasets/imagenette160.zip...\n", - "Dataset download success โœ… (13.2s), saved to \u001b[1m/content/datasets/imagenette160\u001b[0m\n", + "Dataset download success โœ… (3.3s), saved to \u001b[1m/content/datasets/imagenette160\u001b[0m\n", "\n", "\u001b[34m\u001b[1malbumentations: \u001b[0mRandomResizedCrop(p=1.0, height=224, width=224, scale=(0.08, 1.0), ratio=(0.75, 1.3333333333333333), interpolation=1), HorizontalFlip(p=0.5), ColorJitter(p=0.5, brightness=[0.6, 1.4], contrast=[0.6, 1.4], saturation=[0.6, 1.4], hue=[0, 0]), Normalize(p=1.0, mean=(0.485, 0.456, 0.406), std=(0.229, 0.224, 0.225), max_pixel_value=255.0), ToTensorV2(always_apply=True, p=1.0, transpose_mask=False)\n", "Model summary: 149 layers, 4185290 parameters, 4185290 gradients, 10.5 GFLOPs\n", @@ -1300,14 +1300,16 @@ "Image sizes 224 train, 224 test\n", "Using 1 dataloader workers\n", "Logging results to \u001b[1mruns/train-cls/exp\u001b[0m\n", - "Starting yolov5s-cls.pt training on imagenette160 dataset with 10 classes for 3 epochs...\n", + "Starting yolov5s-cls.pt training on imagenette160 dataset with 10 classes for 5 epochs...\n", "\n", " Epoch GPU_mem train_loss val_loss top1_acc top5_acc\n", - " 1/3 0.348G 1.31 1.09 0.794 0.979: 100% 592/592 [01:02<00:00, 9.47it/s]\n", - " 2/3 0.415G 1.09 0.852 0.883 0.99: 100% 592/592 [00:59<00:00, 10.00it/s]\n", - " 3/3 0.415G 0.954 0.776 0.907 0.994: 100% 592/592 [00:59<00:00, 9.89it/s]\n", + " 1/5 1.47G 1.05 0.974 0.828 0.975: 100% 148/148 [00:38<00:00, 3.82it/s]\n", + " 2/5 1.73G 0.895 0.766 0.911 0.994: 100% 148/148 [00:36<00:00, 4.03it/s]\n", + " 3/5 1.73G 0.82 0.704 0.934 0.996: 100% 148/148 [00:35<00:00, 4.20it/s]\n", + " 4/5 1.73G 0.766 0.664 0.951 0.998: 100% 148/148 [00:36<00:00, 4.05it/s]\n", + " 5/5 1.73G 0.724 0.634 0.959 0.997: 100% 148/148 [00:37<00:00, 3.94it/s]\n", "\n", - "Training complete (0.051 hours)\n", + "Training complete (0.052 hours)\n", "Results saved to \u001b[1mruns/train-cls/exp\u001b[0m\n", "Predict: python classify/predict.py --weights runs/train-cls/exp/weights/best.pt --source im.jpg\n", "Validate: python classify/val.py --weights runs/train-cls/exp/weights/best.pt --data /content/datasets/imagenette160\n", @@ -1320,7 +1322,7 @@ ], "source": [ "# Train YOLOv5s Classification on Imagenette160 for 3 epochs\n", - "!python classify/train.py --img 224 --batch 16 --epochs 3 --data imagenette160 --model yolov5s-cls.pt --cache" + "!python classify/train.py --model yolov5s-cls.pt --data imagenette160 --epochs 5 --img 224 --cache" ] }, { @@ -1452,8 +1454,7 @@ "accelerator": "GPU", "colab": { "name": "YOLOv5 Classification Tutorial", - "provenance": [], - "toc_visible": true + "provenance": [] }, "kernelspec": { "display_name": "Python 3 (ipykernel)", @@ -1475,4 +1476,4 @@ }, "nbformat": 4, "nbformat_minor": 0 -} +} \ No newline at end of file