Ryukijano commited on
Commit
eaaedd2
·
1 Parent(s): f223812

Add ZeroGPU Gradio Space app

Browse files
Files changed (3) hide show
  1. README.md +37 -4
  2. app.py +92 -0
  3. requirements.txt +2 -0
README.md CHANGED
@@ -1,15 +1,48 @@
1
  ---
2
  title: Cosmos Sentinel
3
- emoji: 🌖
4
  colorFrom: blue
5
- colorTo: gray
6
  sdk: gradio
7
  sdk_version: 6.8.0
8
  python_version: '3.12'
9
  app_file: app.py
10
  pinned: false
11
  license: apache-2.0
12
- short_description: Submission for Nvidia Cosmos Cookoff.
13
  ---
14
 
15
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  title: Cosmos Sentinel
3
+ emoji: 🚦
4
  colorFrom: blue
5
+ colorTo: indigo
6
  sdk: gradio
7
  sdk_version: 6.8.0
8
  python_version: '3.12'
9
  app_file: app.py
10
  pinned: false
11
  license: apache-2.0
12
+ short_description: BADAS + Cosmos Reason 2 ZeroGPU demo.
13
  ---
14
 
15
+ # Cosmos Sentinel
16
+
17
+ Cosmos Sentinel is a traffic-safety demo built around:
18
+
19
+ - **BADAS** for predictive collision gating
20
+ - **Cosmos Reason 2** for causal incident narration and severity labeling
21
+ - **Cosmos Predict 2.5** for optional future continuation rollouts in the full project repo
22
+
23
+ This Hugging Face Space is implemented as a **Gradio app** so it is compatible with **ZeroGPU**.
24
+
25
+ ## What this Space includes
26
+
27
+ - a polished overview of the project
28
+ - sample run artifacts from Cosmos Sentinel
29
+ - a lightweight ZeroGPU-compatible diagnostic action
30
+ - supplementary links to the main papers, repos, and official docs
31
+
32
+ ## Full project repository
33
+
34
+ - GitHub: https://github.com/Ryukijano/Nvidia-Cosmos-Cookoff
35
+
36
+ ## Supplementary materials
37
+
38
+ - NVIDIA Cosmos overview: https://docs.nvidia.com/cosmos/latest/introduction.html
39
+ - Cosmos Reason 2 docs: https://docs.nvidia.com/cosmos/latest/reason2/index.html
40
+ - Cosmos Reason 2 repo: https://github.com/nvidia-cosmos/cosmos-reason2
41
+ - Cosmos Predict 2.5 repo: https://github.com/nvidia-cosmos/cosmos-predict2.5
42
+ - Cosmos Cookbook: https://nvidia-cosmos.github.io/cosmos-cookbook/index.html
43
+ - BADAS paper: https://arxiv.org/abs/2510.14876
44
+ - Nexar dataset paper: https://openaccess.thecvf.com/content/CVPR2025W/WAD/papers/Moura_Nexar_Dashcam_Collision_Prediction_Dataset_and_Challenge_CVPRW_2025_paper.pdf
45
+
46
+ ## Note
47
+
48
+ The full local Streamlit dashboard and heavier pipeline workflow remain in the GitHub repo. This Space is the lightweight Gradio presentation layer tailored for Hugging Face Spaces and ZeroGPU deployment.
app.py ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pathlib import Path
2
+ import time
3
+
4
+ import gradio as gr
5
+
6
+ try:
7
+ import spaces
8
+ except ImportError:
9
+ class _SpacesFallback:
10
+ @staticmethod
11
+ def GPU(fn=None, **_kwargs):
12
+ if fn is None:
13
+ def decorator(inner):
14
+ return inner
15
+ return decorator
16
+ return fn
17
+ spaces = _SpacesFallback()
18
+
19
+ ROOT = Path(__file__).resolve().parent
20
+ GITHUB_REPO_URL = "https://github.com/Ryukijano/Nvidia-Cosmos-Cookoff"
21
+ GITHUB_ASSET_LINKS = {
22
+ "Sample input video": f"{GITHUB_REPO_URL}/blob/main/1_first.mp4",
23
+ "BADAS-focused clip": f"{GITHUB_REPO_URL}/blob/main/extracted_clip.mp4",
24
+ "BADAS gradient saliency": f"{GITHUB_REPO_URL}/blob/main/badas_gradient_saliency.png",
25
+ "BADAS frame strip": f"{GITHUB_REPO_URL}/blob/main/badas_frame_strip.png",
26
+ "Reason frame strip": f"{GITHUB_REPO_URL}/blob/main/reason_frame_strip.png",
27
+ "Reason bounding-box visualization": f"{GITHUB_REPO_URL}/blob/main/bboxes_visualization.png",
28
+ "Reason risk visualization": f"{GITHUB_REPO_URL}/blob/main/risk_visualization.png",
29
+ }
30
+
31
+ SUPPLEMENTARY_MARKDOWN = """
32
+ ## Supplementary Materials
33
+
34
+ - [Project repository](https://github.com/Ryukijano/Nvidia-Cosmos-Cookoff)
35
+ - [NVIDIA Cosmos overview](https://docs.nvidia.com/cosmos/latest/introduction.html)
36
+ - [Cosmos Reason 2 docs](https://docs.nvidia.com/cosmos/latest/reason2/index.html)
37
+ - [Cosmos Reason 2 repo](https://github.com/nvidia-cosmos/cosmos-reason2)
38
+ - [Cosmos Predict 2.5 repo](https://github.com/nvidia-cosmos/cosmos-predict2.5)
39
+ - [Cosmos Cookbook](https://nvidia-cosmos.github.io/cosmos-cookbook/index.html)
40
+ - [BADAS paper](https://arxiv.org/abs/2510.14876)
41
+ - [Nexar dataset and challenge paper](https://openaccess.thecvf.com/content/CVPR2025W/WAD/papers/Moura_Nexar_Dashcam_Collision_Prediction_Dataset_and_Challenge_CVPRW_2025_paper.pdf)
42
+ """
43
+ @spaces.GPU
44
+ def zero_gpu_diagnostic():
45
+ started_at = time.strftime("%Y-%m-%d %H:%M:%S UTC", time.gmtime())
46
+ return (
47
+ "ZeroGPU diagnostic executed successfully.\n\n"
48
+ f"Timestamp: {started_at}\n"
49
+ "This Space uses the Gradio SDK and a ZeroGPU-compatible decorated function."
50
+ )
51
+
52
+
53
+ with gr.Blocks(theme=gr.themes.Soft(), title="Cosmos Sentinel") as demo:
54
+ gr.Markdown("# 🚦 Cosmos Sentinel")
55
+ gr.Markdown(
56
+ "A BADAS + Cosmos Reason 2 traffic-safety demo adapted for Hugging Face Spaces. "
57
+ "The full local project includes a Streamlit dashboard; this Space is the lightweight Gradio presentation version for ZeroGPU compatibility."
58
+ )
59
+
60
+ with gr.Tabs():
61
+ with gr.Tab("Overview"):
62
+ gr.Markdown(
63
+ """
64
+ ## Pipeline
65
+
66
+ 1. **BADAS** scans the traffic video for developing collision risk.
67
+ 2. **Clip extraction** isolates the highest-risk temporal window.
68
+ 3. **Cosmos Reason 2** analyzes the scene and explains the likely incident and severity.
69
+ 4. **Cosmos Predict 2.5** can optionally simulate observed or prevented continuations in the full project repo.
70
+
71
+ ## Why this Space is Gradio-based
72
+
73
+ Hugging Face **ZeroGPU** is officially supported for **Gradio Spaces**, not Streamlit Spaces. This app is therefore the Space-native presentation layer for the project.
74
+ """
75
+ )
76
+
77
+ with gr.Tab("Sample Run Artifacts"):
78
+ artifact_lines = ["Example artifacts from a local sample run of Cosmos Sentinel are hosted in the GitHub repository:"]
79
+ artifact_lines.extend([f"- [{label}]({url})" for label, url in GITHUB_ASSET_LINKS.items()])
80
+ gr.Markdown("\n".join(artifact_lines))
81
+
82
+ with gr.Tab("ZeroGPU Check"):
83
+ gr.Markdown("Click the button below to run a lightweight function through the ZeroGPU-compatible execution path.")
84
+ check_button = gr.Button("Run ZeroGPU diagnostic", variant="primary")
85
+ check_output = gr.Textbox(label="Diagnostic output", lines=6)
86
+ check_button.click(fn=zero_gpu_diagnostic, inputs=None, outputs=check_output)
87
+
88
+ with gr.Tab("Supplementary Materials"):
89
+ gr.Markdown(SUPPLEMENTARY_MARKDOWN)
90
+
91
+
92
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio>=5.0.0
2
+ spaces