Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -20,24 +20,29 @@ function(text_input, url_params) {
|
|
| 20 |
"""
|
| 21 |
def predict(text, url_params):
|
| 22 |
mod_url=""
|
|
|
|
| 23 |
try:
|
| 24 |
mod_url = url_params.get('url')
|
| 25 |
print (mod_url)
|
| 26 |
out = gr.HTML.update(f"""<h1>Loading model from:<br>{mod_url} </h1>""")
|
| 27 |
except Exception:
|
| 28 |
out=gr.HTML.update(f"""<h1>Enter Model URL</h1>""")
|
| 29 |
-
return ["" + text + "", out,mod_url]
|
| 30 |
|
| 31 |
def find_model(url):
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
|
| 43 |
with gr.Blocks(css="style.css") as app:
|
|
@@ -45,8 +50,6 @@ with gr.Blocks(css="style.css") as app:
|
|
| 45 |
with gr.Row():
|
| 46 |
inp = gr.Textbox(label="URL")
|
| 47 |
go_btn=gr.Button("Load")
|
| 48 |
-
|
| 49 |
-
|
| 50 |
out_html=gr.HTML('''''')
|
| 51 |
'''
|
| 52 |
with gr.Tab("iFrame"):
|
|
@@ -56,7 +59,7 @@ with gr.Blocks(css="style.css") as app:
|
|
| 56 |
</div>
|
| 57 |
""")
|
| 58 |
'''
|
| 59 |
-
|
| 60 |
|
| 61 |
with gr.Row(visible=False):
|
| 62 |
text_input=gr.Textbox()
|
|
@@ -65,7 +68,7 @@ with gr.Blocks(css="style.css") as app:
|
|
| 65 |
|
| 66 |
|
| 67 |
app.load(None,None,None,_js=load_js1)
|
| 68 |
-
app.load(fn=predict, inputs=[text_input,url_params], outputs=[text_output,out_html,inp],_js=load_js2).then(find_model,inp,out_html)
|
| 69 |
go_btn.click(find_model,inp,out_html)
|
| 70 |
app.launch()
|
| 71 |
|
|
|
|
| 20 |
"""
|
| 21 |
def predict(text, url_params):
|
| 22 |
mod_url=""
|
| 23 |
+
mod=None
|
| 24 |
try:
|
| 25 |
mod_url = url_params.get('url')
|
| 26 |
print (mod_url)
|
| 27 |
out = gr.HTML.update(f"""<h1>Loading model from:<br>{mod_url} </h1>""")
|
| 28 |
except Exception:
|
| 29 |
out=gr.HTML.update(f"""<h1>Enter Model URL</h1>""")
|
| 30 |
+
return ["" + text + "", mod,out,mod_url]
|
| 31 |
|
| 32 |
def find_model(url):
|
| 33 |
+
mod=None
|
| 34 |
+
if url != "" and url != None:
|
| 35 |
+
try:
|
| 36 |
+
mod = gr.HTML(f'''
|
| 37 |
+
<div>
|
| 38 |
+
<model-viewer src="{url}" camera-controls poster="https://cdn.glitch.global/fe6d4fc5-58dd-43de-a65d-7bd5b477e8e1/poster.webp?v=1696812691961" shadow-intensity="1"></model-viewer>
|
| 39 |
+
</div>
|
| 40 |
+
''')
|
| 41 |
+
except Exception as e:
|
| 42 |
+
out = gr.HTML(f'''<h1>Could not find Model</h1><br><h3>System Message: {e}''')
|
| 43 |
+
else:
|
| 44 |
+
out = gr.HTML(f'''<h1>Enter Model URL</h1>''')
|
| 45 |
+
return mod,out
|
| 46 |
|
| 47 |
|
| 48 |
with gr.Blocks(css="style.css") as app:
|
|
|
|
| 50 |
with gr.Row():
|
| 51 |
inp = gr.Textbox(label="URL")
|
| 52 |
go_btn=gr.Button("Load")
|
|
|
|
|
|
|
| 53 |
out_html=gr.HTML('''''')
|
| 54 |
'''
|
| 55 |
with gr.Tab("iFrame"):
|
|
|
|
| 59 |
</div>
|
| 60 |
""")
|
| 61 |
'''
|
| 62 |
+
markdown = gr.HTML("""""")
|
| 63 |
|
| 64 |
with gr.Row(visible=False):
|
| 65 |
text_input=gr.Textbox()
|
|
|
|
| 68 |
|
| 69 |
|
| 70 |
app.load(None,None,None,_js=load_js1)
|
| 71 |
+
app.load(fn=predict, inputs=[text_input,url_params], outputs=[text_output,out_html,markdown,inp],_js=load_js2).then(find_model,inp,out_html,markdown)
|
| 72 |
go_btn.click(find_model,inp,out_html)
|
| 73 |
app.launch()
|
| 74 |
|