Commit 3: Add 34 file(s)
Browse files- demos/model3D/run.py +12 -5
- requirements.txt +2 -2
- run.py +13 -25
demos/model3D/run.py
CHANGED
@@ -1,24 +1,31 @@
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
|
|
|
4 |
def load_mesh(mesh_file_name):
|
5 |
return mesh_file_name
|
6 |
|
|
|
7 |
demo = gr.Interface(
|
8 |
fn=load_mesh,
|
9 |
-
inputs=gr.Model3D(),
|
10 |
outputs=gr.Model3D(
|
11 |
-
|
|
|
12 |
examples=[
|
13 |
[os.path.join(os.path.dirname(__file__), "files/Bunny.obj")],
|
14 |
[os.path.join(os.path.dirname(__file__), "files/Duck.glb")],
|
15 |
[os.path.join(os.path.dirname(__file__), "files/Fox.gltf")],
|
16 |
[os.path.join(os.path.dirname(__file__), "files/face.obj")],
|
17 |
[os.path.join(os.path.dirname(__file__), "files/sofia.stl")],
|
18 |
-
[
|
19 |
-
|
|
|
|
|
|
|
|
|
20 |
],
|
21 |
-
cache_examples=True
|
22 |
)
|
23 |
|
24 |
if __name__ == "__main__":
|
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
|
4 |
+
|
5 |
def load_mesh(mesh_file_name):
|
6 |
return mesh_file_name
|
7 |
|
8 |
+
|
9 |
demo = gr.Interface(
|
10 |
fn=load_mesh,
|
11 |
+
inputs=gr.Model3D(label="Other name", display_mode="wireframe"),
|
12 |
outputs=gr.Model3D(
|
13 |
+
clear_color=(0.0, 0.0, 0.0, 0.0), label="3D Model", display_mode="wireframe"
|
14 |
+
),
|
15 |
examples=[
|
16 |
[os.path.join(os.path.dirname(__file__), "files/Bunny.obj")],
|
17 |
[os.path.join(os.path.dirname(__file__), "files/Duck.glb")],
|
18 |
[os.path.join(os.path.dirname(__file__), "files/Fox.gltf")],
|
19 |
[os.path.join(os.path.dirname(__file__), "files/face.obj")],
|
20 |
[os.path.join(os.path.dirname(__file__), "files/sofia.stl")],
|
21 |
+
[
|
22 |
+
"https://huggingface.co/datasets/dylanebert/3dgs/resolve/main/bonsai/bonsai-7k-mini.splat"
|
23 |
+
],
|
24 |
+
[
|
25 |
+
"https://huggingface.co/datasets/dylanebert/3dgs/resolve/main/luigi/luigi.ply"
|
26 |
+
],
|
27 |
],
|
28 |
+
cache_examples=True,
|
29 |
)
|
30 |
|
31 |
if __name__ == "__main__":
|
requirements.txt
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
-
gradio-client @ git+https://github.com/gradio-app/gradio@
|
2 |
-
https://gradio-pypi-previews.s3.amazonaws.com/
|
3 |
pypistats==1.1.0
|
4 |
plotly
|
5 |
matplotlib
|
|
|
1 |
+
gradio-client @ git+https://github.com/gradio-app/gradio@9cc7aee50ce74fafc94c51221127dd14dc479e89#subdirectory=client/python
|
2 |
+
https://gradio-pypi-previews.s3.amazonaws.com/9cc7aee50ce74fafc94c51221127dd14dc479e89/gradio-5.45.0-py3-none-any.whl
|
3 |
pypistats==1.1.0
|
4 |
plotly
|
5 |
matplotlib
|
run.py
CHANGED
@@ -4,36 +4,13 @@ import os
|
|
4 |
import sys
|
5 |
import copy
|
6 |
import pathlib
|
7 |
-
from fastapi import FastAPI, Request
|
8 |
-
from fastapi.templating import Jinja2Templates
|
9 |
-
import uvicorn
|
10 |
-
from gradio.utils import get_space
|
11 |
|
12 |
os.environ["GRADIO_ANALYTICS_ENABLED"] = "False"
|
13 |
|
14 |
demo_dir = pathlib.Path(__file__).parent / "demos"
|
15 |
|
16 |
-
app = FastAPI()
|
17 |
-
|
18 |
-
templates = Jinja2Templates(directory="templates")
|
19 |
-
|
20 |
names = sorted(os.listdir("./demos"))
|
21 |
|
22 |
-
|
23 |
-
@app.get("/")
|
24 |
-
def index(request: Request):
|
25 |
-
names = [[p[0], p[2]] for p in all_demos]
|
26 |
-
return templates.TemplateResponse(
|
27 |
-
"index.html",
|
28 |
-
{
|
29 |
-
"request": request,
|
30 |
-
"names": names,
|
31 |
-
"initial_demo": names[0][0],
|
32 |
-
"is_space": get_space(),
|
33 |
-
},
|
34 |
-
)
|
35 |
-
|
36 |
-
|
37 |
all_demos = []
|
38 |
demo_module = None
|
39 |
for p in sorted(os.listdir("./demos")):
|
@@ -50,8 +27,19 @@ for p in sorted(os.listdir("./demos")):
|
|
50 |
gr.Markdown(f"Error loading demo: {e}")
|
51 |
all_demos.append((p, demo, True))
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
for demo_name, demo, _ in all_demos:
|
54 |
-
app
|
|
|
|
|
|
|
55 |
|
56 |
if __name__ == "__main__":
|
57 |
-
|
|
|
4 |
import sys
|
5 |
import copy
|
6 |
import pathlib
|
|
|
|
|
|
|
|
|
7 |
|
8 |
os.environ["GRADIO_ANALYTICS_ENABLED"] = "False"
|
9 |
|
10 |
demo_dir = pathlib.Path(__file__).parent / "demos"
|
11 |
|
|
|
|
|
|
|
|
|
12 |
names = sorted(os.listdir("./demos"))
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
all_demos = []
|
15 |
demo_module = None
|
16 |
for p in sorted(os.listdir("./demos")):
|
|
|
27 |
gr.Markdown(f"Error loading demo: {e}")
|
28 |
all_demos.append((p, demo, True))
|
29 |
|
30 |
+
app = gr.Blocks()
|
31 |
+
|
32 |
+
with app:
|
33 |
+
gr.Markdown("""
|
34 |
+
# Deployed Demos
|
35 |
+
## Click through demos to test them out!
|
36 |
+
""")
|
37 |
+
|
38 |
for demo_name, demo, _ in all_demos:
|
39 |
+
with app.route(demo_name):
|
40 |
+
demo.render()
|
41 |
+
|
42 |
+
# app = gr.mount_gradio_app(app, demo, f"/demo/{demo_name}")
|
43 |
|
44 |
if __name__ == "__main__":
|
45 |
+
app.launch()
|