thomasht86/accident-conditions
收藏资源简介:
--- license: other license_name: nlod-2.0 license_link: https://data.norge.no/nlod/en/2.0 language: - "no" tags: - road-images - norway - trondheim - traffic-accidents - accident-conditions - embeddings - multimodal - geospatial - gemini - image-editing - synthetic-conditions pretty_name: Norwegian Traffic Accident Scene Images with Embeddings size_categories: - 1K<n<10K task_categories: - image-feature-extraction - image-classification - zero-shot-image-classification configs: - config_name: default data_files: - split: train path: data/train/** dataset_info: - config_name: default features: - name: image dtype: image - name: nvdb_id dtype: int64 - name: accident_date dtype: string - name: accident_time dtype: string - name: year dtype: int64 - name: month dtype: int64 - name: day_of_week dtype: string - name: latitude dtype: float64 - name: longitude dtype: float64 - name: municipality_name dtype: string - name: municipality_number dtype: int64 - name: urban_area dtype: string - name: road_reference dtype: string - name: road_type dtype: string - name: speed_limit dtype: int64 - name: road_width dtype: float64 - name: light_conditions dtype: string - name: weather dtype: string - name: road_surface_condition dtype: string - name: temperature dtype: float64 - name: accident_type dtype: string - name: accident_code dtype: string - name: num_units dtype: int64 - name: num_cars dtype: int64 - name: num_trucks dtype: int64 - name: num_buses dtype: int64 - name: num_vans dtype: int64 - name: num_mc dtype: int64 - name: num_light_mc dtype: int64 - name: num_mopeds dtype: int64 - name: num_bicycles dtype: int64 - name: num_pedestrians dtype: int64 - name: num_escooters dtype: int64 - name: image_timestamp dtype: string - name: image_lat dtype: float64 - name: image_lon dtype: float64 - name: image_heading dtype: float64 - name: image_road_category dtype: string - name: image_road_number dtype: int64 - name: image_lane dtype: string - name: image_detected_objects dtype: string - name: address_text dtype: string - name: image_distance_m dtype: float64 - name: distance_km dtype: float64 - name: embedding sequence: float32 splits: - name: train num_examples: 3791 --- # Norwegian Traffic Accident Scene Images with Embeddings  A dataset of **~3,800 road images** depicting the environmental conditions at the time of real traffic accidents in the Trondheim region of Norway (2006–2024). Source images from [Statens vegvesen](https://www.vegvesen.no/) (Vegbilder) have been **AI-edited using Gemini** to realistically match the recorded accident conditions (lighting, weather, road surface), then paired with rich accident metadata and 3072-dimensional image embeddings. ## Dataset Description - **Source images**: [Vegbilder](https://vegbilder.atlas.vegvesen.no/) (Statens vegvesen road camera images, 2025) - **Accident data**: [NVDB](https://nvdbapiles-v3.atlas.vegvesen.no/) (Norwegian Road Database, traffic accidents 2006–2024) - **License**: [NLOD 2.0](https://data.norge.no/nlod/en/2.0) (Norwegian Licence for Open Government Data) — free to use with attribution - **Attribution**: Statens vegvesen / Norwegian Public Roads Administration - **Area**: Trondheim, Norway (~40km radius) - **Image editing**: Gemini 3.1 Flash (image editing mode) — conditions applied based on accident metadata - **Embeddings**: 3072-dimensional vectors from `gemini-embedding-2-preview` ## How It Was Built Each accident in the NVDB database was matched to the **nearest road image** from Vegbilder (within 100m). Where the accident occurred under different environmental conditions than the source image (e.g., nighttime, rain, snow/ice on road), the image was **edited using Gemini** to realistically depict those conditions. Images where conditions already matched (daylight, clear, dry) were used as-is. ``` Accident metadata (NVDB) → Match to nearest road image (Vegbilder WFS) → Edit image to accident conditions (Gemini) → Generate embedding (Gemini Batch API) → Upload to HuggingFace ``` ## Dataset Structure Each example contains: ### Image & Identifiers | Field | Type | Description | |---|---|---| | `image` | Image | Road scene JPEG — edited to match accident conditions | | `nvdb_id` | int | Unique accident ID from NVDB | ### Accident Time & Location | Field | Type | Description | |---|---|---| | `accident_date` | string | Date of accident (ISO 8601) | | `accident_time` | string | Time of accident (HH:MM) | | `year` | int | Accident year (2006–2024) | | `month` | int | Month (1–12) | | `day_of_week` | string | Day in Norwegian (Mandag–Søndag) | | `latitude` | float | Accident latitude (WGS84) | | `longitude` | float | Accident longitude (WGS84) | | `municipality_name` | string | Municipality (e.g., Trondheim, Melhus) | | `municipality_number` | int | Norwegian municipality number | | `urban_area` | string | Tettsted (urban) / Ikke tettsted (rural) / Ukjent | ### Road Information | Field | Type | Description | |---|---|---| | `road_reference` | string | Road reference (e.g., "FV6594 S2D1 m2405") | | `road_type` | string | Road type (Vanlig veg/gate, Boliggate, Gang-/sykkelveg, etc.) | | `speed_limit` | int | Posted speed limit (km/h) | | `road_width` | float | Road width in meters | ### Environmental Conditions (at accident time) These fields describe the conditions that were applied to edit the source image: | Field | Type | Description | |---|---|---| | `light_conditions` | string | Dagslys / Mørkt med vegbelysning / Mørkt uten vegbelysning / Tusmørke | | `weather` | string | God sikt opphold / God sikt nedbør / Dårlig sikt nedbør / Tåke / etc. | | `road_surface_condition` | string | Tørr bar veg / Våt bar veg / Snø/isbelagt / Delvis snø/is / Glatt | | `temperature` | float | Temperature in °C at accident time | ### Accident Details | Field | Type | Description | |---|---|---| | `accident_type` | string | High-level type (Utforkjøring, Kryssende kjøreretning, etc.) | | `accident_code` | string | Detailed accident description | | `num_units` | int | Total units involved | | `num_cars` | int | Number of cars | | `num_trucks` | int | Number of trucks | | `num_buses` | int | Number of buses | | `num_vans` | int | Number of vans | | `num_mc` | int | Number of motorcycles | | `num_light_mc` | int | Number of light motorcycles | | `num_mopeds` | int | Number of mopeds | | `num_bicycles` | int | Number of bicycles | | `num_pedestrians` | int | Number of pedestrians | | `num_escooters` | int | Number of e-scooters | ### Source Image Metadata (from Vegbilder) | Field | Type | Description | |---|---|---| | `image_timestamp` | string | When the source image was captured (ISO 8601) | | `image_lat` | float | Source image latitude (WGS84) | | `image_lon` | float | Source image longitude (WGS84) | | `image_heading` | float | Camera heading in degrees | | `image_road_category` | string | Road category: E (European), R (National), F (County) | | `image_road_number` | int | Road number from Vegbilder | | `image_lane` | string | Lane code (1 or 2, indicating direction) | | `image_detected_objects` | string | Auto-detected objects as JSON (e.g., `{"car": "1"}`) | | `address_text` | string | Nearest address from [Geonorge](https://ws.geonorge.no/) (e.g., "Innherredsveien 1, 7014 TRONDHEIM, TRONDHEIM") | | `image_distance_m` | float | Distance from accident to source image location (meters) | | `distance_km` | float | Distance from Trondheim city center (km) | ### Embedding | Field | Type | Description | |---|---|---| | `embedding` | list[float] | 3072-dim image embedding from `gemini-embedding-2-preview` | ## Usage ### Load the dataset ```python from datasets import load_dataset ds = load_dataset("thomasht86/accident-conditions", split="train") example = ds[0] print(example["accident_type"]) # "Utforkjøring" print(example["light_conditions"]) # "Mørkt uten vegbelysning" print(example["road_surface_condition"])# "Snø / isbelagt veg" print(len(example["embedding"])) # 3072 ``` ### Stream the dataset ```python from datasets import load_dataset ds = load_dataset("thomasht86/accident-conditions", split="train", streaming=True) for example in ds: image = example["image"] conditions = f"{example['light_conditions']} / {example['weather']} / {example['road_surface_condition']}" print(f"Accident {example['nvdb_id']}: {conditions}") ``` ### Use embeddings for similarity search ```python import numpy as np from datasets import load_dataset ds = load_dataset("thomasht86/accident-conditions", split="train") embeddings = np.array(ds["embedding"]) # (~3800, 3072) # Find scenes similar to the first one query = embeddings[0] similarities = embeddings @ query / (np.linalg.norm(embeddings, axis=1) * np.linalg.norm(query)) top_k = np.argsort(similarities)[-5:][::-1] for idx in top_k: ex = ds[int(idx)] print(f" {ex['accident_type']} | {ex['light_conditions']} | {ex['weather']} (sim: {similarities[idx]:.3f})") ``` ### Filter by conditions ```python # Night accidents only night = ds.filter(lambda x: "Mørkt" in str(x["light_conditions"])) # Winter accidents with snow/ice winter_ice = ds.filter( lambda x: x["month"] in (11, 12, 1, 2, 3) and "snø" in str(x["road_surface_condition"]).lower() ) # High-speed road accidents fast = ds.filter(lambda x: x["speed_limit"] is not None and x["speed_limit"] >= 80) ``` ## Data Collection Pipeline 1. **Accident data** fetched from NVDB API (traffic accidents in Trondheim area, 2006–2024) 2. **Image matching** via Vegbilder WFS — each accident matched to nearest road image within 100m 3. **Condition editing** via Gemini 3.1 Flash — images edited to match accident lighting, weather, and road surface conditions. ~45% of images needed editing; the rest already matched. 4. **Embeddings** generated via Gemini Batch API (`gemini-embedding-2-preview`, 3072 dims) ## Intended Uses - Visual search for accident scenes by condition similarity (embedding-based retrieval) - Training and evaluation of road condition classifiers - Analysis of accident patterns by environmental conditions - Multimodal search applications (text-to-image via shared Gemini embedding space) - Road safety research and visualization ## Limitations - **AI-edited images**: ~55% of images are synthetically edited to match accident conditions. While Gemini produces realistic results, they are not real photographs of the accident scene. - **Temporal mismatch**: Source images are from 2025; accidents span 2006–2024. Road geometry may have changed. - **Spatial approximation**: Images are matched within 100m of the accident location, not the exact spot. - **Coverage**: Limited to the Trondheim area (~40km radius). 20 accidents with matched images could not be edited. - **Embeddings**: Generated from a preview model (`gemini-embedding-2-preview`) which may change. ## Citation If you use this dataset, please credit the original data sources: ``` Statens vegvesen (2025). Vegbilder & NVDB. Norwegian Public Roads Administration. Licensed under NLOD 2.0: https://data.norge.no/nlod/en/2.0 ``` ## Related Datasets - [thomasht86/road-images-and-embeddings](https://huggingface.co/datasets/thomasht86/road-images-and-embeddings) — 34,908 road images from the same area (unedited, with embeddings)
license: 其他 license_name: nlod-2.0 license_link: https://data.norge.no/nlod/en/2.0 language: - "no" tags: - 道路图像 - 挪威 - 特隆赫姆 - 交通事故 - 事故场景 - 嵌入向量 - 多模态 - 地理空间 - Gemini - 图像编辑 - 合成场景 pretty_name: 带嵌入向量的挪威交通事故现场图像 size_categories: - 1000 < 样本数 < 10000 task_categories: - 图像特征提取 - 图像分类 - 零样本图像分类 configs: - config_name: default data_files: - split: train path: data/train/** dataset_info: - config_name: default features: - name: image dtype: 图像 - name: nvdb_id dtype: int64 - name: accident_date dtype: 字符串 - name: accident_time dtype: 字符串 - name: year dtype: int64 - name: month dtype: int64 - name: day_of_week dtype: 字符串 - name: latitude dtype: float64 - name: longitude dtype: float64 - name: municipality_name dtype: 字符串 - name: municipality_number dtype: int64 - name: urban_area dtype: 字符串 - name: road_reference dtype: 字符串 - name: road_type dtype: 字符串 - name: speed_limit dtype: int64 - name: road_width dtype: float64 - name: light_conditions dtype: 字符串 - name: weather dtype: 字符串 - name: road_surface_condition dtype: 字符串 - name: temperature dtype: float64 - name: accident_type dtype: 字符串 - name: accident_code dtype: 字符串 - name: num_units dtype: int64 - name: num_cars dtype: int64 - name: num_trucks dtype: int64 - name: num_buses dtype: int64 - name: num_vans dtype: int64 - name: num_mc dtype: int64 - name: num_light_mc dtype: int64 - name: num_mopeds dtype: int64 - name: num_bicycles dtype: int64 - name: num_pedestrians dtype: int64 - name: num_escooters dtype: int64 - name: image_timestamp dtype: 字符串 - name: image_lat dtype: float64 - name: image_lon dtype: float64 - name: image_heading dtype: float64 - name: image_road_category dtype: 字符串 - name: image_road_number dtype: int64 - name: image_lane dtype: 字符串 - name: image_detected_objects dtype: string - name: address_text dtype: 字符串 - name: image_distance_m dtype: float64 - name: distance_km dtype: float64 - name: embedding sequence: float32 splits: - name: train num_examples: 3791 # 带嵌入向量的挪威交通事故现场图像  本数据集包含约3800张道路图像,展现了挪威特隆赫姆地区2006年至2024年间真实交通事故发生时的环境场景。原始图像取自挪威公共道路管理局(Statens vegvesen)的Vegbilder道路摄像头图库,经Gemini AI编辑后,可逼真还原事故记录中的光照、天气与路面状况,随后与丰富的事故元数据及3072维图像嵌入向量进行绑定。 ## 数据集说明 - **原始图像**:Vegbilder(挪威公共道路管理局道路摄像头图像,2025年) - **事故数据**:挪威道路数据库(NVDB,2006年至2024年交通事故数据) - **许可证**:NLOD 2.0(挪威开放政府数据许可证)—— 标注来源即可免费使用 - **署名要求**:挪威公共道路管理局(Statens vegvesen) - **覆盖区域**:挪威特隆赫姆地区(半径约40公里) - **图像编辑**:Gemini 3.1 Flash(图像编辑模式)—— 编辑条件基于事故元数据生成 - **嵌入向量**:由`gemini-embedding-2-preview`生成的3072维向量 ## 数据集构建流程 挪威道路数据库(NVDB)中的每一起事故均匹配至Vegbilder图库中最近的道路图像(距离不超过100米)。若事故发生时的环境条件与原始图像存在差异(例如夜间、降雨、路面积雪/结冰),则使用Gemini对图像进行编辑,以逼真还原对应场景;若环境条件已匹配(日间、晴朗、路面干燥),则直接使用原始图像。 Accident metadata (NVDB) → Match to nearest road image (Vegbilder WFS) → Edit image to accident conditions (Gemini) → Generate embedding (Gemini Batch API) → Upload to HuggingFace ## 数据集结构 每个样本包含以下字段: ### 图像与标识符 | 字段名 | 数据类型 | 说明 | |---|---|---| | `image` | 图像 | 已编辑以匹配事故场景的道路场景JPEG图像 | | `nvdb_id` | int64 | 挪威道路数据库(NVDB)中的唯一事故ID | ### 事故时间与位置 | 字段名 | 数据类型 | 说明 | |---|---|---| | `accident_date` | 字符串 | 事故日期(ISO 8601格式) | | `accident_time` | 字符串 | 事故时间(HH:MM格式) | | `year` | int64 | 事故年份(2006–2024) | | `month` | int64 | 事故月份(1–12) | | `day_of_week` | 字符串 | 星期几(挪威语,Mandag至Søndag,即周一至周日) | | `latitude` | float64 | 事故纬度(WGS84坐标系) | | `longitude` | float64 | 事故经度(WGS84坐标系) | | `municipality_name` | 字符串 | 自治市名称(例如特隆赫姆、梅吕什) | | `municipality_number` | int64 | 挪威自治市编号 | | `urban_area` | 字符串 | 区域类型:Tettsted(城区)/ Ikke tettsted(乡村)/ Ukjent(未知) | ### 道路信息 | 字段名 | 数据类型 | 说明 | |---|---|---| | `road_reference` | 字符串 | 道路编号(例如"FV6594 S2D1 m2405") | | `road_type` | 字符串 | 道路类型(普通道路/街道、居民区道路、步行/自行车道等) | | `speed_limit` | int64 | 法定限速(单位:km/h) | | `road_width` | float64 | 道路宽度(单位:米) | ### 事故发生时的环境条件 以下字段描述了用于编辑原始图像的环境条件: | 字段名 | 数据类型 | 说明 | |---|---|---| | `light_conditions` | 字符串 | 光照条件:日光/夜间有道路照明/夜间无道路照明/完全黑暗 | | `weather` | 字符串 | 天气状况:良好无降水/良好有降水/低能见度降水/雾等 | | `road_surface_condition` | 字符串 | 路面状况:干燥路面/潮湿路面/积雪/结冰路面/部分积雪/结冰/光滑路面 | | `temperature` | float64 | 事故发生时的气温(单位:℃) | ### 事故详情 | 字段名 | 数据类型 | 说明 | |---|---|---| | `accident_type` | 字符串 | 事故大类(例如Utforkjøring、交叉路口碰撞等) | | `accident_code` | 字符串 | 详细事故描述 | | `num_units` | int64 | 涉事单位/车辆总数 | | `num_cars` | int64 | 轿车数量 | | `num_trucks` | int64 | 货车数量 | | `num_buses` | int64 | 巴士数量 | | `num_vans` | int64 | 厢式货车数量 | | `num_mc` | int64 | 摩托车数量 | | `num_light_mc` | int64 | 轻便摩托车数量 | | `num_mopeds` | int64 | 助力自行车数量 | | `num_bicycles` | int64 | 自行车数量 | | `num_pedestrians` | int64 | 行人数量 | | `num_escooters` | int64 | 电动滑板车数量 | ### 原始图像元数据(来自Vegbilder) | 字段名 | 数据类型 | 说明 | |---|---|---| | `image_timestamp` | 字符串 | 原始图像拍摄时间(ISO 8601格式) | | `image_lat` | float64 | 原始图像纬度(WGS84坐标系) | | `image_lon` | float64 | 原始图像经度(WGS84坐标系) | | `image_heading` | float64 | 摄像头朝向(单位:度) | | `image_road_category` | 字符串 | 道路类别:E(欧洲级)、R(国家级)、F(县级) | | `image_road_number` | int64 | Vegbilder中的道路编号 | | `image_lane` | 字符串 | 车道代码(1或2,代表行驶方向) | | `image_detected_objects` | 字符串 | 自动检测到的对象JSON格式(例如`{"car": "1"}`) | | `address_text` | 字符串 | 来自Geonorge的最近地址(例如"Innherredsveien 1, 7014 TRONDHEIM, TRONDHEIM") | | `image_distance_m` | float64 | 事故地点与原始图像位置的距离(单位:米) | | `distance_km` | float64 | 距离特隆赫姆市中心的距离(单位:公里) | ### 嵌入向量 | 字段名 | 数据类型 | 说明 | |---|---|---| | `embedding` | list[float] | 由`gemini-embedding-2-preview`生成的3072维图像嵌入向量 | ## 使用方法 ### 加载数据集 python from datasets import load_dataset ds = load_dataset("thomasht86/accident-conditions", split="train") example = ds[0] print(example["accident_type"]) # "Utforkjøring" print(example["light_conditions"]) # "Mørkt uten vegbelysning" print(example["road_surface_condition"])# "Snø / isbelagt veg" print(len(example["embedding"])) # 3072 ### 流式加载数据集 python from datasets import load_dataset ds = load_dataset("thomasht86/accident-conditions", split="train", streaming=True) for example in ds: image = example["image"] conditions = f"{example['light_conditions']} / {example['weather']} / {example['road_surface_condition']}" print(f"Accident {example['nvdb_id']}: {conditions}") ### 使用嵌入向量进行相似度搜索 python import numpy as np from datasets import load_dataset ds = load_dataset("thomasht86/accident-conditions", split="train") embeddings = np.array(ds["embedding"]) # (~3800, 3072) # Find scenes similar to the first one query = embeddings[0] similarities = embeddings @ query / (np.linalg.norm(embeddings, axis=1) * np.linalg.norm(query)) top_k = np.argsort(similarities)[-5:][::-1] for idx in top_k: ex = ds[int(idx)] print(f" {ex['accident_type']} | {ex['light_conditions']} | {ex['weather']} (sim: {similarities[idx]:.3f})") ### 按条件筛选 python # Night accidents only night = ds.filter(lambda x: "Mørkt" in str(x["light_conditions"])) # Winter accidents with snow/ice winter_ice = ds.filter( lambda x: x["month"] in (11, 12, 1, 2, 3) and "snø" in str(x["road_surface_condition"]).lower() ) # High-speed road accidents fast = ds.filter(lambda x: x["speed_limit"] is not None and x["speed_limit"] >= 80) ## 数据收集流程 1. **事故数据获取**:从NVDB API获取特隆赫姆地区2006年至2024年的交通事故数据 2. **图像匹配**:通过Vegbilder WFS服务,将每起事故匹配至100米范围内的最近道路图像 3. **场景编辑**:通过Gemini 3.1 Flash编辑图像,以匹配事故的光照、天气与路面状况。约45%的图像需要编辑,其余图像已匹配对应条件 4. **嵌入向量生成**:通过Gemini批量API(`gemini-embedding-2-preview`,3072维)生成图像嵌入向量 ## 预期用途 - 基于嵌入向量的场景相似度检索,按场景条件搜索事故现场图像 - 道路状况分类器的训练与评估 - 基于环境条件的事故模式分析 - 多模态搜索应用(通过共享的Gemini嵌入空间实现文本到图像检索) - 道路安全研究与可视化 ## 局限性 - **AI编辑图像**:约55%的图像为合成编辑后的场景,尽管Gemini生成的结果逼真,但并非事故现场的真实照片 - **时间不匹配**:原始图像拍摄于2025年,而事故时间跨度为2006-2024年,道路设施可能发生变化 - **空间近似**:图像匹配位置与事故地点的距离在100米以内,而非精确位置 - **覆盖范围**:仅覆盖特隆赫姆地区(半径约40公里),有20起事故无法匹配到可编辑的图像 - **嵌入向量**:由预览模型`gemini-embedding-2-preview`生成,模型可能发生变更 ## 引用说明 若使用本数据集,请注明原始数据来源: Statens vegvesen (2025). Vegbilder & NVDB. Norwegian Public Roads Administration. Licensed under NLOD 2.0: https://data.norge.no/nlod/en/2.0 ## 相关数据集 - [thomasht86/road-images-and-embeddings](https://huggingface.co/datasets/thomasht86/road-images-and-embeddings) — 同区域的34,908张道路图像(未编辑,带嵌入向量)



