记录mask-rcnn的复现所遇到的问题

介于水平有限,所以是主要参考现成的一篇博客跑的。不过还是遇到了一些问题,这里做下记录

参考链接

(57条消息) 手把手教你训练自己的Mask R-CNN图像实例分割模型(PyTorch官方教程)_一个菜鸟的奋斗的博客-CSDN博客_实例分割模型

第一个是文件夹的问题,你必须要把相关文件拷贝到当前目录,比如utils.py engine.py transforms.py等,不是傻傻地pip install

第二个是transforms.py有个函数 get_dimensions

我发现torchvision.transforms.functional模块当时的版本是没有这个函数的。

主要是实现

channels,height,width=get_dimensions(image)

我有查看了下torchvision.transforms.functional有哪些方法,我发现有

get_image_size和get_image_num_channels方法

我想可能是包新版本这两个方法之后是合并了吧。(我猜的,也可能是拆开了,我太懒了= =)

所以我自己写了个函数

from torchvision.transforms.functional import get_image_size
from torchvision.transforms.functional import get_image_num_channels

def get_dimensions(image):
    height, width = get_image_size(image)[1],get_image_size(image)[0]
    channels = get_image_num_channels(image)
    return channels,height,width

解决了这个问题。

第三个是数据类型的问题

for images, targets in metric_logger.log_every(data_loader, print_freq, header):
    images = list(image.to(device) for image in images)
#这里images里面是int8型

这里的images原本是int型的,报错要改为float型,所以我改成了

for images, targets in metric_logger.log_every(data_loader, print_freq, header):
    images = list(image.to(device) for image in images)
    images = [ items.float() for items in images]
#images是个列表

第四个是学习率设置太大,导致在train的时候loss特别大出现nan

只要把学习率改小就好了。

结果

Epoch: [9] Total time: 0:00:19 (0.3245 s / it)
hahahhaha
creating index...
index created!
Test:  [ 0/50]  eta: 0:00:13  model_time: 0.1376 (0.1376)  evaluator_time: 0.0535 (0.0535)  time: 0.2753  data: 0.0835  max mem: 3358
Test:  [49/50]  eta: 0:00:00  model_time: 0.1464 (0.1449)  evaluator_time: 0.0807 (0.0910)  time: 0.2470  data: 0.0035  max mem: 3358
outle
Test: Total time: 0:00:12 (0.2460 s / it)
Averaged stats: model_time: 0.1464 (0.1449)  evaluator_time: 0.0807 (0.0910)
Accumulating evaluation results...
DONE (t=0.06s).
Accumulating evaluation results...
DONE (t=0.05s).
IoU metric: bbox
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.044
 Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.178
 Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.013
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = -1.000
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.000
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.048
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.056
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.178
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.317
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = -1.000
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.025
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.338
IoU metric: segm
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.010
 Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.050
 Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.000
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = -1.000
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.000
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.012
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.019
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.059
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.118
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = -1.000
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.013
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.126

第五个是会有数据集会出现.ipynb_checkpoints的隐藏文件,读取的时候会有问题

删掉这个文件就好了

誓为血气少年郎,不做羊质虎皮人!

你可能感兴趣的:(深度学习,计算机视觉,人工智能)