Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -176,6 +176,7 @@ def extract_gaussian(state: dict, req: gr.Request) -> Tuple[str, str]:
|
|
| 176 |
torch.cuda.empty_cache()
|
| 177 |
return gaussian_path, gaussian_path
|
| 178 |
|
|
|
|
| 179 |
# Gradio Interface
|
| 180 |
# Gradio Interface
|
| 181 |
with gr.Blocks() as demo:
|
|
@@ -183,10 +184,8 @@ with gr.Blocks() as demo:
|
|
| 183 |
## Game Asset Generation to 3D with FLUX and TRELLIS
|
| 184 |
* Enter a prompt to generate a game asset image, then convert it to 3D
|
| 185 |
* If you find the generated 3D asset satisfactory, click "Extract GLB" to extract the GLB file and download it.
|
| 186 |
-
* [TRELLIS Model](https://huggingface.co/JeffreyXiang/TRELLIS-image-large) [Trellis Github](https://github.com/microsoft/TRELLIS) [Flux-Dev](https://huggingface.co/black-forest-labs/FLUX.1-dev)
|
| 187 |
-
* [Flux Game Assets LoRA](https://huggingface.co/gokaygokay/Flux-Game-Assets-LoRA-v2) [Hyper FLUX 8Steps LoRA](https://huggingface.co/ByteDance/Hyper-SD) [safetensors to GGUF for Flux](https://github.com/ruSauron/to-gguf-bat) [Thanks to John6666](https://huggingface.co/John6666)
|
| 188 |
""")
|
| 189 |
-
|
| 190 |
with gr.Row():
|
| 191 |
with gr.Column():
|
| 192 |
# Flux image generation inputs
|
|
@@ -199,7 +198,7 @@ with gr.Blocks() as demo:
|
|
| 199 |
height = gr.Slider(512, 1024, label="Height", value=1024, step=16)
|
| 200 |
with gr.Row():
|
| 201 |
guidance_scale = gr.Slider(0.0, 10.0, label="Guidance Scale", value=3.5, step=0.1)
|
| 202 |
-
|
| 203 |
# Botones separados
|
| 204 |
generate_image_btn = gr.Button("Generar Imagen")
|
| 205 |
generate_video_btn = gr.Button("Generar Video", interactive=False)
|
|
@@ -207,17 +206,28 @@ with gr.Blocks() as demo:
|
|
| 207 |
with gr.Column():
|
| 208 |
generated_image = gr.Image(label="Generated Asset", type="pil")
|
| 209 |
video_output = gr.Video(label="Generated 3D Asset", autoplay=True, loop=True)
|
| 210 |
-
|
| 211 |
model_output = LitModel3D(label="Extracted GLB/Gaussian", exposure=8.0, height=400)
|
| 212 |
-
|
| 213 |
with gr.Row():
|
| 214 |
extract_glb_btn = gr.Button("Extract GLB", interactive=False)
|
| 215 |
extract_gs_btn = gr.Button("Extract Gaussian", interactive=False)
|
| 216 |
-
|
| 217 |
with gr.Row():
|
| 218 |
download_glb = gr.DownloadButton(label="Download GLB", interactive=False)
|
| 219 |
download_gs = gr.DownloadButton(label="Download Gaussian", interactive=False)
|
| 220 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 221 |
# Estado para almacenar la imagen generada temporalmente
|
| 222 |
temp_image_state = gr.State()
|
| 223 |
output_buf = gr.State()
|
|
@@ -239,7 +249,14 @@ with gr.Blocks() as demo:
|
|
| 239 |
# Generar video
|
| 240 |
generate_video_btn.click(
|
| 241 |
image_to_3d,
|
| 242 |
-
inputs=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 243 |
outputs=[output_buf, video_output],
|
| 244 |
).then(
|
| 245 |
lambda: tuple([gr.Button(interactive=True), gr.Button(interactive=True)]),
|
|
@@ -265,7 +282,6 @@ with gr.Blocks() as demo:
|
|
| 265 |
lambda: gr.Button(interactive=True),
|
| 266 |
outputs=[download_gs],
|
| 267 |
)
|
| 268 |
-
|
| 269 |
# Initialize both pipelines
|
| 270 |
if __name__ == "__main__":
|
| 271 |
from diffusers import FluxTransformer2DModel, FluxPipeline, BitsAndBytesConfig, GGUFQuantizationConfig
|
|
|
|
| 176 |
torch.cuda.empty_cache()
|
| 177 |
return gaussian_path, gaussian_path
|
| 178 |
|
| 179 |
+
# Gradio Interface
|
| 180 |
# Gradio Interface
|
| 181 |
# Gradio Interface
|
| 182 |
with gr.Blocks() as demo:
|
|
|
|
| 184 |
## Game Asset Generation to 3D with FLUX and TRELLIS
|
| 185 |
* Enter a prompt to generate a game asset image, then convert it to 3D
|
| 186 |
* If you find the generated 3D asset satisfactory, click "Extract GLB" to extract the GLB file and download it.
|
|
|
|
|
|
|
| 187 |
""")
|
| 188 |
+
|
| 189 |
with gr.Row():
|
| 190 |
with gr.Column():
|
| 191 |
# Flux image generation inputs
|
|
|
|
| 198 |
height = gr.Slider(512, 1024, label="Height", value=1024, step=16)
|
| 199 |
with gr.Row():
|
| 200 |
guidance_scale = gr.Slider(0.0, 10.0, label="Guidance Scale", value=3.5, step=0.1)
|
| 201 |
+
|
| 202 |
# Botones separados
|
| 203 |
generate_image_btn = gr.Button("Generar Imagen")
|
| 204 |
generate_video_btn = gr.Button("Generar Video", interactive=False)
|
|
|
|
| 206 |
with gr.Column():
|
| 207 |
generated_image = gr.Image(label="Generated Asset", type="pil")
|
| 208 |
video_output = gr.Video(label="Generated 3D Asset", autoplay=True, loop=True)
|
| 209 |
+
|
| 210 |
model_output = LitModel3D(label="Extracted GLB/Gaussian", exposure=8.0, height=400)
|
| 211 |
+
|
| 212 |
with gr.Row():
|
| 213 |
extract_glb_btn = gr.Button("Extract GLB", interactive=False)
|
| 214 |
extract_gs_btn = gr.Button("Extract Gaussian", interactive=False)
|
| 215 |
+
|
| 216 |
with gr.Row():
|
| 217 |
download_glb = gr.DownloadButton(label="Download GLB", interactive=False)
|
| 218 |
download_gs = gr.DownloadButton(label="Download Gaussian", interactive=False)
|
| 219 |
+
|
| 220 |
+
# Variables adicionales para la generaci贸n 3D
|
| 221 |
+
with gr.Accordion("3D Generation Settings", open=False):
|
| 222 |
+
gr.Markdown("Stage 1: Sparse Structure Generation")
|
| 223 |
+
with gr.Row():
|
| 224 |
+
ss_guidance_strength = gr.Slider(0.0, 10.0, label="Guidance Strength", value=7.5, step=0.1)
|
| 225 |
+
ss_sampling_steps = gr.Slider(1, 50, label="Sampling Steps", value=12, step=1)
|
| 226 |
+
gr.Markdown("Stage 2: Structured Latent Generation")
|
| 227 |
+
with gr.Row():
|
| 228 |
+
slat_guidance_strength = gr.Slider(0.0, 10.0, label="Guidance Strength", value=3.0, step=0.1)
|
| 229 |
+
slat_sampling_steps = gr.Slider(1, 50, label="Sampling Steps", value=12, step=1)
|
| 230 |
+
|
| 231 |
# Estado para almacenar la imagen generada temporalmente
|
| 232 |
temp_image_state = gr.State()
|
| 233 |
output_buf = gr.State()
|
|
|
|
| 249 |
# Generar video
|
| 250 |
generate_video_btn.click(
|
| 251 |
image_to_3d,
|
| 252 |
+
inputs=[
|
| 253 |
+
temp_image_state,
|
| 254 |
+
seed,
|
| 255 |
+
ss_guidance_strength,
|
| 256 |
+
ss_sampling_steps,
|
| 257 |
+
slat_guidance_strength,
|
| 258 |
+
slat_sampling_steps
|
| 259 |
+
],
|
| 260 |
outputs=[output_buf, video_output],
|
| 261 |
).then(
|
| 262 |
lambda: tuple([gr.Button(interactive=True), gr.Button(interactive=True)]),
|
|
|
|
| 282 |
lambda: gr.Button(interactive=True),
|
| 283 |
outputs=[download_gs],
|
| 284 |
)
|
|
|
|
| 285 |
# Initialize both pipelines
|
| 286 |
if __name__ == "__main__":
|
| 287 |
from diffusers import FluxTransformer2DModel, FluxPipeline, BitsAndBytesConfig, GGUFQuantizationConfig
|