Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,21 +1,31 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from datasets import load_dataset
|
| 3 |
-
from itertools import islice
|
| 4 |
|
| 5 |
-
def
|
| 6 |
try:
|
| 7 |
ds = load_dataset("MultimodalUniverse/jwst", split="train", streaming=True)
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
except Exception as e:
|
| 11 |
-
return
|
| 12 |
|
| 13 |
demo = gr.Interface(
|
| 14 |
-
fn=
|
| 15 |
-
inputs=
|
| 16 |
-
outputs="
|
| 17 |
-
title="JWST
|
| 18 |
-
description="
|
| 19 |
)
|
| 20 |
|
| 21 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from datasets import load_dataset
|
|
|
|
| 3 |
|
| 4 |
+
def peek_schema():
|
| 5 |
try:
|
| 6 |
ds = load_dataset("MultimodalUniverse/jwst", split="train", streaming=True)
|
| 7 |
+
first = next(iter(ds))
|
| 8 |
+
keys = list(first.keys())
|
| 9 |
+
types = {k: type(first[k]).__name__ for k in keys}
|
| 10 |
+
# show a few short text snippets if present
|
| 11 |
+
previews = {}
|
| 12 |
+
for k, v in first.items():
|
| 13 |
+
if isinstance(v, str) and len(v) > 0:
|
| 14 |
+
previews[k] = v[:200]
|
| 15 |
+
return {
|
| 16 |
+
"keys": keys,
|
| 17 |
+
"types": types,
|
| 18 |
+
"sample_text_preview": previews
|
| 19 |
+
}
|
| 20 |
except Exception as e:
|
| 21 |
+
return {"error": str(e)}
|
| 22 |
|
| 23 |
demo = gr.Interface(
|
| 24 |
+
fn=peek_schema,
|
| 25 |
+
inputs=None,
|
| 26 |
+
outputs="json",
|
| 27 |
+
title="JWST dataset schema peek",
|
| 28 |
+
description="Streams the first record from the JWST dataset to show available fields."
|
| 29 |
)
|
| 30 |
|
| 31 |
demo.launch()
|