Spaces:
Configuration error
Configuration error
Upload 2 files
Browse files
app.py
CHANGED
|
@@ -5,18 +5,15 @@ import threading
|
|
| 5 |
from pathlib import Path
|
| 6 |
|
| 7 |
# === Runtime environment tweaks ===
|
| 8 |
-
os.environ.setdefault("CUDA_VISIBLE_DEVICES", "")
|
| 9 |
os.environ.setdefault("WORLDGEN_DISABLE_EVAL", "1")
|
| 10 |
os.environ.setdefault("GRADIO_TEMP_DIR", "/tmp/gradio")
|
| 11 |
|
| 12 |
# Monkey patch to avoid CUDA errors
|
| 13 |
import nunchaku.utils
|
| 14 |
-
|
| 15 |
def safe_get_precision(*args, **kwargs):
|
| 16 |
return "fp32"
|
| 17 |
-
|
| 18 |
nunchaku.utils.get_precision = safe_get_precision
|
| 19 |
-
|
| 20 |
try:
|
| 21 |
import nunchaku.models.transformers.transformer_flux as tf
|
| 22 |
tf.get_precision = safe_get_precision
|
|
@@ -31,7 +28,7 @@ _wg = None
|
|
| 31 |
def get_worldgen():
|
| 32 |
global _wg
|
| 33 |
if _wg is None:
|
| 34 |
-
#
|
| 35 |
model_path = hf_hub_download(
|
| 36 |
repo_id="mit-han-lab/svdq-int4-flux.1-dev",
|
| 37 |
filename="unquantized_layers.safetensors",
|
|
@@ -79,14 +76,17 @@ def generate_from_text(prompt: str):
|
|
| 79 |
return zip_path, "Done. Download the ZIP (contains 3D assets)."
|
| 80 |
|
| 81 |
with gr.Blocks(title="WorldGen • Text -> 3D Scene") as demo:
|
| 82 |
-
gr.Markdown("# WorldGen - Text -> 3D
|
| 83 |
with gr.Row():
|
| 84 |
with gr.Column():
|
| 85 |
-
prompt = gr.Textbox(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
btn = gr.Button("Generate 3D Scene")
|
| 87 |
with gr.Column():
|
| 88 |
out_zip = gr.File(label="Download output (ZIP)")
|
| 89 |
status = gr.Markdown()
|
| 90 |
btn.click(generate_from_text, inputs=[prompt], outputs=[out_zip, status])
|
| 91 |
-
|
| 92 |
demo.launch()
|
|
|
|
| 5 |
from pathlib import Path
|
| 6 |
|
| 7 |
# === Runtime environment tweaks ===
|
| 8 |
+
os.environ.setdefault("CUDA_VISIBLE_DEVICES", "")
|
| 9 |
os.environ.setdefault("WORLDGEN_DISABLE_EVAL", "1")
|
| 10 |
os.environ.setdefault("GRADIO_TEMP_DIR", "/tmp/gradio")
|
| 11 |
|
| 12 |
# Monkey patch to avoid CUDA errors
|
| 13 |
import nunchaku.utils
|
|
|
|
| 14 |
def safe_get_precision(*args, **kwargs):
|
| 15 |
return "fp32"
|
|
|
|
| 16 |
nunchaku.utils.get_precision = safe_get_precision
|
|
|
|
| 17 |
try:
|
| 18 |
import nunchaku.models.transformers.transformer_flux as tf
|
| 19 |
tf.get_precision = safe_get_precision
|
|
|
|
| 28 |
def get_worldgen():
|
| 29 |
global _wg
|
| 30 |
if _wg is None:
|
| 31 |
+
# Confirm model file is downloadable
|
| 32 |
model_path = hf_hub_download(
|
| 33 |
repo_id="mit-han-lab/svdq-int4-flux.1-dev",
|
| 34 |
filename="unquantized_layers.safetensors",
|
|
|
|
| 76 |
return zip_path, "Done. Download the ZIP (contains 3D assets)."
|
| 77 |
|
| 78 |
with gr.Blocks(title="WorldGen • Text -> 3D Scene") as demo:
|
| 79 |
+
gr.Markdown("# WorldGen - Text -> 3D")
|
| 80 |
with gr.Row():
|
| 81 |
with gr.Column():
|
| 82 |
+
prompt = gr.Textbox(
|
| 83 |
+
label="Scene prompt (English)",
|
| 84 |
+
placeholder="a neon-lit cyberpunk street with rain reflections, highly detailed",
|
| 85 |
+
lines=3,
|
| 86 |
+
)
|
| 87 |
btn = gr.Button("Generate 3D Scene")
|
| 88 |
with gr.Column():
|
| 89 |
out_zip = gr.File(label="Download output (ZIP)")
|
| 90 |
status = gr.Markdown()
|
| 91 |
btn.click(generate_from_text, inputs=[prompt], outputs=[out_zip, status])
|
|
|
|
| 92 |
demo.launch()
|