Commit ·
a4421c2
1
Parent(s): c328472
add desc
Browse files9 unmodified lines1011121314151618 unmodified lines35363738394041424344454647484 unmodified lines53545556575859606162639 unmodified linesreturn url_match[1]# Check if input is already in the correct formatreturn input_text if re.match(r"^[\w-]+/[\w-]+$", input_text) else Nonedef load_collection():18 unmodified linesdef display_dataset(dataset_ids, index):dataset_id = dataset_ids[index]return gr.HTML(f"""<iframesrc="https://huggingface.co/datasets/{dataset_id}/embed/viewer"frameborder="0"width="100%"height="560px"></iframe>""")def navigate_dataset(dataset_ids, index, direction):4 unmodified lines)try:dataset_ids, collection_id = load_collection()with gr.Blocks() as demo:gr.Markdown(f"<h1>Dataset Viewer for Collection: {collection_id}</h1>")index_state = gr.State(value=0)9 unmodified lines1011121314151618 unmodified lines3536373839404142434445464 unmodified lines515253545556575859606162636465666768697071727374757677787980819 unmodified linesreturn url_match[1]# Check if input is already in the correct formatreturn input_text if re.match(r"^[\w-]+/[\w-]+", input_text) else Nonedef load_collection():18 unmodified linesdef display_dataset(dataset_ids, index):dataset_id = dataset_ids[index]return gr.HTML(f"""<iframesrc="https://huggingface.co/datasets/{dataset_id}/embed/viewer"frameborder="0"width="100%"height="560px"></iframe>""")def navigate_dataset(dataset_ids, index, direction):4 unmodified lines)def get_display_name(collection_id):# Strip out the extra ID part of the namereturn re.sub(r"-[a-f0-9]{32}$", "", collection_id)try:dataset_ids, collection_id = load_collection()display_name = get_display_name(collection_id)with gr.Blocks() as demo:gr.Markdown(f"<h1>Dataset Viewer for Collection: {display_name}</h1>")gr.Markdown(f"[View full collection on Hugging Face](https://huggingface.co/collections/{collection_id})")gr.Markdown("""This app allows you to browse and view datasets from a specific Hugging Face collection.Use the 'Previous' and 'Next' buttons to navigate through the datasets in the collection.**Note**: This space is currently set up to display datasets from a specific collection.If you'd like to use it for a different collection:1. Duplicate this space2. In your duplicated space, set the `COLLECTION_SLUG_OR_URL` environment variable to your desired collection ID or URL3. Your new space will then display datasets from your chosen collection!""")index_state = gr.State(value=0)
app.py+24-6