Merge branch #davanstrien/collection_dataset_viewer' into 'librarian-bots/Alpaca-Style-Datasets-explorer'
Browse files
app.py
CHANGED
@@ -52,13 +52,13 @@ def navigate_dataset(dataset_ids, index, direction):
|
|
52 |
|
53 |
|
54 |
def get_display_name(collection_id):
|
55 |
-
#
|
56 |
-
|
57 |
-
if
|
58 |
-
|
59 |
-
|
60 |
-
return
|
61 |
-
|
62 |
|
63 |
|
64 |
try:
|
@@ -73,14 +73,8 @@ try:
|
|
73 |
|
74 |
gr.Markdown("""
|
75 |
This app allows you to browse and view datasets from a specific Hugging Face collection.
|
76 |
-
Use the 'Previous' and 'Next' buttons to navigate through the datasets in the collection.
|
77 |
-
|
78 |
-
**Note**: This space is currently set up to display datasets from a specific collection.
|
79 |
-
If you'd like to use it for a different collection:
|
80 |
-
1. Duplicate this space
|
81 |
-
2. In your duplicated space, set the `COLLECTION_SLUG_OR_URL` environment variable to your desired collection ID or URL
|
82 |
-
3. Your new space will then display datasets from your chosen collection!
|
83 |
-
""")
|
84 |
|
85 |
index_state = gr.State(value=0)
|
86 |
|
@@ -90,7 +84,12 @@ try:
|
|
90 |
|
91 |
dataset_info = gr.Markdown(f"Dataset 1 of {len(dataset_ids)}: {dataset_ids[0]}")
|
92 |
iframe_output = gr.HTML()
|
93 |
-
|
|
|
|
|
|
|
|
|
|
|
94 |
left_btn.click(
|
95 |
navigate_dataset,
|
96 |
inputs=[gr.State(dataset_ids), index_state, gr.Number(-1, visible=False)],
|
|
|
52 |
|
53 |
|
54 |
def get_display_name(collection_id):
|
55 |
+
# Pattern to match username/repo-name with an optional ID of 16 or more hexadecimal characters
|
56 |
+
pattern = r"^(.+?)-([a-f0-9]{16,})$"
|
57 |
+
if match := re.match(pattern, collection_id):
|
58 |
+
return match[1]
|
59 |
+
else:
|
60 |
+
# If no match, return the original
|
61 |
+
return collection_id
|
62 |
|
63 |
|
64 |
try:
|
|
|
73 |
|
74 |
gr.Markdown("""
|
75 |
This app allows you to browse and view datasets from a specific Hugging Face collection.
|
76 |
+
Use the 'Previous' and 'Next' buttons to navigate through the datasets in the collection.
|
77 |
+
See below for how to set up this app for a different collection.""")
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
|
79 |
index_state = gr.State(value=0)
|
80 |
|
|
|
84 |
|
85 |
dataset_info = gr.Markdown(f"Dataset 1 of {len(dataset_ids)}: {dataset_ids[0]}")
|
86 |
iframe_output = gr.HTML()
|
87 |
+
gr.Markdown("""**Note**: This space is currently set up to display datasets from a specific collection.
|
88 |
+
If you'd like to use it for a different collection:
|
89 |
+
1. Duplicate this space
|
90 |
+
2. In your duplicated space, set the `COLLECTION_SLUG_OR_URL` environment variable to your desired collection ID or URL
|
91 |
+
3. Your new space will then display datasets from your chosen collection!
|
92 |
+
""")
|
93 |
left_btn.click(
|
94 |
navigate_dataset,
|
95 |
inputs=[gr.State(dataset_ids), index_state, gr.Number(-1, visible=False)],
|