|
| 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 | +} |
0 commit comments