worldarchived commited on
Commit
0e7d3e3
·
verified ·
1 Parent(s): 31abd36

Hero stats, CTAs, segment list, LeRobot snippet

Browse files
Files changed (1) hide show
  1. app.py +61 -20
app.py CHANGED
@@ -2,12 +2,14 @@
2
  from __future__ import annotations
3
 
4
  import json
5
- from pathlib import Path
6
 
7
  import gradio as gr
 
8
  from huggingface_hub import hf_hub_download
9
 
10
  REPO = "WorldArchive/mono-india-workplace-sample"
 
11
  CLIPS = [
12
  ("sample_02_industrial_sewing_machine", "Industrial sewing"),
13
  ("sample_01_shuttle_tube_packaging", "Shuttle tube packaging"),
@@ -15,6 +17,19 @@ CLIPS = [
15
  ]
16
  LAYERS = ["plain", "skeleton", "boxes"]
17
  S3 = "https://ggn-egocentric-data-sample.s3.ap-south-1.amazonaws.com/sample_data_june"
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
 
20
  def clip_video_path(clip_id: str, layer: str) -> str:
@@ -23,44 +38,70 @@ def clip_video_path(clip_id: str, layer: str) -> str:
23
 
24
 
25
  def clip_metadata(clip_id: str) -> str:
26
- try:
27
- import pandas as pd
 
 
 
 
28
 
29
- path = hf_hub_download(REPO, "data/clips.parquet", repo_type="dataset")
30
- df = pd.read_parquet(path)
31
- row = df[df["clip_id"] == clip_id].iloc[0].to_dict()
32
- return json.dumps(row, indent=2, default=str)
33
- except Exception as e:
34
- return json.dumps({"clip_id": clip_id, "error": str(e), "s3": f"{S3}/metadata/{clip_id}.json"})
 
 
 
 
 
 
 
 
 
35
 
36
 
37
  def update(clip_label: str, layer: str):
38
  clip_id = next(c for c, label in CLIPS if label == clip_label)
39
- return clip_video_path(clip_id, layer), clip_metadata(clip_id)
40
 
41
 
42
  with gr.Blocks(title="World Archive Data Explorer", theme=gr.themes.Soft()) as demo:
43
  gr.Markdown(
44
- """
45
  # World Archive — Mono Clear Sample Explorer
46
 
47
  **Annotated egocentric manipulation from Indian workplaces.**
48
 
49
- Switch layers: plain video · hand skeleton · object boxes.
50
- [Full sample pack (S3)](https://ggn-egocentric-data-sample.s3.ap-south-1.amazonaws.com/sample_data_june/index.html) ·
51
- [Dataset card](https://huggingface.co/datasets/WorldArchive/mono-india-workplace-sample) ·
52
- [Book a call](https://calendly.com/algorithmsdheeraj/30min) ·
53
- shubham@worldarchive.co
 
 
 
 
 
 
 
 
 
 
 
54
  """
55
  )
56
  with gr.Row():
57
  clip_dd = gr.Dropdown([l for _, l in CLIPS], value=CLIPS[0][1], label="Clip")
58
  layer_dd = gr.Radio(LAYERS, value="plain", label="Layer")
59
  video = gr.Video(label="Preview (6s)", autoplay=True)
60
- meta = gr.Code(label="Clip metadata (parquet)", language="json")
61
- clip_dd.change(update, [clip_dd, layer_dd], [video, meta])
62
- layer_dd.change(update, [clip_dd, layer_dd], [video, meta])
63
- demo.load(update, [clip_dd, layer_dd], [video, meta])
 
 
64
 
65
  if __name__ == "__main__":
66
  demo.launch()
 
2
  from __future__ import annotations
3
 
4
  import json
5
+ from functools import lru_cache
6
 
7
  import gradio as gr
8
+ import pandas as pd
9
  from huggingface_hub import hf_hub_download
10
 
11
  REPO = "WorldArchive/mono-india-workplace-sample"
12
+ LEROBOT_REPO = "WorldArchive/mono-india-workplace-lerobot"
13
  CLIPS = [
14
  ("sample_02_industrial_sewing_machine", "Industrial sewing"),
15
  ("sample_01_shuttle_tube_packaging", "Shuttle tube packaging"),
 
17
  ]
18
  LAYERS = ["plain", "skeleton", "boxes"]
19
  S3 = "https://ggn-egocentric-data-sample.s3.ap-south-1.amazonaws.com/sample_data_june"
20
+ CALENDLY = "https://calendly.com/algorithmsdheeraj/30min"
21
+
22
+
23
+ @lru_cache(maxsize=1)
24
+ def load_segments_df() -> pd.DataFrame:
25
+ path = hf_hub_download(REPO, "data/segments.parquet", repo_type="dataset")
26
+ return pd.read_parquet(path)
27
+
28
+
29
+ @lru_cache(maxsize=1)
30
+ def load_clips_df() -> pd.DataFrame:
31
+ path = hf_hub_download(REPO, "data/clips.parquet", repo_type="dataset")
32
+ return pd.read_parquet(path)
33
 
34
 
35
  def clip_video_path(clip_id: str, layer: str) -> str:
 
38
 
39
 
40
  def clip_metadata(clip_id: str) -> str:
41
+ try:
42
+ df = load_clips_df()
43
+ row = df[df["clip_id"] == clip_id].iloc[0].to_dict()
44
+ return json.dumps(row, indent=2, default=str)
45
+ except Exception as e:
46
+ return json.dumps({"clip_id": clip_id, "error": str(e), "s3": f"{S3}/metadata/{clip_id}.json"})
47
 
48
+
49
+ def clip_segments(clip_id: str) -> str:
50
+ try:
51
+ df = load_segments_df()
52
+ video = f"{clip_id}.mp4"
53
+ rows = df[df["video"] == video].sort_values("start_sec")
54
+ lines = []
55
+ for _, r in rows.iterrows():
56
+ lines.append(
57
+ f"{r['start_sec']:.1f}s–{r['end_sec']:.1f}s "
58
+ f"**{r.get('action', '?')} {r.get('object', '?')}**"
59
+ )
60
+ return "\n".join(lines) if lines else "_No segments found._"
61
+ except Exception as e:
62
+ return f"_Could not load segments: {e}_"
63
 
64
 
65
  def update(clip_label: str, layer: str):
66
  clip_id = next(c for c, label in CLIPS if label == clip_label)
67
+ return clip_video_path(clip_id, layer), clip_metadata(clip_id), clip_segments(clip_id)
68
 
69
 
70
  with gr.Blocks(title="World Archive Data Explorer", theme=gr.themes.Soft()) as demo:
71
  gr.Markdown(
72
+ f"""
73
  # World Archive — Mono Clear Sample Explorer
74
 
75
  **Annotated egocentric manipulation from Indian workplaces.**
76
 
77
+ | Clips | Segments | Verticals | Annotation layers |
78
+ |:-----:|:--------:|:---------:|:-----------------:|
79
+ | **9** | **218** | **9** | **8+** |
80
+
81
+ Switch layers: plain video · hand skeleton · object boxes.
82
+
83
+ **Get in touch:** [Book a call]({CALENDLY}) · shubham@worldarchive.co
84
+
85
+ [Full sample pack (S3, ~19 GB)]({S3}/index.html) ·
86
+ [Dataset card](https://huggingface.co/datasets/{REPO}) ·
87
+ [LeRobot mirror](https://huggingface.co/datasets/{LEROBOT_REPO})
88
+
89
+ ```python
90
+ from lerobot.datasets.lerobot_dataset import LeRobotDataset
91
+ ds = LeRobotDataset("{LEROBOT_REPO}")
92
+ ```
93
  """
94
  )
95
  with gr.Row():
96
  clip_dd = gr.Dropdown([l for _, l in CLIPS], value=CLIPS[0][1], label="Clip")
97
  layer_dd = gr.Radio(LAYERS, value="plain", label="Layer")
98
  video = gr.Video(label="Preview (6s)", autoplay=True)
99
+ with gr.Row():
100
+ meta = gr.Code(label="Clip metadata (parquet)", language="json")
101
+ segs = gr.Markdown(label="Action segments")
102
+ clip_dd.change(update, [clip_dd, layer_dd], [video, meta, segs])
103
+ layer_dd.change(update, [clip_dd, layer_dd], [video, meta, segs])
104
+ demo.load(update, [clip_dd, layer_dd], [video, meta, segs])
105
 
106
  if __name__ == "__main__":
107
  demo.launch()