Spaces:
Runtime error
Runtime error
examples:
Browse files
app.py
CHANGED
@@ -1,29 +1,77 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
from gradio_rerun import Rerun
|
3 |
|
4 |
|
5 |
-
def predict(file_path: str | list[str]):
|
|
|
|
|
6 |
return file_path
|
7 |
|
8 |
|
9 |
with gr.Blocks(css=".gradio-container { max-width: unset!important; }") as demo:
|
10 |
with gr.Row():
|
11 |
with gr.Column():
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
with gr.Column():
|
14 |
pass
|
15 |
btn = gr.Button("Run", scale=0)
|
16 |
with gr.Row():
|
17 |
rerun_viewer = Rerun(height=900)
|
18 |
-
inputs = [file_path]
|
19 |
outputs = [rerun_viewer]
|
20 |
gr.on(
|
21 |
-
[btn.click,
|
22 |
fn=predict,
|
23 |
inputs=inputs,
|
24 |
outputs=outputs,
|
25 |
)
|
26 |
gr.on([btn.click, file_path.upload], fn=predict, inputs=inputs, outputs=outputs)
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
-
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from gradio_huggingfacehub_search import HuggingfaceHubSearch
|
3 |
from gradio_rerun import Rerun
|
4 |
|
5 |
|
6 |
+
def predict(search_in: str, file_path: str | list[str], url: str):
|
7 |
+
if url:
|
8 |
+
return url
|
9 |
return file_path
|
10 |
|
11 |
|
12 |
with gr.Blocks(css=".gradio-container { max-width: unset!important; }") as demo:
|
13 |
with gr.Row():
|
14 |
with gr.Column():
|
15 |
+
search_in = HuggingfaceHubSearch(
|
16 |
+
label="Search Models on Huggingface Hub and convert to rrd",
|
17 |
+
placeholder="Search for models on Huggingface",
|
18 |
+
search_type="model",
|
19 |
+
)
|
20 |
+
with gr.Group():
|
21 |
+
file_path = gr.File(file_count="multiple", type="filepath")
|
22 |
+
url = gr.Text(
|
23 |
+
info="Or use a URL",
|
24 |
+
label="URL",
|
25 |
+
)
|
26 |
with gr.Column():
|
27 |
pass
|
28 |
btn = gr.Button("Run", scale=0)
|
29 |
with gr.Row():
|
30 |
rerun_viewer = Rerun(height=900)
|
31 |
+
inputs = [search_in, file_path, url]
|
32 |
outputs = [rerun_viewer]
|
33 |
gr.on(
|
34 |
+
[btn.click, search_in.submit],
|
35 |
fn=predict,
|
36 |
inputs=inputs,
|
37 |
outputs=outputs,
|
38 |
)
|
39 |
gr.on([btn.click, file_path.upload], fn=predict, inputs=inputs, outputs=outputs)
|
40 |
|
41 |
+
gr.Examples(
|
42 |
+
examples=[
|
43 |
+
[
|
44 |
+
None,
|
45 |
+
None,
|
46 |
+
"https://app.rerun.io/version/0.15.1/examples/detect_and_track_objects.rrd",
|
47 |
+
],
|
48 |
+
[
|
49 |
+
None,
|
50 |
+
["./examples/rgbd.rrd"],
|
51 |
+
None,
|
52 |
+
],
|
53 |
+
[
|
54 |
+
None,
|
55 |
+
["./examples/rrt-star.rrd"],
|
56 |
+
None,
|
57 |
+
],
|
58 |
+
[
|
59 |
+
None,
|
60 |
+
["./examples/structure_from_motion.rrd"],
|
61 |
+
None,
|
62 |
+
],
|
63 |
+
[
|
64 |
+
None,
|
65 |
+
["./examples/structure_from_motion.rrd", "./examples/rrt-star.rrd"],
|
66 |
+
None,
|
67 |
+
],
|
68 |
+
],
|
69 |
+
fn=predict,
|
70 |
+
inputs=inputs,
|
71 |
+
outputs=outputs,
|
72 |
+
run_on_click=True,
|
73 |
+
)
|
74 |
+
|
75 |
|
76 |
+
if __name__ == "__main__":
|
77 |
+
demo.launch()
|