opennmmlab實戰營二期-mmpretrain代碼課課(五)
點我:視頻課程
代碼課寫代碼最重要(相關代碼見:點我),筆記的話就簡單進行總結,大致如下:
-
一、安裝mmpretrain
-
二、呼叫mmpretrain的模型進行推理
- 影像分類
- 影像描述
-
三、在新分類資料集進行resnet18微調訓練
-
1、準備貓狗資料集
-
2、介紹組態檔(resnet18_8×32_link.py)
- 模型配置(resnet18.py)
- 資料集配置(imagenet_bs32.py)
- schedules配置(imagenet_bs256.py)
- 運行配置(default_runtime.py)
-
3、撰寫組態檔(resnet18_finetune.py)
- 復制模型、資料集、運行組態檔的內容至resnet18_finetune.py
- 修改組態檔
- 模型:
- 加
init_cfg=dict(type="Pretrained",checkpoint='https://download.openmmlab.com/mmclassification/v0/resnet/resnet18_8xb32_in1k_20210831-fbbb1da6.pth')(來自https://download.openmmlab.com/mmclassification/v0/resnet/resnet18_8xb32_in1k_20210831-fbbb1da6.pth) - 修改num_classes=2
- 加
- 資料集:
- 修改資料集型別:
dataset_type='CustomDataset' - 修改資料集路徑:
data_root=''
- 修改資料集型別:
- 運行:epoch
- 模型:
-
4、啟動訓練
-
mim mmpretrain resnet18_finetune.py --work-dir=./exp
-
-
5、測驗集評估
-
mim mmpretrain resnet18_finuetune.py --checkpoint exp/epoch.pth
-
-
6、使用其他工具分析結果
-
mim run mmpretrain analyze_results resnet18_finetune.py result.pkl --out-dir analyze
-
-
7、混淆矩陣
-
mim run mmpretrain confuse_matrix resnet18_finetune.py result.pkl --show --include-values
-
-
8、預測圖片
-
from mmpretrain import ImageClassficationInference inf=ImageClassficationInference('resnet18_finetune.py',pretrainen='epoch.pth') inf('image.jpg',show=True)
-
-
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/554497.html
標籤:其他
上一篇:ChatGPT玩法(二):AI玩轉Excel表格處理
下一篇:返回列表
