Spaces:
Configuration error
Configuration error
Upload 2 files
Browse files
app.py
CHANGED
|
@@ -9,15 +9,15 @@ os.environ.setdefault("CUDA_VISIBLE_DEVICES", "") # force CPU
|
|
| 9 |
os.environ.setdefault("WORLDGEN_DISABLE_EVAL", "1") # avoid KNN/eval paths if supported
|
| 10 |
os.environ.setdefault("GRADIO_TEMP_DIR", "/tmp/gradio") # centralize gradio cache
|
| 11 |
|
| 12 |
-
# Monkey patch to avoid CUDA errors
|
| 13 |
-
|
| 14 |
-
import nunchaku.utils
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
|
| 19 |
-
|
| 20 |
|
|
|
|
| 21 |
import nunchaku.models.transformers.transformer_flux as tf
|
| 22 |
tf.get_precision = safe_get_precision
|
| 23 |
except Exception:
|
|
@@ -26,18 +26,11 @@ except Exception:
|
|
| 26 |
import gradio as gr
|
| 27 |
from worldgen import WorldGen
|
| 28 |
|
| 29 |
-
# Lazy init
|
| 30 |
_wg = None
|
| 31 |
def get_worldgen():
|
| 32 |
global _wg
|
| 33 |
if _wg is None:
|
| 34 |
-
_wg = WorldGen(
|
| 35 |
-
mode="t2s",
|
| 36 |
-
device="cpu",
|
| 37 |
-
low_vram=True,
|
| 38 |
-
lora_path=None,
|
| 39 |
-
repo_id="mit-han-lab/svdq-int4-flux.1-dev"
|
| 40 |
-
)
|
| 41 |
return _wg
|
| 42 |
|
| 43 |
def _zip_directory(dir_path: Path) -> str:
|
|
@@ -92,9 +85,9 @@ def generate_from_text(prompt: str):
|
|
| 92 |
|
| 93 |
return zip_path, "Done. Download the ZIP (contains 3D assets)."
|
| 94 |
|
| 95 |
-
with gr.Blocks(title="WorldGen • Text
|
| 96 |
gr.Markdown(
|
| 97 |
-
"""# WorldGen - Text
|
| 98 |
- CPU-only fallback is enabled. For real runs, switch the Space to a GPU (T4/A10G).
|
| 99 |
- Outputs are zipped for download; temp files are cleaned shortly after each run.
|
| 100 |
"""
|
|
|
|
| 9 |
os.environ.setdefault("WORLDGEN_DISABLE_EVAL", "1") # avoid KNN/eval paths if supported
|
| 10 |
os.environ.setdefault("GRADIO_TEMP_DIR", "/tmp/gradio") # centralize gradio cache
|
| 11 |
|
| 12 |
+
# Monkey patch get_precision 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
|
| 23 |
except Exception:
|
|
|
|
| 26 |
import gradio as gr
|
| 27 |
from worldgen import WorldGen
|
| 28 |
|
|
|
|
| 29 |
_wg = None
|
| 30 |
def get_worldgen():
|
| 31 |
global _wg
|
| 32 |
if _wg is None:
|
| 33 |
+
_wg = WorldGen(mode="t2s", device="cpu", low_vram=True, lora_path=None)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
return _wg
|
| 35 |
|
| 36 |
def _zip_directory(dir_path: Path) -> str:
|
|
|
|
| 85 |
|
| 86 |
return zip_path, "Done. Download the ZIP (contains 3D assets)."
|
| 87 |
|
| 88 |
+
with gr.Blocks(title="WorldGen • Text -> 3D Scene") as demo:
|
| 89 |
gr.Markdown(
|
| 90 |
+
"""# WorldGen - Text -> 3D
|
| 91 |
- CPU-only fallback is enabled. For real runs, switch the Space to a GPU (T4/A10G).
|
| 92 |
- Outputs are zipped for download; temp files are cleaned shortly after each run.
|
| 93 |
"""
|