Spaces:
Running on Zero
Running on Zero
Fix random noise output by properly stripping the 'model.diffusion_model.' prefix from the AIO safetensors file before loading the state_dict.
Browse files
app.py
CHANGED
|
@@ -106,7 +106,14 @@ state_dict = load_file(ckpt_path)
|
|
| 106 |
config = QwenImageTransformer2DModel.load_config("Qwen/Qwen-Image-Edit-2511", subfolder="transformer")
|
| 107 |
transformer = QwenImageTransformer2DModel.from_config(config)
|
| 108 |
transformer.to(dtype)
|
| 109 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
|
| 111 |
# 3. Explicitly wipe the 28.4GB state_dict from CPU RAM
|
| 112 |
del state_dict
|
|
|
|
| 106 |
config = QwenImageTransformer2DModel.load_config("Qwen/Qwen-Image-Edit-2511", subfolder="transformer")
|
| 107 |
transformer = QwenImageTransformer2DModel.from_config(config)
|
| 108 |
transformer.to(dtype)
|
| 109 |
+
|
| 110 |
+
# Extract only the transformer keys and strip the prefix
|
| 111 |
+
transformer_state_dict = {}
|
| 112 |
+
for k, v in state_dict.items():
|
| 113 |
+
if k.startswith("model.diffusion_model."):
|
| 114 |
+
transformer_state_dict[k.replace("model.diffusion_model.", "")] = v
|
| 115 |
+
|
| 116 |
+
transformer.load_state_dict(transformer_state_dict, strict=False)
|
| 117 |
|
| 118 |
# 3. Explicitly wipe the 28.4GB state_dict from CPU RAM
|
| 119 |
del state_dict
|