mishig HF Staff commited on
Commit
b1911ab
·
verified ·
1 Parent(s): 5a33acc

Sync from huggingface/lerobot-dataset-visualizer via hub-sync

Browse files
src/app/[org]/[dataset]/[episode]/episode-viewer.tsx CHANGED
@@ -756,6 +756,7 @@ function EpisodeViewerInner({
756
  {activeTab === "frames" && (
757
  <OverviewPanel
758
  data={episodeFramesData}
 
759
  loading={framesLoading}
760
  flaggedOnly={framesFlaggedOnly}
761
  onFlaggedOnlyChange={setFramesFlaggedOnly}
 
756
  {activeTab === "frames" && (
757
  <OverviewPanel
758
  data={episodeFramesData}
759
+ cameras={datasetInfo.cameras}
760
  loading={framesLoading}
761
  flaggedOnly={framesFlaggedOnly}
762
  onFlaggedOnlyChange={setFramesFlaggedOnly}
src/components/overview-panel.tsx CHANGED
@@ -2,19 +2,23 @@
2
 
3
  import React, { useState, useEffect, useRef, useCallback } from "react";
4
  import type {
 
5
  EpisodeFrameInfo,
6
  EpisodeFramesData,
7
  } from "@/app/[org]/[dataset]/[episode]/fetch-data";
8
  import { useFlaggedEpisodes } from "@/context/flagged-episodes-context";
 
9
 
10
  const PAGE_SIZE = 48;
11
 
12
  function FrameThumbnail({
13
  info,
14
  showLast,
 
15
  }: {
16
  info: EpisodeFrameInfo;
17
  showLast: boolean;
 
18
  }) {
19
  const containerRef = useRef<HTMLDivElement>(null);
20
  const videoRef = useRef<HTMLVideoElement>(null);
@@ -62,11 +66,14 @@ function FrameThumbnail({
62
 
63
  return (
64
  <div ref={containerRef} className="flex flex-col items-center">
65
- <div className="w-full aspect-video bg-[var(--surface-1)] rounded overflow-hidden relative group">
 
 
 
66
  {inView ? (
67
  <video
68
  ref={videoRef}
69
- src={info.videoUrl}
70
  preload="metadata"
71
  muted
72
  className="w-full h-full object-cover"
@@ -111,6 +118,7 @@ function FrameThumbnail({
111
 
112
  interface OverviewPanelProps {
113
  data: EpisodeFramesData | null;
 
114
  loading: boolean;
115
  flaggedOnly?: boolean;
116
  onFlaggedOnlyChange?: (v: boolean) => void;
@@ -118,6 +126,7 @@ interface OverviewPanelProps {
118
 
119
  export default function OverviewPanel({
120
  data,
 
121
  loading,
122
  flaggedOnly = false,
123
  onFlaggedOnlyChange,
@@ -191,15 +200,22 @@ export default function OverviewPanel({
191
  }
192
 
193
  const totalPages = Math.ceil(frames.length / PAGE_SIZE);
 
 
 
 
194
  const pageFrames = frames.slice(page * PAGE_SIZE, (page + 1) * PAGE_SIZE);
195
 
196
  return (
197
  <div className="max-w-7xl mx-auto py-6 space-y-5">
198
- <p className="text-sm text-slate-500">
199
- Use first/last frame views to spot episodes with bad end states or other
200
- anomalies. Hover over a thumbnail and click the flag icon to mark
201
- episodes with wrong outcomes for review.
202
- </p>
 
 
 
203
 
204
  {/* Controls row */}
205
  <div className="flex items-center justify-between flex-wrap gap-4">
@@ -308,6 +324,7 @@ export default function OverviewPanel({
308
  key={`${selectedCamera}-${info.episodeIndex}`}
309
  info={info}
310
  showLast={showLast}
 
311
  />
312
  ))}
313
  </div>
 
2
 
3
  import React, { useState, useEffect, useRef, useCallback } from "react";
4
  import type {
5
+ CameraInfo,
6
  EpisodeFrameInfo,
7
  EpisodeFramesData,
8
  } from "@/app/[org]/[dataset]/[episode]/fetch-data";
9
  import { useFlaggedEpisodes } from "@/context/flagged-episodes-context";
10
+ import { proxyHfUrl } from "@/utils/auth";
11
 
12
  const PAGE_SIZE = 48;
13
 
14
  function FrameThumbnail({
15
  info,
16
  showLast,
17
+ aspectRatio,
18
  }: {
19
  info: EpisodeFrameInfo;
20
  showLast: boolean;
21
+ aspectRatio: number;
22
  }) {
23
  const containerRef = useRef<HTMLDivElement>(null);
24
  const videoRef = useRef<HTMLVideoElement>(null);
 
66
 
67
  return (
68
  <div ref={containerRef} className="flex flex-col items-center">
69
+ <div
70
+ className="w-full bg-[var(--surface-1)] rounded overflow-hidden relative group"
71
+ style={{ aspectRatio }}
72
+ >
73
  {inView ? (
74
  <video
75
  ref={videoRef}
76
+ src={proxyHfUrl(info.videoUrl)}
77
  preload="metadata"
78
  muted
79
  className="w-full h-full object-cover"
 
118
 
119
  interface OverviewPanelProps {
120
  data: EpisodeFramesData | null;
121
+ cameras: CameraInfo[];
122
  loading: boolean;
123
  flaggedOnly?: boolean;
124
  onFlaggedOnlyChange?: (v: boolean) => void;
 
126
 
127
  export default function OverviewPanel({
128
  data,
129
+ cameras,
130
  loading,
131
  flaggedOnly = false,
132
  onFlaggedOnlyChange,
 
200
  }
201
 
202
  const totalPages = Math.ceil(frames.length / PAGE_SIZE);
203
+ /// The camera's own shape: a fixed 16:9 box with object-cover cropped 4:3 frames top and bottom.
204
+ const camera = cameras.find((c) => c.name === selectedCamera);
205
+ const aspectRatio =
206
+ camera && camera.height > 0 ? camera.width / camera.height : 16 / 9;
207
  const pageFrames = frames.slice(page * PAGE_SIZE, (page + 1) * PAGE_SIZE);
208
 
209
  return (
210
  <div className="max-w-7xl mx-auto py-6 space-y-5">
211
+ <div>
212
+ <h2 className="text-xl font-bold text-slate-100">Frames</h2>
213
+ <p className="text-sm text-slate-400 mt-1">
214
+ Use first/last frame views to spot episodes with bad end states or
215
+ other anomalies. Hover over a thumbnail and click the flag icon to
216
+ mark episodes with wrong outcomes for review.
217
+ </p>
218
+ </div>
219
 
220
  {/* Controls row */}
221
  <div className="flex items-center justify-between flex-wrap gap-4">
 
324
  key={`${selectedCamera}-${info.episodeIndex}`}
325
  info={info}
326
  showLast={showLast}
327
+ aspectRatio={aspectRatio}
328
  />
329
  ))}
330
  </div>