FeilongTang commited on
Commit
2482664
1 Parent(s): 33347ae

Add gr.Examples block (gated on demo file presence)

Browse files

The block renders only if examples/demo_codec_heatmap.mp4 exists in
the Space root, so checkouts without the binary still launch cleanly.
Three preset rows ready for the demo clip:
1. Selection 路 gradient 路 global (baseline)
2. Heatmap 路 combined 路 log 路 dynamic (readiness story)
3. Side-by-side 路 combined 路 GOP=8 路 2048 budget (full feature)

The video itself is uploaded separately via xet (binary files are not
allowed through plain git push to HF Spaces).

Files changed (1) hide show
  1. app.py +40 -0
app.py CHANGED
@@ -1122,6 +1122,46 @@ with gr.Blocks(**_BLOCK_KW) as demo:
1122
  label="", language="json", lines=18,
1123
  )
1124
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1125
  gr.HTML(
1126
  '<div id="ovc-footer">'
1127
  '<b>OneVision Encoder</b> 路 codec-style patch saliency demo 路 '
 
1122
  label="", language="json", lines=18,
1123
  )
1124
 
1125
+ DEMO_VIDEO = os.path.join(
1126
+ os.path.dirname(os.path.abspath(__file__)),
1127
+ "examples", "demo_codec_heatmap.mp4",
1128
+ )
1129
+ if os.path.exists(DEMO_VIDEO):
1130
+ with gr.Group(elem_classes="ovc-card"):
1131
+ gr.Markdown("### Demo video")
1132
+ gr.Markdown(
1133
+ "<small>Click any row below to load the bundled clip with a "
1134
+ "preset configuration. Or upload your own video at the top.</small>"
1135
+ )
1136
+ gr.Examples(
1137
+ examples=[
1138
+ [
1139
+ DEMO_VIDEO, 16, 14, 1024, 150000,
1140
+ "selection", 0.55, 0.0, 0.0,
1141
+ "gradient", False, 99.0, 0.55, "global",
1142
+ ],
1143
+ [
1144
+ DEMO_VIDEO, 16, 14, 1024, 150000,
1145
+ "heatmap", 0.55, 0.0, 0.0,
1146
+ "combined", True, 96.0, 0.55, "dynamic",
1147
+ ],
1148
+ [
1149
+ DEMO_VIDEO, 24, 14, 2048, 150000,
1150
+ "sbs", 0.55, 0.0, 0.0,
1151
+ "combined", True, 95.0, 0.55, "8",
1152
+ ],
1153
+ ],
1154
+ inputs=[
1155
+ video_in, sample_frames, patch_size, top_k, max_pixels,
1156
+ viz_mode, heatmap_alpha, start_sec, end_sec,
1157
+ saliency_signal, score_log_scale, bitcost_pct,
1158
+ fade_strength, gop,
1159
+ ],
1160
+ label="",
1161
+ cache_examples=False,
1162
+ examples_per_page=5,
1163
+ )
1164
+
1165
  gr.HTML(
1166
  '<div id="ovc-footer">'
1167
  '<b>OneVision Encoder</b> 路 codec-style patch saliency demo 路 '