Spaces:
Running
Running
app.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from gradio_client import Client, handle_file
|
| 3 |
|
| 4 |
-
# Gradio Interface Functions
|
| 5 |
def start_session():
|
| 6 |
client = Client("JeffreyXiang/TRELLIS")
|
| 7 |
result = client.predict(api_name="/start_session")
|
|
@@ -82,70 +81,88 @@ def lambda_6_function():
|
|
| 82 |
result = client.predict(api_name="/lambda_6")
|
| 83 |
return result
|
| 84 |
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
"
|
| 90 |
-
"
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
"
|
| 95 |
-
"
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
"
|
| 100 |
-
"
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
"
|
| 105 |
-
"
|
| 106 |
-
"
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
"
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
gr.
|
| 119 |
-
|
| 120 |
-
"
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
)
|
| 150 |
-
|
| 151 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from gradio_client import Client, handle_file
|
| 3 |
|
|
|
|
| 4 |
def start_session():
|
| 5 |
client = Client("JeffreyXiang/TRELLIS")
|
| 6 |
result = client.predict(api_name="/start_session")
|
|
|
|
| 81 |
result = client.predict(api_name="/lambda_6")
|
| 82 |
return result
|
| 83 |
|
| 84 |
+
with gr.Blocks(title="TRELLIS API Client") as demo:
|
| 85 |
+
gr.Markdown("# TRELLIS API Client")
|
| 86 |
+
|
| 87 |
+
with gr.Tab("Start Session"):
|
| 88 |
+
start_btn = gr.Button("Start Session")
|
| 89 |
+
start_output = gr.Textbox(label="Output")
|
| 90 |
+
start_btn.click(fn=start_session, inputs=[], outputs=start_output)
|
| 91 |
+
|
| 92 |
+
with gr.Tab("Lambda"):
|
| 93 |
+
lambda_btn = gr.Button("Run Lambda")
|
| 94 |
+
lambda_output = gr.Textbox(label="Output")
|
| 95 |
+
lambda_btn.click(fn=lambda_function, inputs=[], outputs=lambda_output)
|
| 96 |
+
|
| 97 |
+
with gr.Tab("Lambda 1"):
|
| 98 |
+
lambda1_btn = gr.Button("Run Lambda 1")
|
| 99 |
+
lambda1_output = gr.Textbox(label="Output")
|
| 100 |
+
lambda1_btn.click(fn=lambda_1_function, inputs=[], outputs=lambda1_output)
|
| 101 |
+
|
| 102 |
+
with gr.Tab("Preprocess Image"):
|
| 103 |
+
image_input = gr.Image(type="filepath", label="Input Image")
|
| 104 |
+
preprocess_btn = gr.Button("Preprocess")
|
| 105 |
+
image_output = gr.Image(type="filepath", label="Processed Image")
|
| 106 |
+
preprocess_btn.click(fn=preprocess_image, inputs=image_input, outputs=image_output)
|
| 107 |
+
|
| 108 |
+
with gr.Tab("Preprocess Images"):
|
| 109 |
+
images_input = gr.Gallery(label="Input Images")
|
| 110 |
+
preprocess_images_btn = gr.Button("Preprocess")
|
| 111 |
+
images_output = gr.Gallery(label="Processed Images")
|
| 112 |
+
preprocess_images_btn.click(fn=preprocess_images, inputs=images_input, outputs=images_output)
|
| 113 |
+
|
| 114 |
+
with gr.Tab("Get Seed"):
|
| 115 |
+
with gr.Row():
|
| 116 |
+
randomize = gr.Checkbox(value=True, label="Randomize Seed")
|
| 117 |
+
seed = gr.Slider(minimum=0, maximum=100, value=0, label="Seed")
|
| 118 |
+
seed_btn = gr.Button("Get Seed")
|
| 119 |
+
seed_output = gr.Textbox(label="Output")
|
| 120 |
+
seed_btn.click(fn=get_seed, inputs=[randomize, seed], outputs=seed_output)
|
| 121 |
+
|
| 122 |
+
with gr.Tab("Image to 3D"):
|
| 123 |
+
img_input = gr.Image(type="filepath", label="Image")
|
| 124 |
+
multi_imgs = gr.Gallery(label="Multi Images")
|
| 125 |
+
with gr.Row():
|
| 126 |
+
img_seed = gr.Slider(minimum=0, maximum=100, value=0, label="Seed")
|
| 127 |
+
ss_guidance = gr.Slider(minimum=0, maximum=10, value=7.5, label="SS Guidance Strength")
|
| 128 |
+
with gr.Row():
|
| 129 |
+
ss_steps = gr.Slider(minimum=0, maximum=20, value=12, label="SS Sampling Steps")
|
| 130 |
+
slat_guidance = gr.Slider(minimum=0, maximum=10, value=3, label="SLAT Guidance Strength")
|
| 131 |
+
with gr.Row():
|
| 132 |
+
slat_steps = gr.Slider(minimum=0, maximum=20, value=12, label="SLAT Sampling Steps")
|
| 133 |
+
algo = gr.Radio(choices=["stochastic", "multidiffusion"], value="stochastic", label="Multi-image Algorithm")
|
| 134 |
+
generate_btn = gr.Button("Generate 3D")
|
| 135 |
+
video_output = gr.Video(label="Generated 3D")
|
| 136 |
+
generate_btn.click(
|
| 137 |
+
fn=image_to_3d,
|
| 138 |
+
inputs=[img_input, multi_imgs, img_seed, ss_guidance, ss_steps, slat_guidance, slat_steps, algo],
|
| 139 |
+
outputs=video_output
|
| 140 |
+
)
|
| 141 |
+
|
| 142 |
+
with gr.Tab("Extract GLB"):
|
| 143 |
+
with gr.Row():
|
| 144 |
+
mesh_simplify = gr.Slider(minimum=0, maximum=1, value=0.95, label="Mesh Simplify")
|
| 145 |
+
texture_size = gr.Slider(minimum=0, maximum=2048, value=1024, label="Texture Size")
|
| 146 |
+
extract_glb_btn = gr.Button("Extract GLB")
|
| 147 |
+
glb_output = gr.File(label="GLB File")
|
| 148 |
+
extract_glb_btn.click(fn=extract_glb, inputs=[mesh_simplify, texture_size], outputs=glb_output)
|
| 149 |
+
|
| 150 |
+
with gr.Tab("Extract Gaussian"):
|
| 151 |
+
extract_gaussian_btn = gr.Button("Extract Gaussian")
|
| 152 |
+
gaussian_output = gr.File(label="Gaussian File")
|
| 153 |
+
extract_gaussian_btn.click(fn=extract_gaussian, inputs=[], outputs=gaussian_output)
|
| 154 |
+
|
| 155 |
+
# Add remaining lambda functions as simple buttons with text output
|
| 156 |
+
for name, func in [
|
| 157 |
+
("Lambda 2", lambda_2_function),
|
| 158 |
+
("Lambda 3", lambda_3_function),
|
| 159 |
+
("Lambda 4", lambda_4_function),
|
| 160 |
+
("Lambda 5", lambda_5_function),
|
| 161 |
+
("Lambda 6", lambda_6_function),
|
| 162 |
+
]:
|
| 163 |
+
with gr.Tab(name):
|
| 164 |
+
btn = gr.Button(f"Run {name}")
|
| 165 |
+
output = gr.Textbox(label="Output")
|
| 166 |
+
btn.click(fn=func, inputs=[], outputs=output)
|
| 167 |
+
|
| 168 |
+
demo.launch()
|