Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -56,7 +56,7 @@ def find_fn(lvl_1,lvl_2,fetch_url,config="TEST",split="test",offset=0,length=10)
|
|
56 |
#print(out_json['rows'])
|
57 |
#print (inp)
|
58 |
img_list=[]
|
59 |
-
out_json=query2(fetch_url,config,split,offset=10,length=20)
|
60 |
lvl_1=lvl_1.strip("[]")
|
61 |
|
62 |
lvl_2=lvl_2.strip('""').strip("''")
|
@@ -74,9 +74,36 @@ def find_fn(lvl_1,lvl_2,fetch_url,config="TEST",split="test",offset=0,length=10)
|
|
74 |
if lvl_2 == "":
|
75 |
img_list.append(out_json[lvl_1])
|
76 |
return img_list
|
77 |
-
|
78 |
-
|
79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
out_json,_=query2(fetch_url,config,split,offset=10,length=20)
|
81 |
box_1=[]
|
82 |
box_2=[]
|
@@ -124,10 +151,10 @@ with gr.Blocks() as app:
|
|
124 |
view_data=gr.Button(label="View")
|
125 |
with gr.Row():
|
126 |
lvl_1=gr.Dropdown(label="lvl_1")
|
127 |
-
lvl_2=gr.
|
128 |
-
lvl_3=gr.
|
129 |
-
lvl_4=gr.
|
130 |
-
lvl_5=gr.
|
131 |
|
132 |
find_btn=gr.Button("Search")
|
133 |
with gr.Tab("JSON"):
|
@@ -139,8 +166,13 @@ with gr.Blocks() as app:
|
|
139 |
with gr.Column(scale=1):
|
140 |
out_json = gr.JSON()
|
141 |
|
|
|
|
|
|
|
|
|
142 |
|
143 |
-
|
|
|
144 |
view_data.click(query2,[data_set_url,config_set,split_set],[out_find,lvl_1])
|
145 |
gal_btn.click(img_fn,out_find,out_gal)
|
146 |
|
|
|
56 |
#print(out_json['rows'])
|
57 |
#print (inp)
|
58 |
img_list=[]
|
59 |
+
out_json,_=query2(fetch_url,config,split,offset=10,length=20)
|
60 |
lvl_1=lvl_1.strip("[]")
|
61 |
|
62 |
lvl_2=lvl_2.strip('""').strip("''")
|
|
|
74 |
if lvl_2 == "":
|
75 |
img_list.append(out_json[lvl_1])
|
76 |
return img_list
|
77 |
+
def upd_drop(lvl_1,lvl_2,lvl_3,lvl_4,lvl_5,fetch_url,config="TEST",split="test",offset=0,length=10)):
|
78 |
+
out_json,_=query2(fetch_url,config,split,offset=10,length=20)
|
79 |
+
box_1=[]
|
80 |
+
box_2=[]
|
81 |
+
box_3=[]
|
82 |
+
box_4=[]
|
83 |
+
box_5=[]
|
84 |
+
out1=None
|
85 |
+
out2=None
|
86 |
+
out3=None
|
87 |
+
out4=None
|
88 |
+
|
89 |
+
if lvl_1 !="":
|
90 |
+
for ea in (out_json[lvl_1]):
|
91 |
+
box_1.append(ea)
|
92 |
+
out= gr.update(choices = [m for m in box_1]
|
93 |
+
if lvl_2 !="":
|
94 |
+
for ea in (out_json[lvl_1]):
|
95 |
+
box_2.append(ea[lvl_2])
|
96 |
+
out= gr.update(choices = [m for m in box_2]
|
97 |
+
if lvl_3 !="":
|
98 |
+
for ea in (out_json[lvl_1]):
|
99 |
+
box_3.append(ea[lvl_2][lvl_3])
|
100 |
+
out= gr.update(choices = [m for m in box_3]
|
101 |
+
if lvl_4 !="":
|
102 |
+
for ea in (out_json[lvl_1]):
|
103 |
+
box_4.append(ea[lvl_2][lvl_3][lvl_4])
|
104 |
+
out= gr.update(choices = [m for m in box_4]
|
105 |
+
return out
|
106 |
+
def find_items(lvl_1,lvl_2,lvl_3,lvl_4,lvl_5,fetch_url,config="TEST",split="test",offset=0,length=10):
|
107 |
out_json,_=query2(fetch_url,config,split,offset=10,length=20)
|
108 |
box_1=[]
|
109 |
box_2=[]
|
|
|
151 |
view_data=gr.Button(label="View")
|
152 |
with gr.Row():
|
153 |
lvl_1=gr.Dropdown(label="lvl_1")
|
154 |
+
lvl_2=gr.Dropdown(label="lvl_2")
|
155 |
+
lvl_3=gr.Dropdown(label="lvl_3")
|
156 |
+
lvl_4=gr.Dropdown(label="lvl_4")
|
157 |
+
lvl_5=gr.Dropdown(label="lvl_5")
|
158 |
|
159 |
find_btn=gr.Button("Search")
|
160 |
with gr.Tab("JSON"):
|
|
|
166 |
with gr.Column(scale=1):
|
167 |
out_json = gr.JSON()
|
168 |
|
169 |
+
lvl_1.change(upd_drop,[lvl_1,lvl_2,lvl_3,lvl_4,lvl_5,data_set_url,config_set,split_set],[lvl_2])
|
170 |
+
lvl_2.change(upd_drop,[lvl_1,lvl_2,lvl_3,lvl_4,lvl_5,data_set_url,config_set,split_set],[lvl_3])
|
171 |
+
lvl_3.change(upd_drop,[lvl_1,lvl_2,lvl_3,lvl_4,lvl_5,data_set_url,config_set,split_set],[lvl_4])
|
172 |
+
lvl_4.change(upd_drop,[lvl_1,lvl_2,lvl_3,lvl_4,lvl_5,data_set_url,config_set,split_set],[lvl_5])
|
173 |
|
174 |
+
|
175 |
+
find_btn.click(find_items,[lvl_1,lvl_2,lvl_3,lvl_4,lvl_5,data_set_url,config_set,split_set],out_find)
|
176 |
view_data.click(query2,[data_set_url,config_set,split_set],[out_find,lvl_1])
|
177 |
gal_btn.click(img_fn,out_find,out_gal)
|
178 |
|