GeoProj icon indicating copy to clipboard operation
GeoProj copied to clipboard

Problems with resampling

Open jingaoyin opened this issue 4 years ago • 6 comments

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.

jingaoyin avatar Sep 21 '21 10:09 jingaoyin

Hello, which version of tensorflow compatible environment needs to be configured, and has your problem been solved? Thank you very much!

hanchengyu3 avatar Oct 14 '21 06:10 hanchengyu3

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 ?

nikhilparmar avatar Dec 09 '21 15:12 nikhilparmar

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}) `

ZarrarAhmedKhan avatar Mar 11 '22 11:03 ZarrarAhmedKhan

Hi, I don't have a GPU available. How can I make it work? I get error with cuda in the resampling file ... @xiaoyu258

faviasono avatar Mar 15 '23 17:03 faviasono

Hi, I meet a bug during resampling.py as follow: Traceback (most recent call last): File "resampling.py", line 209, in resImg, resMsk = rectification(distortedImg, flow) File "resampling.py", line 194, in rectification iterSearch[blockspergrid, threadsperblock](padu, padv, paddistorted, resultImg, maxIter, precision, resultMsk) File "/home/liaozk/anaconda3/lib/python3.8/site-packages/numba/cuda/compiler.py", line 833, in call kernel = self.specialize(*args) File "/home/liaozk/anaconda3/lib/python3.8/site-packages/numba/cuda/compiler.py", line 844, in specialize kernel = self.compile(argtypes) File "/home/liaozk/anaconda3/lib/python3.8/site-packages/numba/cuda/compiler.py", line 863, in compile kernel.bind() File "/home/liaozk/anaconda3/lib/python3.8/site-packages/numba/cuda/compiler.py", line 604, in bind self._func.get() File "/home/liaozk/anaconda3/lib/python3.8/site-packages/numba/cuda/compiler.py", line 480, in get ptx = self.ptx.get() File "/home/liaozk/anaconda3/lib/python3.8/site-packages/numba/cuda/compiler.py", line 450, in get ptx = nvvm.llvm_to_ptx(self.llvmir, opt=3, arch=arch, File "/home/liaozk/anaconda3/lib/python3.8/site-packages/numba/cuda/cudadrv/nvvm.py", line 515, in llvm_to_ptx ptx = cu.compile(**opts) File "/home/liaozk/anaconda3/lib/python3.8/site-packages/numba/cuda/cudadrv/nvvm.py", line 232, in compile self._try_error(err, 'Failed to compile\n') File "/home/liaozk/anaconda3/lib/python3.8/site-packages/numba/cuda/cudadrv/nvvm.py", line 250, in _try_error self.driver.check_error(err, "%s\n%s" % (msg, self.get_log())) File "/home/liaozk/anaconda3/lib/python3.8/site-packages/numba/cuda/cudadrv/nvvm.py", line 140, in check_error raise exc numba.cuda.cudadrv.error.NvvmError: Failed to compile (26, 54): parse expected comma after getelementptr's type NVVM_ERROR_COMPILATION @xiaoyu258

lzk9508 avatar Jun 15 '23 06:06 lzk9508

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

psj-yyds avatar Jun 29 '23 14:06 psj-yyds