-
Notifications
You must be signed in to change notification settings - Fork 219
Open
Description
i want to inference a photo,but it have a error, i need help,please to point my question of program.
`import cv2
import os
import numpy as np
os.environ['CUDA_VISIBLE_DEVICES']='0'
import torch
from basicsr.models import build_model
from basicsr.utils.options import parse_options
if name=='main':
opt, args = parse_options('.', is_train=False)
device = 'cuda:0'
opt['network_g']['img_size'] = 512 // 4
model = build_model(opt)
print(model.net_g)
model.net_g = model.net_g.to(device)
model.net_g.eval()
path = "codes/basicsr/123.png"
# try_input = torch.randn((1,3,32,32)).float().to(device)
img = cv2.imread(path, cv2.IMREAD_COLOR).astype(np.float32) / 255.
img = torch.from_numpy(np.transpose(img[:, :, [2, 1, 0]], (2, 0, 1))).float()
img = img.unsqueeze(0).to(device)
print(img.shape)
# with torch.no_grad():
output = model.net_g(img)
print(output.shape)
print(model.net_g.flops()/1e9)
# save image
output = output.data.squeeze().float().cpu().clamp_(0, 1).numpy()
output = np.transpose(output[[2, 1, 0], :, :], (1, 2, 0))
output = (output * 255.0).round().astype(np.uint8)
cv2.imwrite('IPG.png', output)`
Metadata
Metadata
Assignees
Labels
No labels

