
【环境,编程问题汇总】
环境,编程遇到的一些问题的解决方法汇总
InactionWorld
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
pytorch将tensor转为numpy用于图像绘制
目标: 将tensor(图像形式)转为numpy,然后绘制图像1. 形如torch.Size([1, 3, 480, 856]) # B x C x H x W分析: 这种形状的tensor一般是要输出的某种图像或者即将转化为要输出的某种特征图绘制方法:首先压缩tensor的维度tensor = tensor.squeeze(0) # torch.Size([3, 480, 856])然后转换tensor维度的顺序tensor = tensor.permute(1, 2, 0)原创 2022-03-04 20:43:03 · 4457 阅读 · 1 评论 -
model.load_state_dict(checkpoint[‘state_dict‘]) KeyError: ‘state_dict‘
问题描述加载模型时,报错:model.load_state_dict(checkpoint[‘state_dict’]) KeyError: ‘state_dict’解决1. 如果你的模型命名为 checkpoint.ckpt,试试将其改为checkpoint.pt2. model.load_state_dict(torch.load(pth))原创 2022-03-03 22:20:50 · 10327 阅读 · 2 评论 -
ERROR: Failed building wheel for spatial-correlation-sampler
问题描述安装spatial-correlation-sampler模块报错ERROR: Failed building wheel for spatial-correlation-sampler。问题分析出现该问题的原因大概率是pytorch版本或cuda版本与spatial-correlation-sampler要求不一致。spatial-correlation-sampler要求版本:This module is expected to compile for Pytorch 1.2, on原创 2022-03-02 20:00:44 · 2054 阅读 · 0 评论 -
No module named png
问题: No module named png解决:不要直接安装png,会显示没有与之匹配的模块,应该安装pypngpip install pypng然后导入的时候导入pngimport png原创 2022-02-20 23:03:18 · 1848 阅读 · 0 评论 -
pycharm使用命令行形式执行代码,出现无法导入同一项目其他文件下的模块问题。
问题:pycharm使用命令行形式执行代码,出现无法导入同一项目其他文件下的模块问题。起因:初次使用open-mmlab的mmflow框架。其项目结构如下:想要跑一下video_demo.py,计算demo video的光流。根据指示运行命令:python demo/video_demo.py demo/demo.mp4 configs/raft/raft_8x2_100k_mixed_368x768.py checkpoints/raft_8x2_100k_mixed_368x768.pth r原创 2022-02-20 20:56:01 · 817 阅读 · 2 评论 -
TypeError: img should be PIL Image. Got <class ‘dict‘>/Got<class ‘Torch.Tensor‘>/Got<class ‘numpy.n>
1. 问题描述代码运行至下列语句时:for i, data in enumerate(train_loader):有时会遇到以下三种报错:TypeError: img should be PIL Image. Got <class 'dict'>TypeError: img should be PIL Image. Got <class 'Torch.Tensor'>TypeError: img should be PIL Image. Got <class原创 2021-09-30 14:41:05 · 12191 阅读 · 6 评论 -
RuntimeError: Expected object of scalar type Float but got scalar type Double for argument #2 ‘mat1‘
运行以下代码报错:RuntimeError: Expected object of scalar type Float but got scalar type Double for argument #2 ‘mat1’ in call to _th_addmmfor epoch in range(num_epochs): # Convert numpy arrays to torch tensors inputs = torch.from_numpy(x_train) targe原创 2021-09-23 21:40:11 · 495 阅读 · 0 评论 -
CMake Error at CMakeLists.txt:2 (project): project PROJECT called with incorrect number of arguments
问题描述使用CLion创建新项目后,点击构建(编译链接)按钮,报错:CMake Error at CMakeLists.txt:2 (project):project PROJECT called with incorrect number of arguments原因及解决方案创建的项目路径中含有中文,需要把中文修改为英文。...原创 2021-09-17 12:13:33 · 7761 阅读 · 1 评论 -
python读取json文件报错AttributeError: ‘str‘ object has no attribute ‘read‘
问题描述import jsondata = json.load('AlphaPose-pytorch/examples/res/alphapose-results.json')使用以上方法读取json文件时,报错AttributeError: 'str' object has no attribute 'read'解决方法import jsonwith open('AlphaPose-pytorch/examples/res/alphapose-results.json') as f: da原创 2021-05-22 18:48:28 · 13234 阅读 · 2 评论 -
from skimage.measure import compare_ssim as sk_cpt_ssim error,从skimage导入compare_ssim出错。
问题描述from skimage.measure import compare_ssim as sk_cpt_ssim error。从skimage.measure导入compare_ssim出错解决方法将from skimage.measure import compare_ssim as sk_cpt_ssim改为from skimage.metrics import structural_similarity as sk_cpt_ssimps:我在skimage/measure文原创 2021-02-09 14:21:52 · 10818 阅读 · 8 评论 -
Pycharm中无法显示matplotlib图像或者没找到图像
在pycharm尝试用matplotlib显示图像:if __name__ == '__main__': img = Image.open(r'XXXXX.jpg') transform = Random2DTranslation(256, 128, 0.5) img_t = transform(img) import matplotlib.pyplot as plt plt.figure(12) plt.subplot(121) plt.ims.原创 2021-01-24 04:52:37 · 14970 阅读 · 7 评论