Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yolov5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Administrator
yolov5
Commits
7398d2d7
提交
7398d2d7
authored
11月 22, 2022
作者:
Glenn Jocher
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Created using Colaboratory
上级
61ebf5e5
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
31 行增加
和
30 行删除
+31
-30
tutorial.ipynb
classify/tutorial.ipynb
+31
-30
没有找到文件。
classify/tutorial.ipynb
浏览文件 @
7398d2d7
...
...
@@ -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 🚀 v
6.2-258-g7fc7ed7
Python-3.7.15 torch-1.12.1+cu113 CUDA:0 (Tesla T4, 15110MiB)\n"
"YOLOv5 🚀 v
7.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=
Tru
e, 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 🚀 v
6.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=
Fals
e, 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 🚀 v
7.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/v
6.2
/yolov5s-cls.pt to yolov5s-cls.pt...\n",
"100% 10.5M/10.5M [00:0
3<00:00, 2.94
MB/s]\n",
"Downloading https://github.com/ultralytics/yolov5/releases/download/v
7.0
/yolov5s-cls.pt to yolov5s-cls.pt...\n",
"100% 10.5M/10.5M [00:0
0<00:00, 12.3
MB/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.
1
ms\n",
"Speed: 0.3ms pre-process, 4.
0
ms 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.
6
ms\n",
"Speed: 0.3ms pre-process, 4.
3
ms 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 13
s \n",
"ILSVRC2012_img_val. 100%[===================>] 6.28G
16.1MB/s in 10m 52
s \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 🚀 v
6.2-258-g7fc7ed7
Python-3.7.15 torch-1.12.1+cu113 CUDA:0 (Tesla T4, 15110MiB)\n",
"YOLOv5 🚀 v
7.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.35
it/s]\n",
"validating: 100% 391/391 [04:
57<00:00, 1.31
it/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 🚀 v
6.2-258-g7fc7ed7
Python-3.7.15 torch-1.12.1+cu113 CUDA:0 (Tesla T4, 15110MiB)\n",
"YOLOv5 🚀 v
7.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:0
9<00:00, 11.1MB/s]
\n",
"100% 103M/103M [00:0
0<00:00, 347MB/s]
\n",
"Unzipping /content/datasets/imagenette160.zip...\n",
"Dataset download success ✅ (
13.2
s), saved to \u001b[1m/content/datasets/imagenette160\u001b[0m\n",
"Dataset download success ✅ (
3.3
s), 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.05
1
hours)\n",
"Training complete (0.05
2
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)",
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论