Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -95,9 +95,8 @@ def merge_segments_by_labels(gallery_images, labels_input):
|
|
| 95 |
|
| 96 |
def set_hunyuan_client(request: gr.Request):
|
| 97 |
try:
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
print(x_ip_token, "tencent/Hunyuan3D-2 Ip token")
|
| 101 |
return client
|
| 102 |
except:
|
| 103 |
print("tencent/Hunyuan3D-2 no token")
|
|
@@ -105,9 +104,8 @@ def set_hunyuan_client(request: gr.Request):
|
|
| 105 |
|
| 106 |
def set_vFusion_client(request: gr.Request):
|
| 107 |
try:
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
print(x_ip_token, "facebook/VFusion3D Ip token")
|
| 111 |
return client
|
| 112 |
except:
|
| 113 |
print("facebook/VFusion3D no token")
|
|
@@ -129,9 +127,11 @@ def generate_3d_model(client, segment_output, segment_name):
|
|
| 129 |
print(result)
|
| 130 |
return result[0]
|
| 131 |
|
| 132 |
-
def generate_3d_model_texture(client, segment_output, segment_name):
|
| 133 |
for i, (image_path, label) in enumerate(segment_output):
|
| 134 |
if label == segment_name:
|
|
|
|
|
|
|
| 135 |
result = client.predict(
|
| 136 |
caption="",
|
| 137 |
image=handle_file(image_path),
|
|
@@ -195,21 +195,8 @@ with gr.Blocks() as demo:
|
|
| 195 |
hunyuan_button_texture = gr.Button("Hunyuan3D-2 (with texture)")
|
| 196 |
vFusion_button = gr.Button("VFusion3D")
|
| 197 |
with gr.Column(scale=5):
|
| 198 |
-
# trellis_output = gr.Video(label="Generated 3D Asset", autoplay=True, loop=True, height=300)
|
| 199 |
-
# trellis_output2 = LitModel3D(
|
| 200 |
-
# clear_color=[0.1, 0.1, 0.1, 0], # can adjust background color for better contrast
|
| 201 |
-
# label="3D Model Visualization",
|
| 202 |
-
# scale=1.0,
|
| 203 |
-
# tonemapping="aces", # can use aces tonemapping for more realistic lighting
|
| 204 |
-
# exposure=1.0, # can adjust exposure to control brightness
|
| 205 |
-
# contrast=1.1, # can slightly increase contrast for better depth
|
| 206 |
-
# camera_position=(0, 0, 2), # will set initial camera position to center the model
|
| 207 |
-
# zoom_speed=0.5, # will adjust zoom speed for better control
|
| 208 |
-
# pan_speed=0.5, # will adjust pan speed for better control
|
| 209 |
-
# interactive=True # this allow users to interact with the model
|
| 210 |
-
# )
|
| 211 |
trellis_output = gr.Model3D(label="3D Model")
|
| 212 |
-
|
| 213 |
hunyuan_button.click(generate_3d_model, inputs=[hunyuan_client, segment_output, trellis_input], outputs=trellis_output)
|
| 214 |
hunyuan_button_texture.click(generate_3d_model_texture, inputs=[hunyuan_client, segment_output, trellis_input], outputs=trellis_output)
|
| 215 |
vFusion_button.click(generate_3d_model2, inputs=[vFusion_client, segment_output, trellis_input], outputs=trellis_output)
|
|
|
|
| 95 |
|
| 96 |
def set_hunyuan_client(request: gr.Request):
|
| 97 |
try:
|
| 98 |
+
client = Client("tencent/Hunyuan3D-2", headers={"X-IP-Token": request.headers['x-ip-token']})
|
| 99 |
+
print("tencent/Hunyuan3D-2 Ip token")
|
|
|
|
| 100 |
return client
|
| 101 |
except:
|
| 102 |
print("tencent/Hunyuan3D-2 no token")
|
|
|
|
| 104 |
|
| 105 |
def set_vFusion_client(request: gr.Request):
|
| 106 |
try:
|
| 107 |
+
client = Client("facebook/VFusion3D", headers={"X-IP-Token": request.headers['x-ip-token']})
|
| 108 |
+
print("facebook/VFusion3D Ip token")
|
|
|
|
| 109 |
return client
|
| 110 |
except:
|
| 111 |
print("facebook/VFusion3D no token")
|
|
|
|
| 127 |
print(result)
|
| 128 |
return result[0]
|
| 129 |
|
| 130 |
+
def generate_3d_model_texture(client, segment_output, segment_name, request: gr.Request):
|
| 131 |
for i, (image_path, label) in enumerate(segment_output):
|
| 132 |
if label == segment_name:
|
| 133 |
+
client = Client("tencent/Hunyuan3D-2", headers={"X-IP-Token": request.headers['x-ip-token']})
|
| 134 |
+
print("tencent/Hunyuan3D-2 new client token")
|
| 135 |
result = client.predict(
|
| 136 |
caption="",
|
| 137 |
image=handle_file(image_path),
|
|
|
|
| 195 |
hunyuan_button_texture = gr.Button("Hunyuan3D-2 (with texture)")
|
| 196 |
vFusion_button = gr.Button("VFusion3D")
|
| 197 |
with gr.Column(scale=5):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
trellis_output = gr.Model3D(label="3D Model")
|
| 199 |
+
|
| 200 |
hunyuan_button.click(generate_3d_model, inputs=[hunyuan_client, segment_output, trellis_input], outputs=trellis_output)
|
| 201 |
hunyuan_button_texture.click(generate_3d_model_texture, inputs=[hunyuan_client, segment_output, trellis_input], outputs=trellis_output)
|
| 202 |
vFusion_button.click(generate_3d_model2, inputs=[vFusion_client, segment_output, trellis_input], outputs=trellis_output)
|