Download config/refine.py from modventures/room-visualizer-v2: direct link, hf CLI and curl.
- Browser
- Download file 3.87 kB
-
https://huggingface.co/spaces/modventures/room-visualizer-v2/resolve/main/config/refine.py
- Command line
-
hf download hf://spaces/modventures/room-visualizer-v2/config/refine.py
-
curl -L -o refine.py https://huggingface.co/spaces/modventures/room-visualizer-v2/resolve/main/config/refine.py
3.87 kB
| """Configuration for the SDXL refinement pass.""" | |
| from config.loader import config_bool, config_value | |
| REFINE_ENABLED = config_bool("REFINE_ENABLED", "refine", "enabled", "1") | |
| # Refinement on CPU is not viable -- SDXL would take tens of minutes per pass. | |
| # Left on so a CPU dev box returns a clear 503 instead of hanging. | |
| REFINE_REQUIRE_CUDA = config_bool("REFINE_REQUIRE_CUDA", "refine", "require_cuda", "1") | |
| REFINE_BASE_MODEL = str(config_value( | |
| "REFINE_BASE_MODEL", "refine", "base_model", | |
| "diffusers/stable-diffusion-xl-1.0-inpainting-0.1", | |
| )) | |
| REFINE_CONTROLNET_MODEL = str(config_value( | |
| "REFINE_CONTROLNET_MODEL", "refine", "controlnet_model", | |
| "diffusers/controlnet-depth-sdxl-1.0", | |
| )) | |
| # Processing resolution. Drop to 768 on a 16 GB card if a pass hits CUDA OOM; | |
| # raise to 1024 where there is headroom. Rounded down to a multiple of 8. | |
| REFINE_MAX_DIMENSION = max(512, int(config_value( | |
| "REFINE_MAX_DIMENSION", "refine", "max_dimension", "896", | |
| ))) | |
| REFINE_SEED = int(config_value("REFINE_SEED", "refine", "seed", "42")) | |
| # "detail-recovery" keeps SDXL's look and restores texture from the projection. | |
| # "realism-guide" keeps the projection and transfers only SDXL's illumination. | |
| REFINE_BLEND_MODE = str(config_value( | |
| "REFINE_BLEND_MODE", "refine", "blend_mode", "detail-recovery", | |
| )).strip().lower() | |
| REFINE_USE_LIGHTING_TRANSFER = config_bool( | |
| "REFINE_USE_LIGHTING_TRANSFER", "refine", "use_lighting_transfer", "1") | |
| REFINE_USE_SHADOW_TRANSFER = config_bool( | |
| "REFINE_USE_SHADOW_TRANSFER", "refine", "use_shadow_transfer", "1") | |
| REFINE_USE_MATERIAL_MICRODETAIL = config_bool( | |
| "REFINE_USE_MATERIAL_MICRODETAIL", "refine", "use_material_microdetail", "0") | |
| REFINE_USE_CAMERA_NOISE = config_bool( | |
| "REFINE_USE_CAMERA_NOISE", "refine", "use_camera_noise", "0") | |
| REFINE_USE_POST_SHADOW_RESTORE = config_bool( | |
| "REFINE_USE_POST_SHADOW_RESTORE", "refine", "use_post_shadow_restore", "1") | |
| # Free OneFormer / MoGe / depth before loading SDXL. They are idle by the time | |
| # refinement runs and together with SDXL they will not fit a 16 GB card. | |
| REFINE_UNLOAD_CV_MODELS = config_bool( | |
| "REFINE_UNLOAD_CV_MODELS", "refine", "unload_cv_models", "1") | |
| # Stream SDXL submodules from CPU instead of holding the whole pipeline on the | |
| # GPU. Roughly halves peak VRAM and roughly doubles pass time. | |
| REFINE_CPU_OFFLOAD = config_bool("REFINE_CPU_OFFLOAD", "refine", "cpu_offload", "0") | |
| # Park SDXL in CPU RAM when the GPU is handed back, instead of dropping it. | |
| # | |
| # The GPU cannot hold SDXL (~9.5 GB fp16) and the CV models (~3.5 GB) at once | |
| # on a 15 GB card, so one set always has to yield. Dropping the pipeline means | |
| # the next refinement re-parses ~7 GB of safetensors off disk, which is the | |
| # multi-minute "Loading refinement model" wait. Parking keeps the weights in | |
| # RAM and makes the round trip a PCIe copy instead. | |
| # | |
| # Costs ~7 GB of system RAM, so it is skipped automatically when the host does | |
| # not have the headroom -- see models.loader. | |
| # Use one material-neutral prompt per plane instead of per-material text. | |
| # | |
| # The material type is a keyword guess against the tile's name, and it is wrong | |
| # more often than it is right on the current catalogue ("Black Marble | |
| # Herringbone" resolves to wood). A wrong material prompt tells SDXL to convert | |
| # the surface rather than photograph it, which is worse than saying nothing. | |
| # Set to 0 to go back to the per-material prompt text, which is still present. | |
| REFINE_GENERIC_PROMPT = config_bool( | |
| "REFINE_GENERIC_PROMPT", "refine", "generic_prompt", "1") | |
| REFINE_PARK_ON_CPU = config_bool("REFINE_PARK_ON_CPU", "refine", "park_on_cpu", "1") | |
| REFINE_PARK_MIN_FREE_RAM_GB = float( | |
| config_value("REFINE_PARK_MIN_FREE_RAM_GB", "refine", "park_min_free_ram_gb", "9.0")) | |
| REFINE_TARGET_MS = max(5_000, int(config_value( | |
| "REFINE_TARGET_MS", "refine", "target_ms", "120000", | |
| ))) | |