Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions metro-ai-suite/smart-traffic-intersection-agent/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Copyright (C) 2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

.python-version

# Ignore environment variables
.env

# Ignore Python cache files
__pycache__/
*.py[cod]
*.py[codz]
*$py.class

# Ignore virtual environment directories
venv/
env/
.venv/
.env/

# Ignore log files
*.log

# Ignore IDE specific files
.vscode/

*.manifest
*.spec

.DS_Store
.idea/
logs/

# Ignore model files
ov-model/
ov-models/


# Ignore pytest cache
.pytest_cache/

# Ignore pytest result files
*.pytest_cache

# pytest related dir
empty_model_dir
mock_model_dir
.coverage
htmlcov/
.tox/
.nox/
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py.cover
.hypothesis/
.pytest_cache/
cover/

# secrets
**/secrets
**/secrets/ca
**/secrets/certs
**/secrets/django
**/secrets/*.auth
**/secrets/supass
**/dlstreamer-pipeline-server/videos/**.ts

build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

**/edge-ai-suites/
127 changes: 127 additions & 0 deletions metro-ai-suite/smart-traffic-intersection-agent/docker/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# Copyright (C) 2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

name: scene-intelligence

secrets:
root-cert:
file: ../edge-ai-suites/metro-ai-suite/metro-vision-ai-app-recipe/smart-intersection/src/secrets/certs/scenescape-ca.pem

services:
# VLM OpenVINO Serving Service
vlm-openvino-serving:
image: intel/vlm-openvino-serving:1.3.1
ports:
- "${VLM_SERVICE_PORT:-9764}:8000"
ipc: host
networks:
- scenescape
environment:
# Proxy settings
no_proxy_env: ${no_proxy_env},${HOST_IP}
no_proxy: ${no_proxy_env},${HOST_IP}
http_proxy: ${http_proxy}
https_proxy: ${https_proxy}
# VLM Model configuration
VLM_MODEL_NAME: ${VLM_MODEL_NAME:-Qwen/Qwen2.5-VL-3B-Instruct}
VLM_COMPRESSION_WEIGHT_FORMAT: ${VLM_COMPRESSION_WEIGHT_FORMAT:-int4}
VLM_DEVICE: ${VLM_DEVICE:-CPU}
VLM_SEED: ${VLM_SEED:-42}
WORKERS: ${VLM_WORKERS:-1}
VLM_MAX_COMPLETION_TOKENS: ${VLM_MAX_COMPLETION_TOKENS:-1500}
HUGGINGFACE_TOKEN: ${HUGGINGFACE_TOKEN}
OV_CONFIG: ${OV_CONFIG}
VLM_LOG_LEVEL: ${VLM_LOG_LEVEL:-info}
OPENVINO_LOG_LEVEL: ${VLM_OPENVINO_LOG_LEVEL:-1}
VLM_ACCESS_LOG_FILE: ${VLM_ACCESS_LOG_FILE:-/dev/null}
restart: unless-stopped
devices:
- /dev/dri:/dev/dri
group_add:
- ${USER_GROUP_ID:-1000}
- ${VIDEO_GROUP_ID:-44}
- ${RENDER_GROUP_ID:-109}
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:8000/health || exit 1"]
interval: 10s
timeout: 10s
retries: 60
start_period: 10s
volumes:
- ov-models:/root/.cache/huggingface
- ov-models:/app/ov-model

# Traffic Intelligence Service
traffic-intelligence:
build:
context: ../src
dockerfile: Dockerfile
image: ${REGISTRY:-}traffic-intelligence:${TAG:-latest}
ports:
- "${TRAFFIC_INTELLIGENCE_PORT:-8081}:8081"
- "${TRAFFIC_INTELLIGENCE_UI_PORT:-7860}:7860"
networks:
- scenescape
depends_on:
vlm-openvino-serving:
condition: service_healthy
environment:
# Service configuration
TRAFFIC_INTELLIGENCE_HOST: 0.0.0.0
TRAFFIC_INTELLIGENCE_PORT: ${TRAFFIC_INTELLIGENCE_PORT:-8081}
LOG_LEVEL: ${LOG_LEVEL:-INFO}

# UI configuration
TRAFFIC_INTELLIGENCE_UI_PORT: ${TRAFFIC_INTELLIGENCE_UI_PORT:-7860}
USE_API: "true"
API_URL: http://localhost:${TRAFFIC_INTELLIGENCE_PORT:-8081}/api/v1/traffic/current
REFRESH_INTERVAL: ${REFRESH_INTERVAL:-15}

# Proxy settings
http_proxy: ${http_proxy}
https_proxy: ${https_proxy}
no_proxy: ${no_proxy_env},.scenescape.intel.com,${HOST_IP},broker.scenescape.intel.com,vlm-openvino-serving
NO_PROXY: ${no_proxy_env},.scenescape.intel.com,${HOST_IP},broker.scenescape.intel.com,vlm-openvino-serving
HTTP_PROXY: ${http_proxy}
HTTPS_PROXY: ${https_proxy}

# MQTT configuration (connects to broker service)
MQTT_HOST: ${MQTT_HOST:-broker.scenescape.intel.com}
MQTT_PORT: ${MQTT_PORT:-1883}

# Intersection configuration (overrides config/traffic_intelligence.json)
INTERSECTION_NAME: ${INTERSECTION_NAME:-Intersection-1}
INTERSECTION_LATITUDE: ${INTERSECTION_LATITUDE:-37.7049108}
INTERSECTION_LONGITUDE: ${INTERSECTION_LONGITUDE:--121.9096158}

# Weather configuration (overrides config/traffic_intelligence.json)
WEATHER_MOCK: ${WEATHER_MOCK:-true}

# VLM configuration (overrides config/traffic_intelligence.json)
VLM_MODEL: ${VLM_MODEL_NAME:-Qwen/Qwen2.5-VL-3B-Instruct}

# Traffic analysis configuration (overrides config/traffic_intelligence.json)
HIGH_DENSITY_THRESHOLD: ${HIGH_DENSITY_THRESHOLD:-10}

volumes:
- ../src/config:/app/config:ro
- traffic-intelligence-data:/app/data
secrets:
- source: root-cert
target: /app/secrets/certs/scenescape-ca.pem
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:8081/health || exit 1"]
interval: ${HEALTH_CHECK_INTERVAL:-30s}
timeout: ${HEALTH_CHECK_TIMEOUT:-10s}
retries: ${HEALTH_CHECK_RETRIES:-3}
start_period: ${HEALTH_CHECK_START_PERIOD:-10s}
restart: unless-stopped

volumes:
ov-models:
traffic-intelligence-data:

networks:
scenescape:
external: true
name: metro-vision-ai-app-recipe_scenescape
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.. toctree::

user-guide/index
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Scene Intelligence microservice

The Scene Intelligence microservice is a comprehensive traffic analysis service that provides real-time intersection monitoring, directional traffic density analysis, and Vision Language Model (VLM) powered traffic insights. It processes MQTT traffic data, manages camera images, and delivers intelligent traffic analysis through RESTful APIs.

## Overview

The microservice processes real-time traffic data from MQTT streams and provides advanced analytics including directional traffic density monitoring, VLM-powered traffic scene analysis, and comprehensive traffic summaries. It supports sliding window analysis, sustained traffic detection, and intelligent camera image management for enhanced traffic insights.


## Supporting Resources

- [Get Started Guide](get-started.md)
- [API Reference](api-reference.md)
- [System Requirements](system-requirements.md)
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
---
openapi: 3.1.0
info:
title: Traffic Intelligence API
description: Lightweight traffic analysis service for single intersection monitoring
version: 1.0.0
paths:
"/api/v1/traffic/current":
get:
summary: Get Current Traffic Intelligence
description: |-
Get current traffic intelligence data for the intersection.

Returns complete traffic intelligence response matching data.json schema
with weather data and VLM analysis.
operationId: get_current_traffic_intelligence_api_v1_traffic_current_get
parameters:
- name: images
in: query
required: false
schema:
type: boolean
default: true
description: Include camera images in response
title: Images
description: Include camera images in response
responses:
'200':
description: Successful Response
content:
application/json:
schema:
type: object
title: Response Get Current Traffic Intelligence Api V1 Traffic Current
Get
'404':
description: No traffic data available
'422':
description: Validation Error
content:
application/json:
schema:
"$ref": "#/components/schemas/HTTPValidationError"
"/health":
get:
summary: Health Check
description: Health check endpoint.
operationId: health_check_health_get
responses:
'200':
description: Successful Response
content:
application/json:
schema: {}
components:
schemas:
HTTPValidationError:
properties:
detail:
items:
"$ref": "#/components/schemas/ValidationError"
type: array
title: Detail
type: object
title: HTTPValidationError
ValidationError:
properties:
loc:
items:
anyOf:
- type: string
- type: integer
type: array
title: Location
msg:
type: string
title: Message
type:
type: string
title: Error Type
type: object
required:
- loc
- msg
- type
title: ValidationError
WeatherType:
type: string
enum:
- clear
title: WeatherType
description: Weather condition
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# API Reference
**Version: 1.0.0**

```{eval-rst}
.. swagger-plugin:: api-docs/openapi.yaml
```
Loading