{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**step 1:** 安装PyTorch"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!pip install torch==1.5.1+cpu torchvision==0.6.1+cpu -f https://download.pytorch.org/whl/torch_stable.html"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**step 2:** 安装模型运行相关依赖"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!pip install -U -r requirements.txt"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"TACO数据集可以从本人该平台的taco项目从操作获得,所生成的数据集直接放置在根目录下即可**(此处已上传一份本地运行完的数据集)**"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"本人还在该项目根目录下存放了taco.zip文件,使用如下语句即可完成解压"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!unzip taco.zip"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**step 3:** 配置文件配置\n",
"- 将解压后的taco文件夹下taco.yaml文件拷贝至data文件夹下\n",
"- 修改models文件夹下yolov5s.yaml文件中的nc属性值改为对象类型总数"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**step 4:** 模型训练,训练过程所产生的输出将自动存放于runs文件夹下"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!python train.py --img 320 --batch 4 --epochs 100 --data ./data/taco.yaml --cfg ./models/yolov5s.yaml --device cpu --weights yolov5s.pt"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**step 5:** 效果测试,主要利用detect.py对inference/images文件夹下的目标图像进行测试,其结果存放在inference/output文件夹中;在测试前,注意要将runs中的best.pt权重文件放置项目根目录下"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!python detect.py --weights best.pt --img 320 --conf 0.4"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
}
},
"nbformat": 4,
"nbformat_minor": 4
}