Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -133,7 +133,7 @@ def load_from_file(path):
|
|
133 |
return None, True
|
134 |
if not Validator.is_valid_preset(obj):
|
135 |
return None, True
|
136 |
-
return obj, False
|
137 |
|
138 |
def load_from_url(url):
|
139 |
resp = requests.get(url)
|
@@ -145,7 +145,7 @@ def load_from_url(url):
|
|
145 |
return None, True
|
146 |
if not Validator.is_valid_preset(obj):
|
147 |
return None, True
|
148 |
-
return obj, False
|
149 |
|
150 |
with gr.Blocks() as demo:
|
151 |
preset_error = gr.State(False)
|
@@ -156,9 +156,9 @@ with gr.Blocks() as demo:
|
|
156 |
with gr.Tabs() as tabs:
|
157 |
with gr.TabItem("Upload", id=0):
|
158 |
file = gr.File(label="Upload a preset (.json)", file_types=[".json"])
|
159 |
-
file.upload(fn=load_from_file, inputs=[file], outputs=[preset, preset_error])
|
160 |
url_input = gr.Textbox(label="Enter a URL to a preset (.json) - press Enter to submit")
|
161 |
-
url_input.submit(fn=load_from_url, inputs=[url_input], outputs=[preset, preset_error])
|
162 |
with gr.TabItem("Viewer", id=1):
|
163 |
@gr.render(inputs=[preset_error, preset])
|
164 |
def render_preset(preset_error, preset):
|
|
|
133 |
return None, True
|
134 |
if not Validator.is_valid_preset(obj):
|
135 |
return None, True
|
136 |
+
return gr.update(selected=1), obj, False
|
137 |
|
138 |
def load_from_url(url):
|
139 |
resp = requests.get(url)
|
|
|
145 |
return None, True
|
146 |
if not Validator.is_valid_preset(obj):
|
147 |
return None, True
|
148 |
+
return gr.update(selected=1), obj, False
|
149 |
|
150 |
with gr.Blocks() as demo:
|
151 |
preset_error = gr.State(False)
|
|
|
156 |
with gr.Tabs() as tabs:
|
157 |
with gr.TabItem("Upload", id=0):
|
158 |
file = gr.File(label="Upload a preset (.json)", file_types=[".json"])
|
159 |
+
file.upload(fn=load_from_file, inputs=[file], outputs=[tabs, preset, preset_error])
|
160 |
url_input = gr.Textbox(label="Enter a URL to a preset (.json) - press Enter to submit")
|
161 |
+
url_input.submit(fn=load_from_url, inputs=[url_input], outputs=[tabs, preset, preset_error])
|
162 |
with gr.TabItem("Viewer", id=1):
|
163 |
@gr.render(inputs=[preset_error, preset])
|
164 |
def render_preset(preset_error, preset):
|