Open jingaoyin opened 2 years ago
Hello, which version of tensorflow compatible environment needs to be configured, and has your problem been solved? Thank you very much!
Thank you for the source code,They're really good. But when I run the resampling code,The entire compressed file was found to be missing flow.npy,I wonder what kind of document this is,If it is a pre-trained model, the address you provided is no longer available for download, And how to use .pkl that you have trained. Thank you so much for watching,And give me some help.
Hi, did you find the flow.npy file ?
run this eval.py @nikhilparmar
change these
testImgPath = 'images/' saveFlowPath = 'outputs' image_name
`import torch from torch.autograd import Variable import torch.nn as nn import skimage import skimage.io as io from torchvision import transforms import numpy as np from PIL import Image import scipy.io as scio import cv2 from resample.resampling import rectification from modelNetM import EncoderNet, DecoderNet, ClassNet, EPELoss transform = transforms.Compose([transforms.ToTensor(), transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))]) model_en = EncoderNet([1,1,1,1,2]) model_de = DecoderNet([1,1,1,1,2]) model_class = ClassNet() if torch.cuda.device_count() > 1: print("Let's use", torch.cuda.device_count(), "GPUs!") model_en = nn.DataParallel(model_en) model_de = nn.DataParallel(model_de) model_class = nn.DataParallel(model_class) if torch.cuda.is_available(): model_en = model_en.cuda() model_de = model_de.cuda() model_class = model_class.cuda() model_en.load_state_dict(torch.load('models/model_en.pkl'), strict=False) model_de.load_state_dict(torch.load('models/model_de.pkl'), strict=False) model_class.load_state_dict(torch.load('models/model_class.pkl'), strict=False) model_en.eval() model_de.eval() model_class.eval()
testImgPath = 'images/' saveFlowPath = 'outputs'`
correct = 0
` for k in range(1):
image_name = "1.jpg"
imgPath = testImgPath + image_name
disimgs = io.imread(imgPath)
disimgs = Image.open(imgPath).convert('RGB')
im_npy = np.asarray(disimgs.resize((256, 256)))
# disimgs.astype(np.float32)
# disimgs = cv2.resize(disimgs,(256,256), np.float32)
disimgs = transform(disimgs)
use_GPU = torch.cuda.is_available()
if use_GPU:
disimgs = disimgs.cuda()
disimgs = disimgs.view(1,3,256,256)
disimgs = Variable(disimgs)
middle = model_en(disimgs)
flow_output = model_de(middle)
clas = model_class(middle)
_, predicted = torch.max(clas.data, 1)
if predicted.cpu().numpy()[0] == index:
correct += 1
u = flow_output.data.cpu().numpy()[0][0]
v = flow_output.data.cpu().numpy()[0][1]
multi = 2
resImg, resMsk = rectification(im_npy, flow_output.data.cpu().numpy()[0]*multi)
img_out = Image.fromarray(resImg)
img_out.save('outputs/' + 'res_' + image_name)
# saveMatPath = '%s%s%s%s%s%s' % (saveFlowPath, '/',types,'_', str(k).zfill(6), '.mat')
# scio.savemat(saveMatPath, {'u': u,'v': v}) `
Hi, I don't have a GPU available. How can I make it work? I get error with cuda in the resampling file ... @xiaoyu258
Hi, I meet a bug during resampling.py as follow:
Traceback (most recent call last):
File "resampling.py", line 209, in
run this eval.py
Thank you for your work, I also changed as you said, and ran eval.py only generated a picture, no .npy generated
Thank you for the source code,They're really good. But when I run the resampling code,The entire compressed file was found to be missing flow.npy,I wonder what kind of document this is,If it is a pre-trained model, the address you provided is no longer available for download, And how to use .pkl that you have trained. Thank you so much for watching,And give me some help.