eCity-VL-9B

eCity-VL-9B: A Multimodal Vision-Language Model for Urban Operational Safety Anomaly Event Detection

eCity-VL-9B is a vision-language model built for city-governance scenarios. Starting from the Qwen3.5-9B base model, it is fine-tuned with LLaMA-Factory LoRA SFT on surveillance data from three scene types — metro stations, urban roads, and bridges — enabling semantic description and multi-label classification of anomaly events in images/videos (facility damage, passenger violations, road waterlogging, spilled cargo, street vending on the roadway, special-vehicle passage, etc.). This document covers the full pipeline: data samples, training procedure, evaluation results, vLLM deployment, and a demo agent.

Deliverables

Deliverable Location Description
Model weights ./models Full weights after LoRA merge (9B, < 10B)
README (with data samples) ./README.md This document; §3 contains ShareGPT-format data samples for the three scenes
Training process ./assets/loss_curve.png, §4 LLaMA-Factory LoRA SFT configuration and training loss curve
Baseline comparison §5 Classification metrics against 3 open-source base models
Demo agent ./demo_agent.py Unified multi-label anomaly detection agent for metro / urban road / bridge scenes

1. Environment Setup

Use two separate environments for training and serving (vLLM and training dependencies have version conflicts).

Training environment (LLaMA-Factory)

conda create -n ecity-vl-train python=3.11 -y
conda activate ecity-vl-train
pip install torch==2.6.0 torchvision==0.21.0 --index-url https://download.pytorch.org/whl/cu124
git clone --depth 1 https://github.com/hiyouga/LLaMA-Factory.git
cd LLaMA-Factory
pip install -e ".[torch,metrics,deepspeed]"
# flash-attn (optional, speeds up training):
pip install flash-attn==2.7.4.post1 --no-build-isolation

Serving environment (vLLM)

conda create -n ecity-vl-serve python=3.11 -y
conda activate ecity-vl-serve
pip install vllm==0.9.2
pip install openai  # demo_agent.py relies on the OpenAI-compatible client

2. Model

Model Base Parameters Training method Description
eCity-VL-9B Qwen3.5-9B 9.2B (< 10B) LoRA SFT (rank=64, fully merged) Purpose-built model for anomaly event detection in urban surveillance scenes

The fine-tuning objective is to give the model anomaly event judgment capability: for each input surveillance image/video frame, it first outputs a coherent description following a scene-specific chain of thought (spatial environment -> facilities/road conditions -> personnel/vehicles -> anomaly identification), then reaches a multi-label conclusion on the anomaly type.

3. Training Data (Samples)

The training data is curated from real surveillance footage across metro stations, urban roads, and bridges, cleaned and annotated into ShareGPT format with scene-specific system prompts. In total: 12,480 samples — metro 5,260 / urban road 3,860 / bridge 3,360 — split 8:1:1 into train / val / test.

Example images for the three scenes:

Metro station Bridge Urban road
subway_1 bridge_1 road_1
subway_2 bridge_2 road_2
subway_3 bridge_3 road_3
Passage / platform / fare gates Bridge-deck traffic / waterlogging / ambulance passage Street vending / spilled cargo / illegal forklift on road

Data sample 1: metro station (operational safety / facility integrity)

{
  "conversations": [
    {
      "from": "human",
      "value": "<image>Describe in detail what is happening in the image."
    },
    {
      "from": "gpt",
      "value": "The image shows a metro passage environment. The floor is clean, with no standing water or debris, and the glass panels along both walls are intact. The lighting fixtures and advertising light boxes in the passage are all lit normally, and the ceiling-mounted surveillance equipment is in normal condition, with no damaged or detached devices observed. Four passengers are passing through normally, including two adults accompanying a child and one passenger holding an umbrella while looking at a phone; none of them carries large luggage. No dangerous or rule-violating behavior is observed at the scene, all facilities are operating normally, and the overall environment is operationally safe and orderly."
    }
  ],
  "images": [
    "assets/scenes/subway_1.jpg"
  ],
  "system": "You are a metro vision annotation expert whose task is to provide accurate, concise, and coherent image/video semantic descriptions for multimodal model training. Based on the visual content, output one continuous paragraph without titles or labels, focusing on key information relevant to operational safety and facility integrity.\nCore requirements:\nFirst identify the scene area (e.g., entrances and exits, ventilation shafts and pavilions, escalators, platform screen doors, evacuation passages, elevator exits, fare gates) and the environmental state (whether the floor has standing water, litter, or debris; whether glass or walls are damaged);\nNext check the electronic equipment (PIS displays, way-finding light boxes, advertising light boxes, surveillance cameras, fare gates) for being lit, black screens, or detachment, and the mechanical facilities (escalators, railings, signs, fences) for rust, abnormal placement, or damage, and whether anti-fall nets on ventilation shafts are broken;\nThen identify the people (passengers/staff), their number, key items being carried (large luggage, baby strollers, wheelchairs), and key actions (falling down, street performing, begging, unauthorized vending, flyering, climbing, climbing over, smoking, gathering, staying for a long time, moving against the flow, passing items over railings), without describing appearance in detail;\nFinally state the safety judgment, specifying the location and type of the anomaly, or providing evidence of good on-site order if no anomaly exists.\nOutput style: one continuous paragraph, concise language, clear logic, following the order: spatial environment -> facility status -> personnel behavior -> anomaly identification.\nIf the input is a video, synthesize multiple frames across the whole video to judge persistent behaviors and dynamic anomalies."
}

Data sample 2: urban road — street vending detection

{
  "conversations": [
    {
      "from": "human",
      "value": "<image>Describe in detail what is happening in the image."
    },
    {
      "from": "gpt",
      "value": "The image shows an urban road intersection on a clear day with a dry pavement. The lane markings on both carriageways are clear and intact. The signal lights, electronic enforcement camera, and road signs at the intersection are all working normally, and the central guardrails and isolation blocks are neatly placed without displacement. Twelve vehicles are passing normally, including two buses and one ambulance (siren off, proceeding in order). No forklifts, loaders, or commercial box trucks are on the road in violation, and no sign of coach overcapacity is found. On the right side of the image, three mobile vendors have set up stalls occupying about half of the non-motorized lane, forcing passing e-bikes and bicycles to detour into the motorized lanes, which creates a collision risk. Overall judgment: a street-vending anomaly exists, located in the right-side non-motorized lane; it is recommended to notify the relevant management department for disposal. The other facilities and road conditions are normal."
    }
  ],
  "images": [
    "assets/scenes/road_1.jpg"
  ],
  "system": "You are a road vision annotation expert whose task is to provide accurate, concise, and coherent image/video semantic descriptions for multimodal model training. Based on the visual content, output one continuous paragraph without titles or labels, focusing on key information relevant to road traffic safety and traffic events.\nCore requirements:\nFirst identify the road type (urban road, national/provincial highway, elevated road, bridge deck, intersection, tunnel) and the weather and pavement state (dry / waterlogged / snow-covered / icy, visibility);\nNext check the traffic facilities and road conditions (whether signs and markings are missing or blurred, whether guardrails are damaged, whether traffic lights are working, whether the pavement has spilled cargo or potholes, whether there is lane-occupying construction or street vending, whether the road is waterlogged);\nThen identify vehicle types and behaviors (pay special attention to special/commercial vehicles such as forklifts, loaders, ambulances, and box trucks, as well as overcapacity violations on coaches such as a 69-seat coach carrying excess passengers), and describe traffic flow, queuing, wrong-way driving, illegal parking, and other traffic states;\nFinally state the safety judgment, specifying the location and type of the anomaly, or providing evidence of good traffic order if no anomaly exists.\nOutput style: one continuous paragraph, concise language, clear logic, following the order: road environment -> road conditions and facilities -> vehicle behavior -> anomaly identification.\nIf the input is a video, synthesize multiple frames across the whole video to judge persistent behaviors and dynamic anomalies."
}

Data sample 3: bridge deck — waterlogging + special-vehicle recognition

{
  "conversations": [
    {
      "from": "human",
      "value": "<image>Describe in detail what is happening in the image."
    },
    {
      "from": "gpt",
      "value": "The image shows a bridge-deck section in light rain with moderate visibility and a slippery pavement. The stay cables, anti-collision guardrails, and bridge lighting facilities are all intact, and the variable message signs along the deck are displaying speed-limit information normally. Eight vehicles are passing, one of which is an ambulance with warning lights on moving quickly along the emergency lane while the other vehicles slow down and yield. No forklifts, loaders, or other illegal operating vehicles or overcapacity coaches are found. Due to continuous rainfall, a stretch of standing water about 15 meters long has formed in the third lane of the bridge deck, and vehicles driving through splash visibly, posing a skidding risk. Overall judgment: a road-waterlogging anomaly exists in the middle of the third lane; it is recommended to issue a waterlogging alert and arrange drainage. The special-vehicle passage has been recorded and reported."
    }
  ],
  "images": [
    "assets/scenes/bridge_2.jpg"
  ],
  "system": "You are a road vision annotation expert whose task is to provide accurate, concise, and coherent image/video semantic descriptions for multimodal model training. Based on the visual content, output one continuous paragraph without titles or labels, focusing on key information relevant to road traffic safety and traffic events.\nCore requirements:\nFirst identify the road type (urban road, national/provincial highway, elevated road, bridge deck, intersection, tunnel) and the weather and pavement state (dry / waterlogged / snow-covered / icy, visibility);\nNext check the traffic facilities and road conditions (whether signs and markings are missing or blurred, whether guardrails are damaged, whether traffic lights are working, whether the pavement has spilled cargo or potholes, whether there is lane-occupying construction or street vending, whether the road is waterlogged);\nThen identify vehicle types and behaviors (pay special attention to special/commercial vehicles such as forklifts, loaders, ambulances, and box trucks, as well as overcapacity violations on coaches such as a 69-seat coach carrying excess passengers), and describe traffic flow, queuing, wrong-way driving, illegal parking, and other traffic states;\nFinally state the safety judgment, specifying the location and type of the anomaly, or providing evidence of good traffic order if no anomaly exists.\nOutput style: one continuous paragraph, concise language, clear logic, following the order: road environment -> road conditions and facilities -> vehicle behavior -> anomaly identification.\nIf the input is a video, synthesize multiple frames across the whole video to judge persistent behaviors and dynamic anomalies."
}

Register the dataset in LLaMA-Factory's data/dataset_info.json:

"ecity_anomaly_sft": {
  "file_name": "ecity_anomaly_sft.json",
  "formatting": "sharegpt",
  "columns": {"messages": "conversations", "system": "system", "images": "images"},
  "tags": {"role_tag": "from", "content_tag": "value", "user_tag": "human", "assistant_tag": "gpt"}
}

4. Training Procedure (LLaMA-Factory LoRA SFT)

Hardware: 8 x NVIDIA A100 80G; DeepSpeed ZeRO-2 + bf16. Training configuration train_lora.yaml:

model_name_or_path: Qwen/Qwen3.5-9B
stage: sft
do_train: true
finetuning_type: lora
lora_target: all
lora_rank: 64
lora_alpha: 128
lora_dropout: 0.05
dataset: ecity_anomaly_sft
template: qwen3_vl
cutoff_len: 4096
max_samples: 12480
overwrite_cache: true
preprocessing_num_workers: 16
learning_rate: 1.0e-4
num_train_epochs: 3
lr_scheduler_type: cosine
warmup_ratio: 0.03
per_device_train_batch_size: 2
gradient_accumulation_steps: 2
bf16: true
deepspeed: examples/deepspeed/ds_z2_config.json
val_size: 0.1
per_device_eval_batch_size: 4
evaluation_strategy: steps
eval_steps: 100
logging_steps: 10
save_steps: 200
output_dir: saves/eCity-VL-9B/lora/sft
plot_loss: true

Launch training and merge the LoRA weights:

llamafactory-cli train train_lora.yaml

llamafactory-cli export \
    --model_name_or_path Qwen/Qwen3.5-9B \
    --adapter_name_or_path saves/eCity-VL-9B/lora/sft \
    --template qwen3_vl \
    --finetuning_type lora \
    --export_dir models \
    --export_size 2 \
    --export_legacy_format false

Training loss curve (3 epochs, about 1,050 steps in total; train loss converges from 2.1 to ~0.32, eval loss stabilizes at ~0.39 with no overfitting upturn):

loss curve

5. Evaluation: Baseline Comparison

On the test set (1,248 samples), model outputs are parsed into multi-label anomaly categories and scored with Accuracy / Precision / Recall / F1 (macro), compared against zero-shot base models:

Model Setting Accuracy Precision Recall F1
Qwen3.5-9B zero-shot 71.2 68.5 66.9 67.7
Qwen2.5-VL-7B-Instruct zero-shot 74.6 72.1 70.8 71.4
InternVL3-8B zero-shot 76.3 74.0 73.5 73.7
eCity-VL-9B (ours) LoRA SFT 86.6 85.7 84.4 85.0

Per-scene performance of eCity-VL-9B:

Scene Samples Accuracy Precision Recall F1
Metro 526 87.4 86.9 85.6 86.2
Urban road 386 85.0 84.1 82.7 83.4
Bridge 336 87.2 85.8 84.5 85.1

Compared with the strongest zero-shot baseline (InternVL3-8B), eCity-VL-9B improves the overall F1 by +11.3 (73.7 -> 85.0); the recall gain is most pronounced on low-frequency, high-risk categories (e.g., 69-seat coach overcapacity, spilled cargo), with macro recall rising from 66.9 to 84.4. Remaining errors concentrate in semantically adjacent categories (e.g., "standing water/debris on the floor" vs. a normally wet slippery surface, "lingering" vs. normal waiting) and missed detections of small, distant targets.

6. vLLM Deployment

Serve the merged full weights with the OpenAI-compatible API:

conda activate ecity-vl-serve
vllm serve ./models \
    --served-model-name eCity-VL-9B \
    --tensor-parallel-size 2 \
    --max-model-len 8192 \
    --gpu-memory-utilization 0.9 \
    --limit-mm-per-prompt image=4,video=1 \
    --port 8000

Verify inference:

curl http://localhost:8000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "eCity-VL-9B",
    "messages": [
      {"role": "system", "content": "You are an urban anomaly event detection expert..."},
      {"role": "user", "content": [
        {"type": "image_url", "image_url": {"url": "file:///path/to/frame.jpg"}},
        {"type": "text", "text": "Describe in detail what is happening in the image."}
      ]}
    ],
    "temperature": 0.0
  }'

7. Demo: Multi-Scene Anomaly Detection Agent

demo_agent.py implements a detection agent with a unified entry point supporting multi-label anomaly classification across the three scenes: it loads the scene-specific system prompt and anomaly label set, calls the vLLM OpenAI-compatible API for image understanding, and parses the natural-language output into structured JSON (scene, abnormality flag, anomaly categories, description).

# Single image detection (scene in metro | road | bridge)
python demo_agent.py --scene bridge --image /path/to/frame.jpg

# Batch detection over a directory, results written to report.jsonl
python demo_agent.py --scene road --image_dir /path/to/frames --out report.jsonl

Example output:

{
  "scene": "bridge",
  "image": "frame_0873.jpg",
  "is_abnormal": true,
  "categories": ["road waterlogging", "ambulance passing"],
  "description": "The image shows a bridge-deck section in light rain... a road-waterlogging anomaly exists in the middle of the third lane..."
}

Supported anomaly categories:

Scene Anomaly label set
metro Normal; facility anomaly (light box off / black screen / damaged / detached); standing water or debris on the floor; personnel anomaly (fallen / gathering / moving against the flow / climbing / smoking / unauthorized vending / begging / flyering / lingering / passing items over railings / large luggage)
road (urban road) Normal; forklift/loader on public road; ambulance passing; commercial box truck; coach overcapacity (69 seats); missing road markings; spilled cargo; street vending on the roadway; road waterlogging
bridge Normal; forklift/loader on public road; ambulance passing; commercial box truck; coach overcapacity (69 seats); missing road markings; spilled cargo; street vending on the roadway; road waterlogging

8. FAQ

vLLM fails at startup with CUDA out of memory

Lower --gpu-memory-utilization (e.g., 0.8), or reduce --max-model-len to 4096; remove --tensor-parallel-size 2 for single-GPU deployment.

LLaMA-Factory runs out of memory during training

Reduce per_device_train_batch_size to 1 and double gradient_accumulation_steps to keep the effective batch size; or switch to ds_z3_config.json (ZeRO-3).

Model output contains no classification conclusion

Make sure the request carries the scene-specific system prompt (see the data samples in §3) and that temperature is set to 0.0; demo_agent.py ships with the complete prompts for all three scenes and can be reused directly.

Citation

@article{qwen3,
  title={Qwen3 Technical Report},
  author={Qwen Team},
  journal={arXiv preprint arXiv:2505.09388},
  year={2025}
}

@article{qwen2.5-vl,
  title={Qwen2.5-VL Technical Report},
  author={Bai, Shuai and Chen, Keqin and Liu, Xuejing and Wang, Jialin and Ge, Wenbin and Song, Sibo and Dang, Kai and Wang, Peng and Wang, Shijie and Tang, Jun and Zhong, Humen and Zhu, Yuanzhi and Yang, Mingkun and Li, Zhaohai and Wan, Jianqiang and Wang, Pengfei and Ding, Wei and Fu, Zheren and Xu, Yiheng and Ye, Jiabo and Zhang, Xi and Xie, Tianbao and Cheng, Zesen and Zhang, Hang and Yang, Zhibo and Xu, Haiyang and Lin, Junyang},
  journal={arXiv preprint arXiv:2502.13923},
  year={2025}
}

Acknowledgement

Training is built on LLaMA-Factory, inference and serving on vLLM, and the base model is Qwen3.5-9B.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for eCityAI-Sup/eCity-VL-9B

Finetuned
(672)
this model

Papers for eCityAI-Sup/eCity-VL-9B