Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,28 +1,25 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
-
def
|
| 4 |
-
|
|
|
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
|
| 9 |
-
|
| 10 |
-
A list of subfolder names or an empty list if no subfolders exist.
|
| 11 |
-
"""
|
| 12 |
-
try:
|
| 13 |
-
import os
|
| 14 |
-
return [f for f in os.listdir(dataset_path) if os.path.isdir(os.path.join(dataset_path, f))]
|
| 15 |
-
except FileNotFoundError:
|
| 16 |
-
return ["Dataset path not found!"]
|
| 17 |
-
except PermissionError:
|
| 18 |
-
return ["Permission error accessing path!"]
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
interface = gr.Interface(
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
)
|
| 27 |
|
| 28 |
interface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from datasets import list_datasets, list_files
|
| 3 |
|
| 4 |
+
def list_files_and_subfolders(dataset_name):
|
| 5 |
+
# List files and subfolders in the chosen dataset directory
|
| 6 |
+
files_and_subfolders = list_files(dataset_name)
|
| 7 |
|
| 8 |
+
# Convert list to string for display
|
| 9 |
+
files_and_subfolders_str = "\n".join(files_and_subfolders)
|
| 10 |
|
| 11 |
+
return files_and_subfolders_str
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
+
# List all available datasets
|
| 14 |
+
datasets = list_datasets()
|
| 15 |
+
|
| 16 |
+
# Gradio interface
|
| 17 |
interface = gr.Interface(
|
| 18 |
+
fn=list_files_and_subfolders,
|
| 19 |
+
inputs=gr.inputs.Dropdown(choices=datasets, label="Choose Dataset"),
|
| 20 |
+
outputs="text",
|
| 21 |
+
title="List Files and Subfolders in Hugging Face Dataset",
|
| 22 |
+
description="Choose a dataset to list its files and subfolders.",
|
| 23 |
)
|
| 24 |
|
| 25 |
interface.launch()
|