mmagic
mmagic copied to clipboard
Using owndata train EDSR ,error occur when reference
I used my own data to train EDSR, the size of the training data LRHR is 100100; 400400, but I also used the 100*100 test image to make a mistake during the test. the command is: CUDA_VISIBLE_DEVICES=2 python demo/restoration_demo.py expedsr/edsrconfigs/edsr01.py expedsr/real_train/iter_200000.pth expedvr/testimg2/testlr1.png demo/demoo.png
A part of the test set can run normally, but some errors are:
Use load_from_local loader
Traceback (most recent call last):
File "demo/restoration_demo.py", line 46, in
I have solved this problem. the mmediting/mmedit/datasets/pipelines/normlization.py ,in the class RescaleToZeroOne: the results dict has different 'lq' shape while running different imgs. add this :
class RescaleToZeroOne: """Transform the images into a range between 0 and 1.
Required keys are the keys in attribute "keys", added or modified keys are
the keys in attribute "keys".
It also supports rescaling a list of images.
Args:
keys (Sequence[str]): The images to be transformed.
"""
def __init__(self, keys):
self.keys = keys
def __call__(self, results):
"""Call function.
Args:
results (dict): A dict containing the necessary information and
data for augmentation.
Returns:
dict: A dict containing the processed data and information.
"""
for key in self.keys:
if isinstance(results[key], list):
results[key] = [
v.astype(np.float32) / 255. for v in results[key]
]
else:
#print('same')
results[key] = results[key].astype(np.float32) / 255.
####################################### #这里的结果results就已经不一样了,多了一层,添加判断 #print( results.keys())#result.keys='lq_path','lq','lq_ori_shape'#the lq_ori_shape' should be (H,W,3),get (H,W,4) if (results['lq_ori_shape'][2]==3): pass
else:
results['lq']=results['lq'][:,:,0:3]
return results
####################################### def repr(self): return self.class.name + f'(keys={self.keys})'
Hello, do you mean that you encountered an error when the input has 4 channels?
the input imgs has 3 channels,but get 4 channels results durning normlization
the input imgs has 3 channels,but get 4 channels results durning normlization
If this is the case, I guess all images will cause the error? But it seems that it works for most images (at least during training).
the input imgs has 3 channels,but get 4 channels results durning normlization
If this is the case, I guess all images will cause the error? But it seems that it works for most images (at least during training).
Yes, there is no error during the training process. Some pictures can also run normally when running the demo, but some pictures will report errors. the results['lq'] has a fourth element which is 1.0
the input imgs has 3 channels,but get 4 channels results durning normlization
If this is the case, I guess all images will cause the error? But it seems that it works for most images (at least during training).
Yes, there is no error during the training process. Some pictures can also run normally when running the demo, but some pictures will report errors. the results['lq'] has a fourth element which is 1.0
Could you help have a look at the image that gives you this error? For example, maybe this image itself has 4 channels?
I think there must be something this image is different from the others.
the input img's shape is both 100,100,3 and the dtype of it is both uint8
As RescaleToZeroOne
does only a division, I think it will not give you an additional channel. It is probably that results['lq']
has 4 channels before entering RescaleToZeroOne
.
@dzz416 If an image whose format is png
, it may have a hidden channel: alpha
.
I think you can check the channel number of images by
img=cv2.imread('path', flag=cv2.IMREAD_UNCHANGED)
print(img.shape)
PS:
cv2.IMREAD_COLOR
will ignore the alpha
channel.
Closing this Issue due to no more feedback. Please feel free to reopen it if needed.