当前位置: 首页 > news >正文

天池2023智能驾驶汽车虚拟仿真视频数据理解--baseline

baseline

  • 代码

代码

百度飞浆一键运行

import paddle
from PIL import Image
from clip import tokenize, load_model
import glob, json, os
import cv2
from PIL import Image
from tqdm import tqdm_notebook
import numpy as np
from sklearn.preprocessing import normalize
import matplotlib.pyplot as pltmodel, transforms = load_model('ViT_B_32', pretrained=True)en_match_words = {
"scerario" : ["suburbs","city street","expressway","tunnel","parking-lot","gas or charging stations","unknown"],
"weather" : ["clear","cloudy","raining","foggy","snowy","unknown"],
"period" : ["daytime","dawn or dusk","night","unknown"],
"road_structure" : ["normal","crossroads","T-junction","ramp","lane merging","parking lot entrance","round about","unknown"],
"general_obstacle" : ["nothing","speed bumper","traffic cone","water horse","stone","manhole cover","nothing","unknown"],
"abnormal_condition" : ["uneven","oil or water stain","standing water","cracked","nothing","unknown"],
"ego_car_behavior" : ["slow down","go straight","turn right","turn left","stop","U-turn","speed up","lane change","others"],
"closest_participants_type" : ["passenger car","bus","truck","pedestrain","policeman","nothing","others","unknown"],
"closest_participants_behavior" : ["slow down","go straight","turn right","turn left","stop","U-turn","speed up","lane change","others"],
}submit_json = {"author" : "abc" ,"time" : "231011","model" : "model_name","test_results" : []
}paths = glob.glob('./初赛测试视频/*')
paths.sort()for video_path in paths:print(video_path)clip_id = video_path.split('/')[-1]cap = cv2.VideoCapture(video_path)img = cap.read()[1]image = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)image = Image.fromarray(image)image = transforms(image).unsqueeze(0)single_video_result = {"clip_id": clip_id,"scerario" : "cityroad","weather":"unknown","period":"night","road_structure":"ramp","general_obstacle":"nothing","abnormal_condition":"nothing","ego_car_behavior":"turning right","closest_participants_type":"passenger car","closest_participants_behavior":"braking"}for keyword in en_match_words.keys():if keyword not in ["weather", "road_structure"]:continuetexts = np.array(en_match_words[keyword])with paddle.no_grad():logits_per_image, logits_per_text = model(image, tokenize(en_match_words[keyword]))probs = paddle.nn.functional.softmax(logits_per_image, axis=-1)probs = probs.numpy()        single_video_result[keyword] = texts[probs[0].argsort()[::-1][0]]submit_json["test_results"].append(single_video_result)with open('clip_result.json', 'w', encoding='utf-8') as up:json.dump(submit_json, up, ensure_ascii=False)
http://www.lryc.cn/news/232747.html

相关文章:

  • C++入门(1)—命名空间、缺省参数
  • 以程序员的身份使用curl获取速卖通详情
  • Java设计模式-结构型模式-装饰模式
  • 这7个“小毛病”项目经理必须克服
  • 一言成文大模型:大模型实践之路
  • 【VSCode】配置C/C++开发环境教程(Windows系统)
  • 算法实战:亲自写红黑树之四 插入insert的平衡
  • JWT 技术
  • 003.文件描述符、重定向
  • 图论| 827. 最大人工岛 127. 单词接龙
  • 2023年中国恒温蜡疗仪发展趋势分析:应用前景存有很大发展与探索空间[图]
  • 认识“协议”
  • GO语言的由来与发展历程
  • MPN – 制造零件号
  • Redis企业级问题及解决方案
  • 【2021集创赛】基于arm Cortex-M3处理器与深度学习加速器的实时人脸口罩检测 SoC
  • B码的相关知识点笔记
  • java“贪吃蛇”小游戏
  • 【面试经典150 | 位运算】数字范围按位与
  • 推介会如何做好媒体宣传
  • 【ROS导航Navigation】五 | 导航相关的消息 | 地图 | 里程计 | 坐标变换 | 定位 | 目标点和路径规划 | 激光雷达 | 相机
  • 什么是脏读、不可重复读、幻读讲解
  • 2018年五一杯数学建模C题江苏省本科教育质量综合评价解题全过程文档及程序
  • 第四代智能井盖传感器:万宾科技助力城市安全
  • [Jenkins] Docker 安装Jenkins及迁移流程
  • 第七篇 基于JSP 技术的网上购书系统——新品上架、推荐产品、在线留言、搜索功能实现(网上商城、仿淘宝、当当、亚马逊)
  • IntelliJ IDE 插件开发 |(一)快速入门
  • 【Ubuntu】Windows远程Ubuntu系统
  • pipeline jenkins流水线
  • 软件工程理论与实践 (吕云翔) 第六章 面向对象分析课后习题及其解析