dataset-viewer / app.py
Omnibus's picture
Update app.py
d714d3d
raw
history blame
923 Bytes
import gradio as gr
import requests
from datasets import load_dataset
#dataset = load_dataset("nlphuji/flickr30k", split="test[10:20]")
#print (dataset)
#headers = {"Authorization": f"Bearer {API_TOKEN}"}
API_URL1 = "https://datasets-server.huggingface.co/splits?dataset=nlphuji/flickr30k"
def query1():
response = requests.get(API_URL1)
#response = requests.get(API_URL1, headers=headers)
return response.json()
data = query1()
print (data)
def query2(fetch_url):
if fetch_url=="":
fetch_url = "nlphuji/flickr30k"
API_URL2 = f"https://datasets-server.huggingface.co/rows?dataset={fetch_url}&config=TEST&split=test&offset=150&length=10"
response = requests.get(API_URL2)
return response.json()
with gr.Blocks as app:
data_set_url=gr.Textbox():
fetch_btn=gr.Button():
out_json = gr.JSON():
fetch_btn.click(query2,data_set_url,out_json)
app.launch()