UPSNet icon indicating copy to clipboard operation
UPSNet copied to clipboard

test my images error

Open lfdeep opened this issue 5 years ago • 38 comments

How to test my images?

lfdeep avatar Jun 06 '19 11:06 lfdeep

@lfdeep have u solved this problem? I want to test my own pictures too .

EchoAmor avatar Jun 21 '19 08:06 EchoAmor

I write inference.py according to author's test code. But when visualize, the author code is a bit wrong, and now I am debugging the code in the visualization section.

@lfdeep have u solved this problem? I want to test my own pictures too .

lfdeep avatar Jun 21 '19 08:06 lfdeep

will u upload your code when you solve this problem ? I am not so good at coding now, I would very appreciate it if u can share ! Thanks very much ! @lfdeep

EchoAmor avatar Jun 21 '19 08:06 EchoAmor

will u upload your code when you solve this problem ? I am not so good at coding now, I would very appreciate it if u can share ! Thanks very much ! @lfdeep

Yes,Can you give me your contact information?

lfdeep avatar Jun 21 '19 08:06 lfdeep

@lfdeep yeah my email is [email protected], thanks very much!

EchoAmor avatar Jun 21 '19 08:06 EchoAmor

@lfdeep , I am also trying to test on my image. It would be helpful if you share your inference code at [email protected]

dipanjan06 avatar Jul 01 '19 07:07 dipanjan06

@lfdeep , I am also trying to test on my image. It would be helpful if you share your inference code at [email protected]

hello,I will sort out the inference and visualization code and send it to you.

lfdeep avatar Jul 01 '19 10:07 lfdeep

@lfdeep Hey man can you share link to your inference code, I am trying one myself facing some difficulties.

gaussiangit avatar Jul 08 '19 14:07 gaussiangit

@lfdeep , I met with the same problem here. Could you please share your inference and visualization code? It would be really appreciated. My email is [email protected]. Thank you in advance.

ShiweiJin avatar Jul 10 '19 06:07 ShiweiJin

@lfdeep Hey man can you share link to your inference code, I am trying one myself facing some difficulties.

Can you give me your email?

lfdeep avatar Jul 10 '19 09:07 lfdeep

@lfdeep [email protected] Thanks

gaussiangit avatar Jul 10 '19 11:07 gaussiangit

@lfdeep [email protected] Thank you very much

mumuyanyan avatar Jul 10 '19 15:07 mumuyanyan

@lfdeep [email protected] Can you please send me the inference code as well ? Thanks a lot.

phongnhhn92 avatar Jul 14 '19 16:07 phongnhhn92

Hi @lfdeep, Could you send me your inference code, please? Thank you so much. [email protected]

manueldiduch avatar Jul 14 '19 19:07 manueldiduch

@lfdeep any update ? thanks

gaussiangit avatar Jul 15 '19 11:07 gaussiangit

@lfdeep hi,I met the same problem, could you share the code with me, please? Thanks very much ![email protected]

6216 avatar Jul 17 '19 02:07 6216

import os import torch import torch.nn as nn import argparse import cv2 import numpy as np

from upsnet.config.config import * from upsnet.config.parse_args import parse_args

from upsnet.models import *

from PIL import Image, ImageDraw

def get_pallete():

pallete_raw = np.zeros((256, 3)).astype('uint8')
pallete = np.zeros((256, 3)).astype('uint8')

pallete_raw[5, :] =  [111,  74,   0]
pallete_raw[6, :] =  [ 81,   0,  81]
pallete_raw[7, :] =  [128,  64, 128]
pallete_raw[8, :] =  [244,  35, 232]
pallete_raw[9, :] =  [250, 170, 160]
pallete_raw[10, :] = [230, 150, 140]
pallete_raw[11, :] = [ 70,  70,  70]
pallete_raw[12, :] = [102, 102, 156]
pallete_raw[13, :] = [190, 153, 153]
pallete_raw[14, :] = [180, 165, 180]
pallete_raw[15, :] = [150, 100, 100]
pallete_raw[16, :] = [150, 120,  90]
pallete_raw[17, :] = [153, 153, 153]
pallete_raw[18, :] = [153, 153, 153]
pallete_raw[19, :] = [250, 170,  30]
pallete_raw[20, :] = [220, 220,   0]
pallete_raw[21, :] = [107, 142,  35]
pallete_raw[22, :] = [152, 251, 152]
pallete_raw[23, :] = [ 70, 130, 180]
pallete_raw[24, :] = [220,  20,  60]
pallete_raw[25, :] = [255,   0,   0]
pallete_raw[26, :] = [  0,   0, 142]
pallete_raw[27, :] = [  0,   0,  70]
pallete_raw[28, :] = [  0,  60, 100]
pallete_raw[29, :] = [  0,   0,  90]
pallete_raw[30, :] = [  0,   0, 110]
pallete_raw[31, :] = [  0,  80, 100]
pallete_raw[32, :] = [  0,   0, 230]
pallete_raw[33, :] = [119,  11,  32]

train2regular = [7, 8, 11, 12, 13, 17, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 31, 32, 33]

for i in range(len(train2regular)):
    pallete[i, :] = pallete_raw[train2regular[i], :]

pallete = pallete.reshape(-1)

# return pallete_raw
return pallete

parser = argparse.ArgumentParser() args, rest = parser.parse_known_args() args.cfg = "/home/cicv/UPSNet-master/upsnet/experiments/upsnet_resnet50_cityscapes_16gpu.yaml" args.weight_path = "/home/cicv/UPSNet-master/model/upsnet_resnet_50_cityscapes_12000.pth" args.eval_only = "Ture" update_config(args.cfg)

test_model = eval("resnet_50_upsnet")().cuda() test_model.load_state_dict(torch.load(args.weight_path))

#print(test_model)

for p in test_model.parameters(): p.requires_grad = False

test_model.eval()

im = cv2.imread("lindau_000000_000019_leftImg8bit.png") im_resize = cv2.resize(im,(2048,1024),interpolation=cv2.INTER_CUBIC) im_resize = im_resize.transpose(2, 0, 1)

im_tensor = torch.from_numpy(im_resize) im_tensor =torch.unsqueeze(im_tensor,0).type(torch.FloatTensor).cuda() print(im_tensor.shape) # torch.Size([1, 3, 1024, 2048])

test_fake_numpy_data = np.random.rand(1,3) data = {'data': im_tensor , 'im_info' : test_fake_numpy_data} print(data['im_info']) output = test_model(data) #print(output) print(output['fcn_outputs'])

pallete = get_pallete() segmentation_result = np.uint8(np.squeeze(np.copy(output['fcn_outputs']))) segmentation_result = Image.fromarray(segmentation_result) segmentation_result.putpalette(pallete) segmentation_result = segmentation_result.resize((im.shape[1],im.shape[0])) segmentation_result.save("hello_result.png")

AI-liu avatar Jul 19 '19 01:07 AI-liu

you can change to your image. im = cv2.imread("lindau_000000_000019_leftImg8bit.png")

im = cv2.imread("your_imgae_XXXX.png")

------------------ 原始邮件 ------------------ 发件人: "lfdeep"[email protected]; 发送时间: 2019年7月19日(星期五) 上午10:11 收件人: "uber-research/UPSNet"[email protected]; 抄送: "136758759"[email protected];"Comment"[email protected]; 主题: Re: [uber-research/UPSNet] test my images error (#56)

import os import torch import torch.nn as nn import argparse import cv2 import numpy as np

from upsnet.config.config import * from upsnet.config.parse_args import parse_args

from upsnet.models import *

from PIL import Image, ImageDraw

def get_pallete(): pallete_raw = np.zeros((256, 3)).astype('uint8') pallete = np.zeros((256, 3)).astype('uint8') pallete_raw[5, :] = [111, 74, 0] pallete_raw[6, :] = [ 81, 0, 81] pallete_raw[7, :] = [128, 64, 128] pallete_raw[8, :] = [244, 35, 232] pallete_raw[9, :] = [250, 170, 160] pallete_raw[10, :] = [230, 150, 140] pallete_raw[11, :] = [ 70, 70, 70] pallete_raw[12, :] = [102, 102, 156] pallete_raw[13, :] = [190, 153, 153] pallete_raw[14, :] = [180, 165, 180] pallete_raw[15, :] = [150, 100, 100] pallete_raw[16, :] = [150, 120, 90] pallete_raw[17, :] = [153, 153, 153] pallete_raw[18, :] = [153, 153, 153] pallete_raw[19, :] = [250, 170, 30] pallete_raw[20, :] = [220, 220, 0] pallete_raw[21, :] = [107, 142, 35] pallete_raw[22, :] = [152, 251, 152] pallete_raw[23, :] = [ 70, 130, 180] pallete_raw[24, :] = [220, 20, 60] pallete_raw[25, :] = [255, 0, 0] pallete_raw[26, :] = [ 0, 0, 142] pallete_raw[27, :] = [ 0, 0, 70] pallete_raw[28, :] = [ 0, 60, 100] pallete_raw[29, :] = [ 0, 0, 90] pallete_raw[30, :] = [ 0, 0, 110] pallete_raw[31, :] = [ 0, 80, 100] pallete_raw[32, :] = [ 0, 0, 230] pallete_raw[33, :] = [119, 11, 32] train2regular = [7, 8, 11, 12, 13, 17, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 31, 32, 33] for i in range(len(train2regular)): pallete[i, :] = pallete_raw[train2regular[i], :] pallete = pallete.reshape(-1) # return pallete_raw return pallete
parser = argparse.ArgumentParser() args, rest = parser.parse_known_args() args.cfg = "/home/cicv/UPSNet-master/upsnet/experiments/upsnet_resnet50_cityscapes_16gpu.yaml" args.weight_path = "/home/cicv/UPSNet-master/model/upsnet_resnet_50_cityscapes_12000.pth" args.eval_only = "Ture" update_config(args.cfg)

test_model = eval("resnet_50_upsnet")().cuda() test_model.load_state_dict(torch.load(args.weight_path))

#print(test_model)

for p in test_model.parameters(): p.requires_grad = False

test_model.eval()

im = cv2.imread("lindau_000000_000019_leftImg8bit.png") im_resize = cv2.resize(im,(2048,1024),interpolation=cv2.INTER_CUBIC) im_resize = im_resize.transpose(2, 0, 1)

im_tensor = torch.from_numpy(im_resize) im_tensor =torch.unsqueeze(im_tensor,0).type(torch.FloatTensor).cuda() print(im_tensor.shape) # torch.Size([1, 3, 1024, 2048])

test_fake_numpy_data = np.random.rand(1,3) data = {'data': im_tensor , 'im_info' : test_fake_numpy_data} print(data['im_info']) output = test_model(data) #print(output) print(output['fcn_outputs'])

pallete = get_pallete() segmentation_result = np.uint8(np.squeeze(np.copy(output['fcn_outputs']))) segmentation_result = Image.fromarray(segmentation_result) segmentation_result.putpalette(pallete) segmentation_result = segmentation_result.resize((im.shape[1],im.shape[0])) segmentation_result.save("hello_result.png")

this only test cityscaspes model!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

AI-liu avatar Jul 19 '19 10:07 AI-liu

you can change to your image. im = cv2.imread("lindau_000000_000019_leftImg8bit.png") im = cv2.imread("your_imgae_XXXX.png") ------------------ 原始邮件 ------------------ 发件人: "lfdeep"[email protected]; 发送时间: 2019年7月19日(星期五) 上午10:11 收件人: "uber-research/UPSNet"[email protected]; 抄送: "136758759"[email protected];"Comment"[email protected]; 主题: Re: [uber-research/UPSNet] test my images error (#56) import os import torch import torch.nn as nn import argparse import cv2 import numpy as np from upsnet.config.config import * from upsnet.config.parse_args import parse_args from upsnet.models import * from PIL import Image, ImageDraw def get_pallete(): pallete_raw = np.zeros((256, 3)).astype('uint8') pallete = np.zeros((256, 3)).astype('uint8') pallete_raw[5, :] = [111, 74, 0] pallete_raw[6, :] = [ 81, 0, 81] pallete_raw[7, :] = [128, 64, 128] pallete_raw[8, :] = [244, 35, 232] pallete_raw[9, :] = [250, 170, 160] pallete_raw[10, :] = [230, 150, 140] pallete_raw[11, :] = [ 70, 70, 70] pallete_raw[12, :] = [102, 102, 156] pallete_raw[13, :] = [190, 153, 153] pallete_raw[14, :] = [180, 165, 180] pallete_raw[15, :] = [150, 100, 100] pallete_raw[16, :] = [150, 120, 90] pallete_raw[17, :] = [153, 153, 153] pallete_raw[18, :] = [153, 153, 153] pallete_raw[19, :] = [250, 170, 30] pallete_raw[20, :] = [220, 220, 0] pallete_raw[21, :] = [107, 142, 35] pallete_raw[22, :] = [152, 251, 152] pallete_raw[23, :] = [ 70, 130, 180] pallete_raw[24, :] = [220, 20, 60] pallete_raw[25, :] = [255, 0, 0] pallete_raw[26, :] = [ 0, 0, 142] pallete_raw[27, :] = [ 0, 0, 70] pallete_raw[28, :] = [ 0, 60, 100] pallete_raw[29, :] = [ 0, 0, 90] pallete_raw[30, :] = [ 0, 0, 110] pallete_raw[31, :] = [ 0, 80, 100] pallete_raw[32, :] = [ 0, 0, 230] pallete_raw[33, :] = [119, 11, 32] train2regular = [7, 8, 11, 12, 13, 17, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 31, 32, 33] for i in range(len(train2regular)): pallete[i, :] = pallete_raw[train2regular[i], :] pallete = pallete.reshape(-1) # return pallete_raw return pallete parser = argparse.ArgumentParser() args, rest = parser.parse_known_args() args.cfg = "/home/cicv/UPSNet-master/upsnet/experiments/upsnet_resnet50_cityscapes_16gpu.yaml" args.weight_path = "/home/cicv/UPSNet-master/model/upsnet_resnet_50_cityscapes_12000.pth" args.eval_only = "Ture" update_config(args.cfg) test_model = eval("resnet_50_upsnet")().cuda() test_model.load_state_dict(torch.load(args.weight_path)) #print(test_model) for p in test_model.parameters(): p.requires_grad = False test_model.eval() im = cv2.imread("lindau_000000_000019_leftImg8bit.png") im_resize = cv2.resize(im,(2048,1024),interpolation=cv2.INTER_CUBIC) im_resize = im_resize.transpose(2, 0, 1) im_tensor = torch.from_numpy(im_resize) im_tensor =torch.unsqueeze(im_tensor,0).type(torch.FloatTensor).cuda() print(im_tensor.shape) # torch.Size([1, 3, 1024, 2048]) test_fake_numpy_data = np.random.rand(1,3) data = {'data': im_tensor , 'im_info' : test_fake_numpy_data} print(data['im_info']) output = test_model(data) #print(output) print(output['fcn_outputs']) pallete = get_pallete() segmentation_result = np.uint8(np.squeeze(np.copy(output['fcn_outputs']))) segmentation_result = Image.fromarray(segmentation_result) segmentation_result.putpalette(pallete) segmentation_result = segmentation_result.resize((im.shape[1],im.shape[0])) segmentation_result.save("hello_result.png") this only test cityscaspes model! — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

thanks! this code only test cityscapes model! Classes of cityscapes is less than coco. i have soved this problem and can test coco model.

lfdeep avatar Jul 19 '19 10:07 lfdeep

thanks for your code.Thanks so much.

| | 王佳琪 | | 邮箱:[email protected] |

签名由 网易邮箱大师 定制

On 07/19/2019 18:21, lfdeep wrote:

you can change to your image. im = cv2.imread("lindau_000000_000019_leftImg8bit.png") im = cv2.imread("your_imgae_XXXX.png") … ------------------ 原始邮件 ------------------ 发件人: "lfdeep"[email protected]; 发送时间: 2019年7月19日(星期五) 上午10:11 收件人: "uber-research/UPSNet"[email protected]; 抄送: "136758759"[email protected];"Comment"[email protected]; 主题: Re: [uber-research/UPSNet] test my images error (#56) import os import torch import torch.nn as nn import argparse import cv2 import numpy as np from upsnet.config.config import * from upsnet.config.parse_args import parse_args from upsnet.models import * from PIL import Image, ImageDraw def get_pallete(): pallete_raw = np.zeros((256, 3)).astype('uint8') pallete = np.zeros((256, 3)).astype('uint8') pallete_raw[5, :] = [111, 74, 0] pallete_raw[6, :] = [ 81, 0, 81] pallete_raw[7, :] = [128, 64, 128] pallete_raw[8, :] = [244, 35, 232] pallete_raw[9, :] = [250, 170, 160] pallete_raw[10, :] = [230, 150, 140] pallete_raw[11, :] = [ 70, 70, 70] pallete_raw[12, :] = [102, 102, 156] pallete_raw[13, :] = [190, 153, 153] pallete_raw[14, :] = [180, 165, 180] pallete_raw[15, :] = [150, 100, 100] pallete_raw[16, :] = [150, 120, 90] pallete_raw[17, :] = [153, 153, 153] pallete_raw[18, :] = [153, 153, 153] pallete_raw[19, :] = [250, 170, 30] pallete_raw[20, :] = [220, 220, 0] pallete_raw[21, :] = [107, 142, 35] pallete_raw[22, :] = [152, 251, 152] pallete_raw[23, :] = [ 70, 130, 180] pallete_raw[24, :] = [220, 20, 60] pallete_raw[25, :] = [255, 0, 0] pallete_raw[26, :] = [ 0, 0, 142] pallete_raw[27, :] = [ 0, 0, 70] pallete_raw[28, :] = [ 0, 60, 100] pallete_raw[29, :] = [ 0, 0, 90] pallete_raw[30, :] = [ 0, 0, 110] pallete_raw[31, :] = [ 0, 80, 100] pallete_raw[32, :] = [ 0, 0, 230] pallete_raw[33, :] = [119, 11, 32] train2regular = [7, 8, 11, 12, 13, 17, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 31, 32, 33] for i in range(len(train2regular)): pallete[i, :] = pallete_raw[train2regular[i], :] pallete = pallete.reshape(-1) # return pallete_raw return pallete parser = argparse.ArgumentParser() args, rest = parser.parse_known_args() args.cfg = "/home/cicv/UPSNet-master/upsnet/experiments/upsnet_resnet50_cityscapes_16gpu.yaml" args.weight_path = "/home/cicv/UPSNet-master/model/upsnet_resnet_50_cityscapes_12000.pth" args.eval_only = "Ture" update_config(args.cfg) test_model = eval("resnet_50_upsnet")().cuda() test_model.load_state_dict(torch.load(args.weight_path)) #print(test_model) for p in test_model.parameters(): p.requires_grad = False test_model.eval() im = cv2.imread("lindau_000000_000019_leftImg8bit.png") im_resize = cv2.resize(im,(2048,1024),interpolation=cv2.INTER_CUBIC) im_resize = im_resize.transpose(2, 0, 1) im_tensor = torch.from_numpy(im_resize) im_tensor =torch.unsqueeze(im_tensor,0).type(torch.FloatTensor).cuda() print(im_tensor.shape) # torch.Size([1, 3, 1024, 2048]) test_fake_numpy_data = np.random.rand(1,3) data = {'data': im_tensor , 'im_info' : test_fake_numpy_data} print(data['im_info']) output = test_model(data) #print(output) print(output['fcn_outputs']) pallete = get_pallete() segmentation_result = np.uint8(np.squeeze(np.copy(output['fcn_outputs']))) segmentation_result = Image.fromarray(segmentation_result) segmentation_result.putpalette(pallete) segmentation_result = segmentation_result.resize((im.shape[1],im.shape[0])) segmentation_result.save("hello_result.png") this only test cityscaspes model! — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

thanks! this code only test cityscapes model! Classes of cityscapes is less than coco. i have soved this problem and can test coco model.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

6216 avatar Jul 19 '19 10:07 6216

@lfdeep , I am also trying to test on my image. It would be helpful if you share your inference code at [email protected]

jshi31 avatar Aug 08 '19 19:08 jshi31

@lfdeep , i am facing the same problem, could you share your inference code for coco dataset for me? thank you very much. my email : [email protected]

SunNYNO1 avatar Nov 28 '19 17:11 SunNYNO1

[email protected]

Already sent

lfdeep avatar Nov 29 '19 04:11 lfdeep

@lfdeep could you send me as well ? my email id is [email protected] thanks

discretecoder avatar Nov 29 '19 10:11 discretecoder

@lfdeep could you send me as well ? my email id is [email protected] thanks

Already sent

lfdeep avatar Nov 29 '19 10:11 lfdeep

[email protected]

Already sent

Sorry, I didn't receive your email, could you send me again? please send to this email:[email protected], thank you very much.

SunNYNO1 avatar Nov 29 '19 11:11 SunNYNO1

@lfdeep could you send me as well ? my email id is [email protected] thank you very much ~-~

WindAndCloud avatar Nov 30 '19 12:11 WindAndCloud

@lfdeep thanks, could you send me as well? my email id is [email protected]

Scharduldeshpande avatar Dec 03 '19 08:12 Scharduldeshpande

@lfdeep could you send me as well? my email id is [email protected]. thanks a lot!

ywher avatar Mar 02 '20 08:03 ywher

@lfdeep could you send me a copy of your code for panoptic segmentation as well? [email protected] Thanks a lot !

squashking avatar May 20 '20 23:05 squashking