Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,8 +7,8 @@ from datasets import load_dataset
|
|
7 |
#print (dataset)
|
8 |
|
9 |
#headers = {"Authorization": f"Bearer {API_TOKEN}"}
|
10 |
-
API_URL1 = "https://datasets-server.huggingface.co/splits?dataset=nlphuji/flickr30k"
|
11 |
def query1():
|
|
|
12 |
response = requests.get(API_URL1)
|
13 |
#response = requests.get(API_URL1, headers=headers)
|
14 |
return response.json()
|
@@ -16,12 +16,12 @@ def query1():
|
|
16 |
print (data)
|
17 |
|
18 |
|
19 |
-
def query2(fetch_url):
|
20 |
if fetch_url=="":
|
21 |
fetch_url = "nlphuji/flickr30k"
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
response = requests.get(API_URL2)
|
26 |
dictionary=response.json()
|
27 |
return dictionary
|
@@ -30,6 +30,7 @@ def find_fn(inp,out_json):
|
|
30 |
print(out_json['rows'])
|
31 |
print (inp)
|
32 |
img_list=[]
|
|
|
33 |
for rows in out_json['rows']:
|
34 |
img_ea = rows['row']['image']['src']
|
35 |
img_list.append(img_ea)
|
|
|
7 |
#print (dataset)
|
8 |
|
9 |
#headers = {"Authorization": f"Bearer {API_TOKEN}"}
|
|
|
10 |
def query1():
|
11 |
+
API_URL1 = "https://datasets-server.huggingface.co/splits?dataset=nlphuji/flickr30k"
|
12 |
response = requests.get(API_URL1)
|
13 |
#response = requests.get(API_URL1, headers=headers)
|
14 |
return response.json()
|
|
|
16 |
print (data)
|
17 |
|
18 |
|
19 |
+
def query2(fetch_url,offset=0,length=10):
|
20 |
if fetch_url=="":
|
21 |
fetch_url = "nlphuji/flickr30k"
|
22 |
+
#offset=0
|
23 |
+
#length=10
|
24 |
+
API_URL2 = f"https://datasets-server.huggingface.co/rows?dataset={fetch_url}&config=TEST&split=test&offset={offset}&length={length}"
|
25 |
response = requests.get(API_URL2)
|
26 |
dictionary=response.json()
|
27 |
return dictionary
|
|
|
30 |
print(out_json['rows'])
|
31 |
print (inp)
|
32 |
img_list=[]
|
33 |
+
out_json=(query2("",offset=10,lenght=20)
|
34 |
for rows in out_json['rows']:
|
35 |
img_ea = rows['row']['image']['src']
|
36 |
img_list.append(img_ea)
|