Skip to content

Commit 80f3fac

Browse files
committed
add audio classify jupyter
1 parent 6717e20 commit 80f3fac

File tree

2 files changed

+153
-9
lines changed

2 files changed

+153
-9
lines changed

demo/audio_classify.ipynb

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"## 环境配置\n",
8+
"1. 下载[edgelab](https://github.com/mjq2020/edgelab)仓库代码\n",
9+
"2. 运行环境配置脚本\n"
10+
]
11+
},
12+
{
13+
"cell_type": "code",
14+
"execution_count": null,
15+
"metadata": {},
16+
"outputs": [],
17+
"source": [
18+
"%cd ~\n",
19+
"!git clone https://github.com/mjq2020/edgelab\n",
20+
"%cd edgelab"
21+
]
22+
},
23+
{
24+
"cell_type": "code",
25+
"execution_count": null,
26+
"metadata": {},
27+
"outputs": [],
28+
"source": [
29+
"!python tools/env_config.py\n",
30+
"import os\n",
31+
"os.environ['PYTHONPATH'] = '~/edgelab'\n",
32+
"!nvidia-smi"
33+
]
34+
},
35+
{
36+
"cell_type": "markdown",
37+
"metadata": {},
38+
"source": [
39+
"## 模型训练\n",
40+
"1. 运行train.py,设置任务类别、配置文件路径、等"
41+
]
42+
},
43+
{
44+
"cell_type": "code",
45+
"execution_count": null,
46+
"metadata": {},
47+
"outputs": [],
48+
"source": [
49+
"!~/anaconda3/envs/edgelab/bin/python tools/train.py mmcls configs/audio_classify/ali_classiyf_small_8k_8192.py --cfg-options runner.max_epochs=10"
50+
]
51+
},
52+
{
53+
"cell_type": "markdown",
54+
"metadata": {},
55+
"source": [
56+
"## 导出ONNX\n",
57+
"1. 使用torch2onnx.py转换刚才完成训练的权重文件\n",
58+
"2. onnx文件生成位置位于原权重文件相同位置(后缀.onnx)"
59+
]
60+
},
61+
{
62+
"cell_type": "code",
63+
"execution_count": null,
64+
"metadata": {},
65+
"outputs": [],
66+
"source": [
67+
"!~/anaconda3/envs/edgelab/bin/python tools/torch2onnx.py --config configs/audio_classify/ali_classiyf_small_8k_8192.py --checkpoint work_dirs/exp1/latest.pth --task mmcls"
68+
]
69+
},
70+
{
71+
"cell_type": "markdown",
72+
"metadata": {},
73+
"source": [
74+
"## onnx转ncnn及量化\n",
75+
"1. 使用export_quantize.py脚本将生成的onnx文件转为ncnn或进行量化\n",
76+
"2. "
77+
]
78+
},
79+
{
80+
"cell_type": "code",
81+
"execution_count": null,
82+
"metadata": {},
83+
"outputs": [],
84+
"source": [
85+
"!~/anaconda3/envs/edgelab/bin/python tools/export_quantize.py --onnx work_dirs/exp1/latest.onnx --type ncnn"
86+
]
87+
}
88+
],
89+
"metadata": {
90+
"kernelspec": {
91+
"display_name": "Python 3.8.13 ('mmset')",
92+
"language": "python",
93+
"name": "python3"
94+
},
95+
"language_info": {
96+
"codemirror_mode": {
97+
"name": "ipython",
98+
"version": 3
99+
},
100+
"file_extension": ".py",
101+
"mimetype": "text/x-python",
102+
"name": "python",
103+
"nbconvert_exporter": "python",
104+
"pygments_lexer": "ipython3",
105+
"version": "3.8.15"
106+
},
107+
"orig_nbformat": 4,
108+
"vscode": {
109+
"interpreter": {
110+
"hash": "4371667da6ad0a80396cd63c529a9936708aaf3de3d23ccc7c4ed575a0b05f73"
111+
}
112+
}
113+
},
114+
"nbformat": 4,
115+
"nbformat_minor": 2
116+
}

demo/meter.ipynb

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
{
22
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# 表计回归\n",
8+
"1. 模型训练\n",
9+
"2. 导出onnx\n",
10+
"3. 导出ncnn"
11+
]
12+
},
313
{
414
"cell_type": "markdown",
515
"metadata": {},
616
"source": [
717
"## 环境配置\n",
8-
"1. 下载[edgelab](https://github.com/mjq2020/edgelab)仓库代码\n",
9-
"2. 运行环境配置脚本\n"
18+
"1. 下载edgelab仓库代码\n",
19+
"2. 运行项目环境配置脚本"
1020
]
1121
},
1222
{
@@ -36,8 +46,27 @@
3646
"cell_type": "markdown",
3747
"metadata": {},
3848
"source": [
39-
"## 模型训练\n",
40-
"1. 运行train.py,设置任务类别、配置文件路径、等"
49+
"## 数据集下载与上传\n",
50+
"1. 首先下载[表计数据集](https://1drv.ms/u/s!AqG2uRmVUhlShtIhyd_7APHXEhpeXg?e=WwGx5m)\n",
51+
"2. 将数据集上传至用户根目录"
52+
]
53+
},
54+
{
55+
"cell_type": "code",
56+
"execution_count": null,
57+
"metadata": {},
58+
"outputs": [],
59+
"source": [
60+
"%unzip ~/meter.zip -d ~ "
61+
]
62+
},
63+
{
64+
"cell_type": "markdown",
65+
"metadata": {},
66+
"source": [
67+
"## 修改配置文件并训练\n",
68+
"1. 修改config文件中的相配置。\n",
69+
"2. 运行train.py,设置任务类别、配置文件路径、等"
4170
]
4271
},
4372
{
@@ -46,7 +75,7 @@
4675
"metadata": {},
4776
"outputs": [],
4877
"source": [
49-
"!~/anaconda3/envs/edgelab/bin/python tools/train.py mmcls configs/audio_classify/ali_classiyf_small_8k_8192.py --cfg-options runner.max_epochs=10"
78+
"!~/anaconda3/envs/edgelab/bin/python tools/train.py mmpose configs/pfld/pfld_mv2n_112.py --cfg-options runner.max_epochs=10"
5079
]
5180
},
5281
{
@@ -64,16 +93,15 @@
6493
"metadata": {},
6594
"outputs": [],
6695
"source": [
67-
"!~/anaconda3/envs/edgelab/bin/python tools/torch2onnx.py --config configs/audio_classify/ali_classiyf_small_8k_8192.py --checkpoint work_dirs/exp1/latest.pth --task mmcls"
96+
"!~/anaconda3/envs/edgelab/bin/python tools/torch2onnx.py --config configs/pfld/pfld_mv2n_112.py --checkpoint work_dirs/exp1/latest.pth --task mmcls"
6897
]
6998
},
7099
{
71100
"cell_type": "markdown",
72101
"metadata": {},
73102
"source": [
74103
"## onnx转ncnn及量化\n",
75-
"1. 使用export_quantize.py脚本将生成的onnx文件转为ncnn或进行量化\n",
76-
"2. "
104+
"1. 使用export_quantize.py脚本将生成的onnx文件转为ncnn或进行量化"
77105
]
78106
},
79107
{
@@ -102,7 +130,7 @@
102130
"name": "python",
103131
"nbconvert_exporter": "python",
104132
"pygments_lexer": "ipython3",
105-
"version": "3.8.15"
133+
"version": "3.8.13"
106134
},
107135
"orig_nbformat": 4,
108136
"vscode": {

0 commit comments

Comments
 (0)