Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -22,10 +22,6 @@ oneFormer_model = OneFormerForUniversalSegmentation.from_pretrained("shi-labs/on
|
|
| 22 |
|
| 23 |
|
| 24 |
# Функции для обработки изображений
|
| 25 |
-
from PIL import Image, ImageDraw
|
| 26 |
-
from gradio_client import Client, handle_file
|
| 27 |
-
import numpy as np
|
| 28 |
-
|
| 29 |
def segment_image(image):
|
| 30 |
image = Image.fromarray(image)
|
| 31 |
inputs = oneFormer_processor(image, task_inputs=["panoptic"], return_tensors="pt")
|
|
@@ -183,7 +179,7 @@ def generate_3d_model(client, segment_output, segment_name):
|
|
| 183 |
api_name="/shape_generation"
|
| 184 |
)
|
| 185 |
print(result)
|
| 186 |
-
return result[0]
|
| 187 |
|
| 188 |
def generate_3d_model_texture(client, segment_output, segment_name):
|
| 189 |
for i, (image_path, label) in enumerate(segment_output):
|
|
@@ -199,7 +195,7 @@ def generate_3d_model_texture(client, segment_output, segment_name):
|
|
| 199 |
api_name="/generation_all"
|
| 200 |
)
|
| 201 |
print(result)
|
| 202 |
-
return result[1]
|
| 203 |
|
| 204 |
def generate_3d_model2(client, segment_output, segment_name):
|
| 205 |
for i, (image_path, label) in enumerate(segment_output):
|
|
@@ -209,7 +205,7 @@ def generate_3d_model2(client, segment_output, segment_name):
|
|
| 209 |
api_name="/step_1_generate_obj"
|
| 210 |
)
|
| 211 |
print(result)
|
| 212 |
-
return result[0]
|
| 213 |
|
| 214 |
|
| 215 |
# def classify_segments(segments):
|
|
@@ -254,22 +250,24 @@ with gr.Blocks() as demo:
|
|
| 254 |
vFusion_button = gr.Button("VFusion3D")
|
| 255 |
with gr.Column(scale=5):
|
| 256 |
# trellis_output = gr.Video(label="Generated 3D Asset", autoplay=True, loop=True, height=300)
|
| 257 |
-
trellis_output2 = LitModel3D(
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
)
|
|
|
|
|
|
|
| 269 |
# trellis_button.click(generate_3d_model, inputs=[client, segment_output, trellis_input], outputs=trellis_output)
|
| 270 |
-
hunyuan_button.click(generate_3d_model, inputs=[hunyuan_client, segment_output, trellis_input], outputs=trellis_output2)
|
| 271 |
-
hunyuan_button_texture.click(generate_3d_model_texture, inputs=[hunyuan_client, segment_output, trellis_input], outputs=trellis_output2)
|
| 272 |
-
vFusion_button.click(generate_3d_model2, inputs=[vFusion_client, segment_output, trellis_input], outputs=trellis_output2)
|
| 273 |
|
| 274 |
segment_button.click(segment_image, inputs=image_input, outputs=segment_output)
|
| 275 |
# segment_button.click(segment_full_image, inputs=image_input, outputs=segment_output)
|
|
|
|
| 22 |
|
| 23 |
|
| 24 |
# Функции для обработки изображений
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
def segment_image(image):
|
| 26 |
image = Image.fromarray(image)
|
| 27 |
inputs = oneFormer_processor(image, task_inputs=["panoptic"], return_tensors="pt")
|
|
|
|
| 179 |
api_name="/shape_generation"
|
| 180 |
)
|
| 181 |
print(result)
|
| 182 |
+
return (result[0], result[0])
|
| 183 |
|
| 184 |
def generate_3d_model_texture(client, segment_output, segment_name):
|
| 185 |
for i, (image_path, label) in enumerate(segment_output):
|
|
|
|
| 195 |
api_name="/generation_all"
|
| 196 |
)
|
| 197 |
print(result)
|
| 198 |
+
return (result[1], result[1])
|
| 199 |
|
| 200 |
def generate_3d_model2(client, segment_output, segment_name):
|
| 201 |
for i, (image_path, label) in enumerate(segment_output):
|
|
|
|
| 205 |
api_name="/step_1_generate_obj"
|
| 206 |
)
|
| 207 |
print(result)
|
| 208 |
+
return (result[0], result[0])
|
| 209 |
|
| 210 |
|
| 211 |
# def classify_segments(segments):
|
|
|
|
| 250 |
vFusion_button = gr.Button("VFusion3D")
|
| 251 |
with gr.Column(scale=5):
|
| 252 |
# trellis_output = gr.Video(label="Generated 3D Asset", autoplay=True, loop=True, height=300)
|
| 253 |
+
# trellis_output2 = LitModel3D(
|
| 254 |
+
# clear_color=[0.1, 0.1, 0.1, 0], # can adjust background color for better contrast
|
| 255 |
+
# label="3D Model Visualization",
|
| 256 |
+
# scale=1.0,
|
| 257 |
+
# tonemapping="aces", # can use aces tonemapping for more realistic lighting
|
| 258 |
+
# exposure=1.0, # can adjust exposure to control brightness
|
| 259 |
+
# contrast=1.1, # can slightly increase contrast for better depth
|
| 260 |
+
# camera_position=(0, 0, 2), # will set initial camera position to center the model
|
| 261 |
+
# zoom_speed=0.5, # will adjust zoom speed for better control
|
| 262 |
+
# pan_speed=0.5, # will adjust pan speed for better control
|
| 263 |
+
# interactive=True # this allow users to interact with the model
|
| 264 |
+
# )
|
| 265 |
+
trellis_output = gr.Model3D(label="3D Model")
|
| 266 |
+
trellis_output2 = gr.Model3D(clear_color=[0.0, 0.0, 0.0, 0.0], label="3D Model Wireframe")
|
| 267 |
# trellis_button.click(generate_3d_model, inputs=[client, segment_output, trellis_input], outputs=trellis_output)
|
| 268 |
+
hunyuan_button.click(generate_3d_model, inputs=[hunyuan_client, segment_output, trellis_input], outputs=[trellis_output, trellis_output2])
|
| 269 |
+
hunyuan_button_texture.click(generate_3d_model_texture, inputs=[hunyuan_client, segment_output, trellis_input], outputs=[trellis_output, trellis_output2])
|
| 270 |
+
vFusion_button.click(generate_3d_model2, inputs=[vFusion_client, segment_output, trellis_input], outputs=[trellis_output, trellis_output2])
|
| 271 |
|
| 272 |
segment_button.click(segment_image, inputs=image_input, outputs=segment_output)
|
| 273 |
# segment_button.click(segment_full_image, inputs=image_input, outputs=segment_output)
|