PyTorch保存和加载模型方法汇总
看到一篇非常好的文章,介绍pytorch保存和加载模型的,非常详细。备份: 太长不看版: 方法1: torch.save(modelA.state_dict(), PATH) model.load_state_dict(torch.load […]
Matlab提示:错误使用 table/subsrefDot (line 76)
使用Matlab的时候提示:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
警告: 变量名称已修改,以使其可用作有效的 MATLAB 标识符。 > In makeValidName at 25 In @table\private\setVarNames at 48 In table.readTextFile at 278 In table.readFromFile at 33 In readtable at 118 In data_info_maker_dln2 at 4 错误使用 table/subsrefDot (line 76) 变量名称 'name' 无法识别。 出错 table/subsref (line 62) [varargout{1:nargout}] = subsrefDot(t,s); 出错 data_info_maker_dln2 (line 6) video_names = data.name; % video names |
csv文件命名就有这个名字,但是始终无法读取,MOS倒是正常读取,于是在MATLAB中打开csv文件查看,发现问题: 原来name是乱码,确实无 […]
loaded state dict contains a parameter group that doesn’t match the size of optimizer’s group
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
Traceback (most recent call last): File "tools/train.py", line 98, in <module> main() File "tools/train.py", line 94, in main logger=logger) File "/home/omnisky/Code/redet-improve-new/mmdet/apis/train.py", line 61, in train_detector _non_dist_train(model, dataset, cfg, validate=validate) File "/home/omnisky/Code/redet-improve-new/mmdet/apis/train.py", line 194, in _non_dist_train runner.resume(cfg.resume_from) File "/home/omnisky/anaconda3/envs/redet/lib/python3.7/site-packages/mmcv-0.2.13-py3.7-linux-x86_64.egg/mmcv/runner/runner.py", line 313, in resume self.optimizer.load_state_dict(checkpoint['optimizer']) File "/home/omnisky/anaconda3/envs/redet/lib/python3.7/site-packages/torch/optim/optimizer.py", line 116, in load_state_dict raise ValueError("loaded state dict contains a parameter group " ValueError: loaded state dict contains a parameter group that doesn't match the size of optimizer's group |
解决方法(注意文件路径): vi ~/anaconda3/envs/环境名/lib/python3.7/site-packages/mmcv-0.2.13-py3.7-lin […]
RuntimeError: Expected object of scalar type Byte but got scalar type Bool
使用mmdet的时候遇到问题:RuntimeError: Expected object of scalar type Byte but got scalar type Bool for argument #2 ‘other’ in cal […]
OSError: Unable to open file (file signature not found)
今天用h5py读mat文件的时候报错: OSError: Unable to open file (file signature not found) 之前我们读mat文件都是用scipy.io,但是后来MATLAB升级之后,就得用h5py […]
使用Python读取XML文件[以VOC为例]
读取xml文件 假设xml文件是这样的:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
<annotation> <folder>detection</folder> <filename>00001.png</filename> <size> <width>478</width> <height>270</height> <depth>3</depth> </size> <segmented>0</segmented> <object> <name>person</name> <pose>Unspecified</pose> <truncated>0</truncated> <difficult>0</difficult> <bndbox> <xmin>420</xmin> <ymin>125</ymin> <xmax>462</xmax> <ymax>256</ymax> </bndbox> </object> <object> <name>person</name> <pose>Unspecified</pose> <truncated>0</truncated> <difficult>0</difficult> <bndbox> <xmin>463</xmin> <ymin>125</ymin> <xmax>479</xmax> <ymax>255</ymax> </bndbox> </object> <object> <name>person</name> <pose>Unspecified</pose> <truncated>0</truncated> <difficult>0</difficult> <bndbox> <xmin>286</xmin> <ymin>97</ymin> <xmax>301</xmax> <ymax>138</ymax> </bndbox> </object> </annotation> |
读取方法如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
import xml.etree.ElementTree as ET with open('a.xml', 'r') as f: tree=ET.parse(f) root = tree.getroot() root # <Element 'annotation' at 0x107577a98> list(root) # <Element 'folder' at 0x107577908> # <Element 'filename' at 0x107577ef8> # <Element 'size' at 0x107577868> # <Element 'segmented' at 0x107577d18> # <Element 'object' at 0x1075777c8> # <Element 'object' at 0x1075775e8> # <Element 'object' at 0x10741dcc8> size = root.find('size') # 获取子元素 w = int(size.find('width').text) # 读取值 h = int(size.find('height').text) for obj in root.iter('object'): # 多个元素 difficult = obj.find('difficult').text cls = obj.find('name').text |
本文最后更新于2021 […]
VIM常用命令备份
快捷键 功能 记忆 ^ 行首 来源于正则表达式 $ 行尾 来源于正则表达式 i 插入 insert x 删除一个字符 ❌ a 附加(右移再插入) append A 在行尾附加 Append w 下一个单词 word GG 跳转到文尾 Go […]
简要介绍ALEXNET / VGGNET / RESNET / DENSENET
AlexNet AlexNet虽然如今在实践中并不常用,但是很具有历史意义,它是第一个在ImageNet比赛中获奖的CNN结构。 AlexNet 结构在ImageNet中获奖 VGG VGGNet实际上和AlexNet一样都是对CN […]
[图解]Faster R-CNN原理和实现细节
Faster RCNN由Ross B. Girshick在2016年提出,是RCNN系列的延续和经典版本。由于图像中的目标数量和位置并不确定,卷积神经网络本身是难以处理检测这样的问题的。 为了解决这个问题,Faster RC […]
在Python中使用正则表达式
正则表达式简介 默认情况下,正则表达式(Regex)会匹配尽量多的字符,除非使用?标记 只能匹配一个字符的: 符号 匹配 . 任意1个字符 [a-z] 任意1个小写字符 数量限制符号: 符号 匹配 ? 匹配0-1次 + 匹配1-n次 * 匹 […]