Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,31 +1,28 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from datasets import load_dataset
|
| 3 |
|
| 4 |
-
def
|
| 5 |
try:
|
| 6 |
ds = load_dataset("MultimodalUniverse/jwst", split="train", streaming=True)
|
| 7 |
first = next(iter(ds))
|
| 8 |
keys = list(first.keys())
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
previews
|
| 12 |
-
for k,
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
"types": types,
|
| 18 |
-
"sample_text_preview": previews
|
| 19 |
-
}
|
| 20 |
except Exception as e:
|
| 21 |
-
return
|
| 22 |
|
| 23 |
demo = gr.Interface(
|
| 24 |
-
fn=
|
| 25 |
inputs=None,
|
| 26 |
-
outputs="
|
| 27 |
title="JWST dataset schema peek",
|
| 28 |
-
description="
|
| 29 |
)
|
| 30 |
|
| 31 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from datasets import load_dataset
|
| 3 |
|
| 4 |
+
def peek_schema_text():
|
| 5 |
try:
|
| 6 |
ds = load_dataset("MultimodalUniverse/jwst", split="train", streaming=True)
|
| 7 |
first = next(iter(ds))
|
| 8 |
keys = list(first.keys())
|
| 9 |
+
lines = [f"Keys: {keys}", "Types:"]
|
| 10 |
+
lines += [f" {k}: {type(first[k]).__name__}" for k in keys]
|
| 11 |
+
# show short previews if any text fields exist
|
| 12 |
+
previews = [f" {k}: {first[k][:200]}" for k in keys if isinstance(first[k], str) and first[k]]
|
| 13 |
+
if previews:
|
| 14 |
+
lines.append("Text previews:")
|
| 15 |
+
lines += previews
|
| 16 |
+
return "\n".join(lines)
|
|
|
|
|
|
|
|
|
|
| 17 |
except Exception as e:
|
| 18 |
+
return f"Error: {e}"
|
| 19 |
|
| 20 |
demo = gr.Interface(
|
| 21 |
+
fn=peek_schema_text,
|
| 22 |
inputs=None,
|
| 23 |
+
outputs="text",
|
| 24 |
title="JWST dataset schema peek",
|
| 25 |
+
description="Shows keys and types for the first streamed record."
|
| 26 |
)
|
| 27 |
|
| 28 |
demo.launch()
|