File size: 1,171 Bytes
21c3200
79aea11
 
a9e03ae
79aea11
 
21c3200
 
 
 
 
 
 
79aea11
 
a9e03ae
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79aea11
 
 
 
 
 
 
 
 
 
 
 
 
21c3200
 
79aea11
 
 
 
 
 
 
21c3200
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
46
47
48
49
50
51
52
53
54
55
56
import gradio as gr
from gradio_client import Client
client = Client("stabilityai/triposr")
sdxl = Client("hysts/SD-XL")


ABOUT_TEXT = """
# Text-to-3D with TripoSR + SDXL

Commercially-viable text-to-3D model. Usage must comply with the SDXL license.

For image-to-3D, use [TripoSR](https://huggingface.co/spaces/stabilityai/TripoSR) directly.
""".strip()
def generate(text):
    # generate image
    image = sdxl.predict(
		text,
		"",
		"",
		"",
		False,
		False,
		False,
        0,
		1024,
		1024,
		5,
		5,
		25,
		25,
		False,	# bool  in 'Apply refiner' Checkbox component
		api_name="/run"
    )
    # preprocess
    result = client.predict(
		image,
		True,
		0.85,
        api_name="/preprocess"
    )
    result = client.predict(
		result,
        api_name="/generate"
    )
    return result
    
with gr.Blocks() as demo:
    gr.Markdown(ABOUT_TEXT)
    txt = gr.Textbox(interactive=True, label="Text instruction")
    btn = gr.Button("Generate")
    out = gr.Model3D(
        label="3D model",
        interactive=False,
    )
    btn.click(generate, inputs=txt, outputs=out)
demo.queue(api_open=False, default_concurrency_limit=20).launch(show_api=False)