Update app.py
Browse files
app.py
CHANGED
|
@@ -2,6 +2,8 @@
|
|
| 2 |
|
| 3 |
import gradio as gr
|
| 4 |
import torch
|
|
|
|
|
|
|
| 5 |
|
| 6 |
from app_image_to_3d import create_demo as create_demo_image_to_3d
|
| 7 |
from app_text_to_3d import create_demo as create_demo_text_to_3d
|
|
@@ -14,6 +16,18 @@ if not torch.cuda.is_available():
|
|
| 14 |
|
| 15 |
model = Model()
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
with gr.Blocks(css_paths="style.css") as demo:
|
| 18 |
gr.Markdown(DESCRIPTION)
|
| 19 |
with gr.Tabs():
|
|
@@ -22,5 +36,9 @@ with gr.Blocks(css_paths="style.css") as demo:
|
|
| 22 |
with gr.Tab(label="Image to 3D"):
|
| 23 |
create_demo_image_to_3d(model)
|
| 24 |
|
|
|
|
|
|
|
|
|
|
| 25 |
if __name__ == "__main__":
|
|
|
|
| 26 |
demo.queue(max_size=10).launch()
|
|
|
|
| 2 |
|
| 3 |
import gradio as gr
|
| 4 |
import torch
|
| 5 |
+
from fastapi import FastAPI
|
| 6 |
+
from fastapi.middleware.cors import CORSMiddleware
|
| 7 |
|
| 8 |
from app_image_to_3d import create_demo as create_demo_image_to_3d
|
| 9 |
from app_text_to_3d import create_demo as create_demo_text_to_3d
|
|
|
|
| 16 |
|
| 17 |
model = Model()
|
| 18 |
|
| 19 |
+
# Create a FastAPI app
|
| 20 |
+
app = FastAPI()
|
| 21 |
+
|
| 22 |
+
# Add CORS middleware to allow cross-origin requests
|
| 23 |
+
app.add_middleware(
|
| 24 |
+
CORSMiddleware,
|
| 25 |
+
allow_origins=["*"], # Allows all origins
|
| 26 |
+
allow_credentials=True,
|
| 27 |
+
allow_methods=["*"], # Allows all methods
|
| 28 |
+
allow_headers=["*"], # Allows all headers
|
| 29 |
+
)
|
| 30 |
+
|
| 31 |
with gr.Blocks(css_paths="style.css") as demo:
|
| 32 |
gr.Markdown(DESCRIPTION)
|
| 33 |
with gr.Tabs():
|
|
|
|
| 36 |
with gr.Tab(label="Image to 3D"):
|
| 37 |
create_demo_image_to_3d(model)
|
| 38 |
|
| 39 |
+
# Mount the Gradio app
|
| 40 |
+
app = gr.mount_gradio_app(app, demo, path="/")
|
| 41 |
+
|
| 42 |
if __name__ == "__main__":
|
| 43 |
+
# For local development
|
| 44 |
demo.queue(max_size=10).launch()
|