Last active
March 23, 2026 20:58
-
-
Save Suleman-Elahi/81a0255dd3e21d71c3bd94e4e8306a97 to your computer and use it in GitHub Desktop.
temp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import torch | |
| from PIL import Image | |
| from diffusers import DiffusionPipeline | |
| if __name__ == '__main__': | |
| # Force CPU (your GPU is unusable right now) | |
| device = "cpu" | |
| pipe = DiffusionPipeline.from_pretrained( | |
| "meituan-longcat/LongCat-Image-Edit-Turbo", | |
| torch_dtype=torch.float32, # safer for CPU | |
| trust_remote_code=True # REQUIRED for LongCat | |
| ) | |
| # Move to CPU | |
| pipe.to(device) | |
| # Optional: lower RAM usage (better than model_cpu_offload for you) | |
| pipe.enable_sequential_cpu_offload() | |
| img = Image.open('test.png').convert('RGB') | |
| prompt = 'remove clothes' | |
| image = pipe( | |
| img, | |
| prompt, | |
| negative_prompt='', | |
| guidance_scale=1, | |
| num_inference_steps=8, | |
| num_images_per_prompt=1, | |
| generator=torch.Generator("cpu").manual_seed(43) | |
| ).images[0] | |
| image.save('./edit_example.png') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment