Download sampling.py from yamiuchi/qm-image: direct link, hf CLI and curl.
- Browser
- Download file 870 Bytes
-
https://huggingface.co/spaces/yamiuchi/qm-image/resolve/main/sampling.py
- Command line
-
hf download hf://spaces/yamiuchi/qm-image/sampling.py
-
curl -L -o sampling.py https://huggingface.co/spaces/yamiuchi/qm-image/resolve/main/sampling.py
870 Bytes
| """The MOSS Turbo loop is deliberately separate from ComfyUI's Euler sampler.""" | |
| def moss_turbo_sample(noise, mixing, codes, predict, tensor_ops, callback=None): | |
| if tuple(mixing.shape) != (128, 128) or len(codes) != 8: | |
| raise ValueError("MOSS Turboには128×128のQと8個のstep_codesが必要です。") | |
| if noise.shape[1] != 128: | |
| raise ValueError("MOSS Turboのlatent channelsは128です。") | |
| clean = tensor_ops.zeros_like(noise) | |
| for index in range(8): | |
| mixed = noise + tensor_ops.einsum("oc,bchw->bohw", mixing, clean) | |
| # Identical initial noise at every step, no Euler dt and no CFG branch. | |
| velocity = predict(mixed, codes[index]) | |
| clean = noise - velocity.float() if hasattr(velocity, "float") else noise - velocity | |
| if callback is not None: | |
| callback(index + 1, 8) | |
| return clean | |