HarukiYqM/Non-Local-Sparse-Attention

How to test my own images?

WellTung666 opened this issue · 3 comments

Hi, i want to test my owm images, but it always failed ,can you tell me how to set parameters? Thanks~

Hi, i want to test my owm images, but it always failed ,can you tell me how to set parameters? Thanks~

How to inference one image? When I try to inference on my own ToTensor code, it looks like not work .
`
sr_model = model.Model(args, checkpoint).cuda()

sr_model.eval()

img = cv2.imread('test2.jpg')

tensor = torch.from_numpy(img).float().permute(2, 0, 1)

tensor.mul_(1 / 255)

tensor = tensor.unsqueeze(0).cuda()

sr = sr_model(tensor, 0)

sr = quantize(sr,1)

normalized = sr.mul(255 / 1)

normalized = normalized.squeeze(0).permute(1, 2, 0).data.cpu().numpy()

cv2.imwrite('result.png',normalized)

`

Hi, i want to test my owm images, but it always failed ,can you tell me how to set parameters? Thanks~

How to inference one image? When I try to inference on my own ToTensor code, it looks like not work .
`
sr_model = model.Model(args, checkpoint).cuda()

sr_model.eval()

img = cv2.imread('test2.jpg')

tensor = torch.from_numpy(img).float().permute(2, 0, 1)

tensor.mul_(1 / 255)

tensor = tensor.unsqueeze(0).cuda()

sr = sr_model(tensor, 0)

sr = quantize(sr,1)

normalized = sr.mul(255 / 1)

normalized = normalized.squeeze(0).permute(1, 2, 0).data.cpu().numpy()

cv2.imwrite('result.png',normalized)

`

Sorry,I don't have time to test.
This is my test command:
'
python main.py --data_test Demo --dir_demo 'images dir' --chop --save_result --test_only --result 'save dir'
'
I think you can inference one image by modifying the code in here (/src/data/demo.py).

Add --dir_demo <input folder> and change --data_test Demo and the model name. You will be good to go.