当前位置:网站首页>Runtimeerror: output with shape [1, 256, 256] doesn't match the broadcast shape [3, 256, 256] [error]
Runtimeerror: output with shape [1, 256, 256] doesn't match the broadcast shape [3, 256, 256] [error]
2022-07-27 18:51:00 【It's too simple】
resolvent
stay dataloader Before dataset In the function , Add .convert(‘RGB’),eg:
image = Image.open(image_file).convert('RGB')To solve the process
In the process of paper reproduction, try to apply the unused data set to the source code , If there is a report error . After checking, it was found that the error occurred in dataloader in , Consider the problem of inputting pictures , Judge that the newly added data set is a grayscale image through the following code (1. The grayscale image has only one channel 2. Directly view the pixel value ), So infer dataloader Only three channels are accepted RGB chart , Convert picture to RGB Just figure .
Print picture pixel values
img_path = ' Write the address of the image you want to view here '
from PIL import Image
from torchvision import transforms
img = Image.open(img_path)
change = transforms.ToTensor()
img = change(img)
print(img)Check the pixel value of the picture
import cv2
img_path = ' Write the address of the image you want to view here '
img_c = cv2.imread(img_path,cv2.IMREAD_UNCHANGED)
cv2.imshow('photo',img_c)
key = cv2.waitKey(0)The solution of blogging is transforms.Compose() Add the following program segments in , My program hasn't improved , If it's a grayscale ,RGB Transformation and repeat The converted three channel images are consistent , This may be another reason for the program .
transforms.Lambda(lambda x: x.repeat(3, 1, 1))边栏推荐
- 面试官:你觉得你最大的缺点是什么?
- Aircraft battle with enemy aircraft
- ValueError: Found input variables with inconsistent numbers of samples: [80019456, 26673152]【报错】
- Login page tablelayout
- Machine learning -- error caused by only one kind of label data in SVM training set
- C basic concepts list description suggestions collection
- Uploading and downloading of files
- Solve the problem of JSP cascading
- Quick access to website media resources
- Aircraft collision detection
猜你喜欢

怎么会不喜欢呢,CI/CD中轻松发送邮件

MySQL basic statement

【npm】 无法将“npm”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。

Alibaba architects spent 280 hours sorting out 1015 pages of distributed full stack pamphlets to easily start the distributed system

mysql基础语句
MySQL create event execution task

商品评论信息与评论信息分类

MySQL learning Day1 DDL, DML, DQL basic query

Nacos display service registration address error

Solve the problem of JSP cascading
随机推荐
Uni app traversal array rendering data vertical rendering
家用静音驱蚊灯芯片-DLTAP703SD-杰力科创
Wechat applet multi file upload
MySQL查询列必须和group by字段一致吗?
Set the arc button to be displayed in the middle
个人中心--订单业务流程
Uniapp H5 cross domain problem
低噪负离子风扇触摸IC
I'm stupid. When completable future is used with openfegin, it even reports an error
Openstack login dashboard prompt authentication error
Jianmu continuous integration platform v2.5.2 release
Using Jieba and pyhanlp tools to extract keyword words and sentences
全身多功能按摩仪芯片-DLTAP602SD
10 SQL optimization schemes summarized by Alibaba P8 (very practical)
这样的API网关查询接口优化,我是被迫的
[yuntu said] 249 mobile application security service - app's physical examination center, comprehensive testing, safe on the road!
Alibaba architects spent 280 hours sorting out 1015 pages of distributed full stack pamphlets to easily start the distributed system
How to realize the full-text content retrieval of word, PDF and txt files?
Uni app label jump
Filebeat.yml configuration file about the configuration of multiple services