Update app.py
Browse files
app.py
CHANGED
@@ -22,6 +22,8 @@ async def get_first_rows(dataset: str, config: str, split: str) -> Dict[str, Dic
|
|
22 |
URL = f"https://datasets-server.huggingface.co/first-rows?dataset={dataset}&config={config}&split={split}"
|
23 |
async with httpx.AsyncClient() as session:
|
24 |
response = await session.get(URL)
|
|
|
|
|
25 |
return response.json()
|
26 |
|
27 |
def get_df_from_rows(api_output):
|
@@ -45,27 +47,48 @@ async def update_dataset(split_name: str, config_name: str, dataset_name: str):
|
|
45 |
return df
|
46 |
|
47 |
# Guido von Roissum: https://www.youtube.com/watch?v=-DVyjdw4t9I
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
with gr.Blocks() as demo:
|
52 |
gr.Markdown("<h1><center>🥫Datasets🎨</center></h1>")
|
53 |
gr.Markdown("""<div align="center">Curated Datasets: <a href = "https://www.kaggle.com/datasets">Kaggle</a>. <a href="https://www.nlm.nih.gov/research/umls/index.html">NLM UMLS</a>. <a href="https://loinc.org/downloads/">LOINC</a>. <a href="https://www.cms.gov/medicare/icd-10/2022-icd-10-cm">ICD10 Diagnosis</a>. <a href="https://icd.who.int/dev11/downloads">ICD11</a>. <a href="https://paperswithcode.com/datasets?q=medical&v=lst&o=newest">Papers,Code,Datasets for SOTA in Medicine</a>. <a href="https://paperswithcode.com/datasets?q=mental&v=lst&o=newest">Mental</a>. <a href="https://paperswithcode.com/datasets?q=behavior&v=lst&o=newest">Behavior</a>. <a href="https://www.cms.gov/medicare-coverage-database/downloads/downloads.aspx">CMS Downloads</a>. <a href="https://www.cms.gov/medicare/fraud-and-abuse/physicianselfreferral/list_of_codes">CMS CPT and HCPCS Procedures and Services</a> """)
|
54 |
|
55 |
splits_data = gr.State()
|
|
|
56 |
with gr.Row():
|
57 |
-
dataset_name = gr.Dropdown(label="Dataset")
|
58 |
-
config = gr.Dropdown(label="Subset")
|
59 |
-
split = gr.Dropdown(label="Split")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
with gr.Row():
|
61 |
-
dataset = gr.DataFrame(wrap=True)
|
|
|
62 |
demo.load(get_valid_datasets, inputs=None, outputs=[dataset_name])
|
|
|
63 |
dataset_name.change(update_configs, inputs=[dataset_name], outputs=[config, splits_data])
|
64 |
config.change(update_splits, inputs=[config, splits_data], outputs=[split, dataset])
|
65 |
split.change(update_dataset, inputs=[split, config, dataset_name], outputs=[dataset])
|
66 |
|
|
|
|
|
|
|
|
|
67 |
demo.launch(debug=True)
|
68 |
|
69 |
# original: https://huggingface.co/spaces/freddyaboulton/dataset-viewer -- Freddy thanks! Your examples are the best.
|
70 |
# playlist on Gradio and Mermaid: https://www.youtube.com/watch?v=o7kCD4aWMR4&list=PLHgX2IExbFosW7hWNryq8hs2bt2aj91R-
|
71 |
-
# Link to Mermaid model and code: [![](https://mermaid.ink/img/pako:eNp1U8mO2zAM_RXCZ-eQpZccCmSZTIpOMQESIAdnDrRMx0JkydXSNDOYfy_lpUgD1AfBfnx8fCTlj0SYgpJ5UipzFRVaD4flSQM_YjwafcVJ9-FCfrbYVGA0ZQeLUkt9futiOM72pEh4QFijR9iTf2tzsx3Z0ti6hxslvb_Lm0TSNPvBDhQsg1TFXXAag7NBef_9hdDqFA6knbEbdgvGwu7mjRXVkDOLOV-yNXmytdQEsoROvTfi4EhK9XTSxUNz_mo4uVHm1lPyce-uR1k_n2RHymHRNPAvNXaTT7NVZYwjeDECVbS4UiYUAyc2lc-yFoPXxkujHaAl2G54PCjIpfBssZAGtsZ5KlLYkjWXkMLiuOfjPVhiymr3_x4qS7wicneTFuMW6Gdxlb6Cb7oJvt1LbEpMso08sza8MnqskA9jL27Ij72Jafb0G-tGkQNTdgKOy_XcFP5GDxFbWsJLV3FQid2LWfZsfpHVqAXBCBYa1e2dAHUBu5Ar6dgby0ghPWxQWk2Oh_L0M0h_S2Ep0YHUrXFHXD_msefo5XEkfFWBK8atdkA7mgfoalpATJI0qfnWoCz4b_iI0VPiK6rplMz5taASg_Kn5KQ_mYrBm_1Ni2TubaA0CU2BntYSeQl1Mi9ROfr8A8FBGds?type=png)](https://mermaid.live/edit#pako:eNp1U8mO2zAM_RXCZ-eQpZccCmSZTIpOMQESIAdnDrRMx0JkydXSNDOYfy_lpUgD1AfBfnx8fCTlj0SYgpJ5UipzFRVaD4flSQM_YjwafcVJ9-FCfrbYVGA0ZQeLUkt9futiOM72pEh4QFijR9iTf2tzsx3Z0ti6hxslvb_Lm0TSNPvBDhQsg1TFXXAag7NBef_9hdDqFA6knbEbdgvGwu7mjRXVkDOLOV-yNXmytdQEsoROvTfi4EhK9XTSxUNz_mo4uVHm1lPyce-uR1k_n2RHymHRNPAvNXaTT7NVZYwjeDECVbS4UiYUAyc2lc-yFoPXxkujHaAl2G54PCjIpfBssZAGtsZ5KlLYkjWXkMLiuOfjPVhiymr3_x4qS7wicneTFuMW6Gdxlb6Cb7oJvt1LbEpMso08sza8MnqskA9jL27Ij72Jafb0G-tGkQNTdgKOy_XcFP5GDxFbWsJLV3FQid2LWfZsfpHVqAXBCBYa1e2dAHUBu5Ar6dgby0ghPWxQWk2Oh_L0M0h_S2Ep0YHUrXFHXD_msefo5XEkfFWBK8atdkA7mgfoalpATJI0qfnWoCz4b_iI0VPiK6rplMz5taASg_Kn5KQ_mYrBm_1Ni2TubaA0CU2BntYSeQl1Mi9ROfr8A8FBGds)
|
|
|
22 |
URL = f"https://datasets-server.huggingface.co/first-rows?dataset={dataset}&config={config}&split={split}"
|
23 |
async with httpx.AsyncClient() as session:
|
24 |
response = await session.get(URL)
|
25 |
+
print(URL)
|
26 |
+
gr.Markdown(URL)
|
27 |
return response.json()
|
28 |
|
29 |
def get_df_from_rows(api_output):
|
|
|
47 |
return df
|
48 |
|
49 |
# Guido von Roissum: https://www.youtube.com/watch?v=-DVyjdw4t9I
|
50 |
+
async def update_URL(dataset: str, config: str, split: str) -> str:
|
51 |
+
URL = f"https://datasets-server.huggingface.co/first-rows?dataset={dataset}&config={config}&split={split}"
|
52 |
+
URL = f"https://huggingface.co/datasets/{split}"
|
53 |
+
return (URL)
|
54 |
+
|
55 |
+
async def openurl(URL: str) -> str:
|
56 |
+
html = f"<a href={URL} target=_blank>{URL}</a>"
|
57 |
+
return (html)
|
58 |
|
59 |
with gr.Blocks() as demo:
|
60 |
gr.Markdown("<h1><center>🥫Datasets🎨</center></h1>")
|
61 |
gr.Markdown("""<div align="center">Curated Datasets: <a href = "https://www.kaggle.com/datasets">Kaggle</a>. <a href="https://www.nlm.nih.gov/research/umls/index.html">NLM UMLS</a>. <a href="https://loinc.org/downloads/">LOINC</a>. <a href="https://www.cms.gov/medicare/icd-10/2022-icd-10-cm">ICD10 Diagnosis</a>. <a href="https://icd.who.int/dev11/downloads">ICD11</a>. <a href="https://paperswithcode.com/datasets?q=medical&v=lst&o=newest">Papers,Code,Datasets for SOTA in Medicine</a>. <a href="https://paperswithcode.com/datasets?q=mental&v=lst&o=newest">Mental</a>. <a href="https://paperswithcode.com/datasets?q=behavior&v=lst&o=newest">Behavior</a>. <a href="https://www.cms.gov/medicare-coverage-database/downloads/downloads.aspx">CMS Downloads</a>. <a href="https://www.cms.gov/medicare/fraud-and-abuse/physicianselfreferral/list_of_codes">CMS CPT and HCPCS Procedures and Services</a> """)
|
62 |
|
63 |
splits_data = gr.State()
|
64 |
+
|
65 |
with gr.Row():
|
66 |
+
dataset_name = gr.Dropdown(label="Dataset", interactive=True)
|
67 |
+
config = gr.Dropdown(label="Subset", interactive=True)
|
68 |
+
split = gr.Dropdown(label="Split", interactive=True)
|
69 |
+
|
70 |
+
with gr.Row():
|
71 |
+
#filterleft = gr.Textbox(label="First Column Filter",placeholder="Filter Column 1")
|
72 |
+
URLcenter = gr.Textbox(label="Dataset URL", placeholder="URL")
|
73 |
+
btn = gr.Button("Use Dataset")
|
74 |
+
#URLoutput = gr.Textbox(label="Output",placeholder="URL Output")
|
75 |
+
URLoutput = gr.HTML(label="Output",placeholder="URL Output")
|
76 |
+
|
77 |
with gr.Row():
|
78 |
+
dataset = gr.DataFrame(wrap=True, interactive=True)
|
79 |
+
|
80 |
demo.load(get_valid_datasets, inputs=None, outputs=[dataset_name])
|
81 |
+
|
82 |
dataset_name.change(update_configs, inputs=[dataset_name], outputs=[config, splits_data])
|
83 |
config.change(update_splits, inputs=[config, splits_data], outputs=[split, dataset])
|
84 |
split.change(update_dataset, inputs=[split, config, dataset_name], outputs=[dataset])
|
85 |
|
86 |
+
dataset_name.change(update_URL, inputs=[split, config, dataset_name], outputs=[URLcenter])
|
87 |
+
|
88 |
+
btn.click(openurl, [URLcenter], URLoutput)
|
89 |
+
|
90 |
demo.launch(debug=True)
|
91 |
|
92 |
# original: https://huggingface.co/spaces/freddyaboulton/dataset-viewer -- Freddy thanks! Your examples are the best.
|
93 |
# playlist on Gradio and Mermaid: https://www.youtube.com/watch?v=o7kCD4aWMR4&list=PLHgX2IExbFosW7hWNryq8hs2bt2aj91R-
|
94 |
+
# Link to Mermaid model and code: [![](https://mermaid.ink/img/pako:eNp1U8mO2zAM_RXCZ-eQpZccCmSZTIpOMQESIAdnDrRMx0JkydXSNDOYfy_lpUgD1AfBfnx8fCTlj0SYgpJ5UipzFRVaD4flSQM_YjwafcVJ9-FCfrbYVGA0ZQeLUkt9futiOM72pEh4QFijR9iTf2tzsx3Z0ti6hxslvb_Lm0TSNPvBDhQsg1TFXXAag7NBef_9hdDqFA6knbEbdgvGwu7mjRXVkDOLOV-yNXmytdQEsoROvTfi4EhK9XTSxUNz_mo4uVHm1lPyce-uR1k_n2RHymHRNPAvNXaTT7NVZYwjeDECVbS4UiYUAyc2lc-yFoPXxkujHaAl2G54PCjIpfBssZAGtsZ5KlLYkjWXkMLiuOfjPVhiymr3_x4qS7wicneTFuMW6Gdxlb6Cb7oJvt1LbEpMso08sza8MnqskA9jL27Ij72Jafb0G-tGkQNTdgKOy_XcFP5GDxFbWsJLV3FQid2LWfZsfpHVqAXBCBYa1e2dAHUBu5Ar6dgby0ghPWxQWk2Oh_L0M0h_S2Ep0YHUrX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