File size: 1,222 Bytes
feb3220 71eaa84 feb3220 3f8fe83 feb3220 3f8fe83 feb3220 71eaa84 add91d7 feb3220 3f8fe83 feb3220 3f8fe83 feb3220 7f04803 71eaa84 7f04803 71eaa84 7f04803 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
#!/usr/bin/env python
import gradio as gr
import torch
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app_image_to_3d import create_demo as create_demo_image_to_3d
from app_text_to_3d import create_demo as create_demo_text_to_3d
from model import Model
DESCRIPTION = "# [Shap-E](https://github.com/openai/shap-e)"
if not torch.cuda.is_available():
DESCRIPTION += "\n<p>Running on CPU 🥶 This demo does not work on CPU.</p>"
model = Model()
# Create a FastAPI app
app = FastAPI()
# Add CORS middleware to allow cross-origin requests
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # Allows all origins
allow_credentials=True,
allow_methods=["*"], # Allows all methods
allow_headers=["*"], # Allows all headers
)
with gr.Blocks(css_paths="style.css") as demo:
gr.Markdown(DESCRIPTION)
with gr.Tabs():
with gr.Tab(label="Text to 3D"):
create_demo_text_to_3d(model)
with gr.Tab(label="Image to 3D"):
create_demo_image_to_3d(model)
# Mount the Gradio app
app = gr.mount_gradio_app(app, demo, path="/")
if __name__ == "__main__":
# For local development
demo.queue(max_size=10).launch()
|