Ultra-Fast-Lane-Detection测试1920*1080视频

news/2024/10/17 16:32:48/

项目地址:https://github.com/cfzd/Ultra-Fast-Lane-Detection
issue中作者回答了很多训练数据集及检测其他视频的回答

作者知乎文章:https://zhuanlan.zhihu.com/p/157530787

仅修改demo程序以适用于1920*1080分辨率视频。测试使用,如需更好效果应修改源程序并重新训练模型。

1.修改 demo.py

import torch, os
import cv2
from model.model import parsingNet
from utils.common import merge_config
from utils.dist_utils import dist_print
import torch
import scipy.special, tqdm
import numpy as np
import torchvision.transforms as transforms
from data.dataset import LaneTestDataset
from data.constant import culane_row_anchor, tusimple_row_anchorif __name__ == "__main__":torch.backends.cudnn.benchmark = Trueargs, cfg = merge_config()dist_print('start testing...')assert cfg.backbone in ['18','34','50','101','152','50next','101next','50wide','101wide']if cfg.dataset == 'CULane':cls_num_per_lane = 18elif cfg.dataset == 'Tusimple':cls_num_per_lane = 56else:raise NotImplementedErrornet = parsingNet(pretrained = False, backbone=cfg.backbone,cls_dim = (cfg.griding_num+1,cls_num_per_lane,4),use_aux=False).cuda() # we dont need auxiliary segmentation in testingstate_dict = torch.load(cfg.test_model, map_location='cpu')['model']compatible_state_dict = {}for k, v in state_dict.items():if 'module.' in k:compatible_state_dict[k[7:]] = velse:compatible_state_dict[k] = vnet.load_state_dict(compatible_state_dict, strict=False)net.eval()img_transforms = transforms.Compose([#transforms.CenterCrop((590,1640)),transforms.Resize((288, 800)),transforms.ToTensor(),transforms.Normalize((0.485, 0.456, 0.406), (0.229, 0.224, 0.225)),])cap = cv2.VideoCapture("your-test-video.mp4")fourcc = cv2.VideoWriter_fourcc(*'MJPG')rval,frame = cap.read()frame = frame[490:1080,0:1640,:]vout = cv2.VideoWriter('output.avi', fourcc , 30.0, (frame.shape[1],frame.shape[0]))print("w= {},h = {}".format(cap.get(3),cap.get(4)))from PIL import Imageprint('加载CUDA是否成功:',torch.cuda.is_available())while 1:rval,frame = cap.read()if rval == False:breakframe = frame[490:1080,0:1640,:]img = cv2.cvtColor(frame,cv2.COLOR_BGR2RGB)img_ = Image.fromarray(img)imgs = img_transforms(img_)imgs = imgs.unsqueeze(0)imgs = imgs.cuda()with torch.no_grad():out = net(imgs)col_sample = np.linspace(0, 800 - 1, cfg.griding_num)col_sample_w = col_sample[1] - col_sample[0]out_j = out[0].data.cpu().numpy()out_j = out_j[:, ::-1, :]prob = scipy.special.softmax(out_j[:-1, :, :], axis=0)idx = np.arange(cfg.griding_num) + 1idx = idx.reshape(-1, 1, 1)loc = np.sum(prob * idx, axis=0)out_j = np.argmax(out_j, axis=0)loc[out_j == cfg.griding_num] = 0out_j = locfor i in range(out_j.shape[1]):if np.sum(out_j[:, i] != 0) > 2:for k in range(out_j.shape[0]):if out_j[k, i] > 0:ppp = (int(out_j[k, i] * col_sample_w * frame.shape[1] / 800) - 1, int(frame.shape[0] - k * 20) - 1)cv2.circle(frame,ppp,5,(0,255,0),-1)vout.write(frame)vout.release()

2.测试

python demo.py configs/culane.py --test_model path_to_culane_18.pth

在这里插入图片描述


http://www.ppmy.cn/news/126463.html

相关文章

1920像素的屏幕在部分浏览器(chrome,IE等)中只有1536px解决办法

1920像素的屏幕在部分浏览器(chrome,IE等)中只有1536px解决办法 在桌面右键->显示设置,将缩放改为100%。 PC端多屏适配方案请查看这篇文章:https://blog.csdn.net/qq_16687863/article/details/106449461

1920*1080 网页使用scale在其他分辨率或宽度下等比例缩放

一、效果图&#xff1a;1920*1080全屏及非全屏 二、效果图&#xff1a;2880*1800全屏及非全屏 三、代码 <!DOCTYPE html> <html lang"en"><head><meta charset"UTF-8" /><meta http-equiv"X-UA-Compatible" content…

解决1920 * 1080笔记本字体模糊问题

解决1920 * 1080笔记本字体模糊问题 字体模糊是因为分辨率缩放比不能很好的将字体整数缩放. 那么应该怎么解决这个问题呢? 1920 * 1080台式电脑的缩放比为100% 但是如果笔记本用100%的缩放比,图标和文字都会变得非常小. 这个容易解决只要将字体和图标放大就好了. 但是又会面临…

vue项目1920和1280像素切换

我们开发过程中一般设计图的尺寸都是在1920*1080。 但是开发过程中&#xff0c;很多人用的分辨率配置是150%的&#xff0c;就是说浏览器的尺寸已经变成个1280*720 这个时候不仅仅开发遇到了滚动条的问题&#xff0c;同样要考虑到有的用户是1280*720那就左右都有滚动条的话&am…

Ubuntu18.04调整屏幕分辨率至1920*1080

Ubuntu18.04调整屏幕分辨率至1920*1080 文章目录 Ubuntu18.04调整屏幕分辨率至1920*1080前言&#xff1a;参考链接&#xff1a;详细步骤&#xff1a; 前言&#xff1a; 当服务器插上了小分辨率的显示器之后&#xff0c;远程登录拿到的界面竟然也是小的&#xff0c;而且无法通过…

centos7新增分辨率 1920 1080 ,网上各种方法大罗列!(亲测针对不同设备,有的有用!有的......)

谨记&#xff01; 不要照着网上的显示屏瞎改&#xff01;&#xff0c;看自己的配置 步骤总结如下&#xff1a; cvt 1920 1080xrandr --newmode " 1920x1080_60.00"173.0019202048 2248 2576 1080 1083 1088 1120 - hsync vsyncxrandr --addmode VGA-1 “1920x1080_…

深度linux新增分辨率,深度Linux Deepin设置分辨率为1920x1080

Deepin操作系统手动设置分辨率为1920x1080 0X00起因 本小白初次安装Deepin&#xff0c;是安装在了虚拟机里面。不过呢&#xff0c;安装玩发现分辨率不对。不是1920x1080而且显示设置里也没有1920x1080&#xff0c;于是乎&#xff0c;开始找解决方法。 0X01开始手动设置分辨率 首…

安装office未能启动服务器,Office 2010安装时遇到1920错误问题怎么解决?

在尝试安装Office 2010时&#xff0c;可能会收到如下错误信息&#xff1a;错误1920.未能启动服务“Office Software Protection Platform”(osppsvc)请确认您有足够的权限启动系统服务。如何才能解决这个问题呢&#xff1f; Office 2010 是微软最新推出的智能商务办公软件&…