Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,12 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
ABOUT_TEXT = """
|
3 |
# Text-to-3D with TripoSR + SDXL
|
4 |
|
@@ -6,6 +14,29 @@ Commercially-viable text-to-3D model. Usage must comply with the SDXL license.
|
|
6 |
|
7 |
For image-to-3D, use [TripoSR](https://huggingface.co/spaces/stabilityai/TripoSR) directly.
|
8 |
""".strip()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
with gr.Blocks() as demo:
|
10 |
gr.Markdown(ABOUT_TEXT)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
demo.queue(api_open=False, default_concurrency_limit=20).launch(show_api=False)
|
|
|
1 |
import gradio as gr
|
2 |
+
from diffusers import DiffusionPipeline
|
3 |
+
import torch
|
4 |
+
from gradio_client import Client
|
5 |
+
pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, use_safetensors=True, variant="fp16")
|
6 |
+
if torch.cuda.is_available(): pipe.to("cuda")
|
7 |
+
client = Client("stabilityai/triposr")
|
8 |
+
|
9 |
+
|
10 |
ABOUT_TEXT = """
|
11 |
# Text-to-3D with TripoSR + SDXL
|
12 |
|
|
|
14 |
|
15 |
For image-to-3D, use [TripoSR](https://huggingface.co/spaces/stabilityai/TripoSR) directly.
|
16 |
""".strip()
|
17 |
+
def generate(text):
|
18 |
+
# generate image
|
19 |
+
image = pipe(prompt=text).images[0]
|
20 |
+
# preprocess
|
21 |
+
result = client.predict(
|
22 |
+
image,
|
23 |
+
True,
|
24 |
+
0.85,
|
25 |
+
api_name="/preprocess"
|
26 |
+
)
|
27 |
+
result = client.predict(
|
28 |
+
result,
|
29 |
+
api_name="/generate"
|
30 |
+
)
|
31 |
+
return result
|
32 |
+
|
33 |
with gr.Blocks() as demo:
|
34 |
gr.Markdown(ABOUT_TEXT)
|
35 |
+
txt = gr.Textbox(interactive=True, label="Text instruction")
|
36 |
+
btn = gr.Button("Generate")
|
37 |
+
out = gr.Model3D(
|
38 |
+
label="3D model",
|
39 |
+
interactive=False,
|
40 |
+
)
|
41 |
+
btn.click(generate, inputs=txt, outputs=out)
|
42 |
demo.queue(api_open=False, default_concurrency_limit=20).launch(show_api=False)
|