New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inference single custom images #8
Comments
what error do you get?
should be
|
Sorry, that is a typo. thank for your helping |
If you're testing on a image from a different dataset, then there's no guarantee the result is going to be useful. |
appreciated your response. Thanks so much. |
Your pre-process of input image is different from the ours. |
Thanks for your response. appreciated!!! |
Congratulations. 😁 |
I'm struggling with inferencing my custom image. |
you can refer to this code: https://github.com/Turoad/lanedet/blob/main/tools/detect.py |
Hi there,
Thanks your code,
I want to inference any custom image which is not in Tusimple dataset.
The following is my code:
import torch
import cv2
import torch.nn.functional as F
from models.resa import RESANet
from utils.config import Config
from datasets import build_dataloader
from models.registry import build_net
from PIL import Image
import utils.transforms as tf
from torch.autograd import Variable
from torchvision.utils import save_image
import torchvision.transforms as transforms
loader1 = transforms.Compose([transforms.ToTensor(),
transforms.Normalize((103.939, 116.779, 123.68), (1., 1., 1.)),
transforms.Resize((368,640)),]) # for tusimple
def image_loader(image_name):
"""load image, return cuda tensor"""
image = Image.open(image_name)
image = loader1(image).float()
image = Variable(image, requires_grad=True)
image = image.unsqueeze(0)
return image.cuda()
cfg = Config.fromfile('configs/tusimple.py')
resa = build_net(cfg)
resa = torch.nn.parallel.DataParallel(
resa, device_ids = range(1)).cuda()
loader = build_dataloader(cfg.dataset.val, cfg, is_train=False)
pretrained_model = torch.load('tusimple_resnet34.pth')
resa.load_state_dict(pretrained_model['net'], strict=True)
x = image_loader('./20.jpg') # 20.jpg is copied from tusimple test datasets
with torch.no_grad():
out = resa(x)
probmap, exist = out['seg'], out['exist']
probmap = F.softmax(probmap, dim=1).squeeze().cpu().numpy()
exist = exist.squeeze().cpu().numpy()
coords = loader.dataset.probmap2lane(probmap, exist)
img = cv2.imread('./20.jpg')
loader.dataset.view(img, coords, './test.png')
The result is not as good as choose from x = loader.dataset[img_idx]['img'].unsqueeze(0).cuda()
Can you help that?
thanks so much.
The text was updated successfully, but these errors were encountered: