Skip to content

Instantly share code, notes, and snippets.

@Suleman-Elahi
Last active March 23, 2026 20:58
Show Gist options
  • Select an option

  • Save Suleman-Elahi/81a0255dd3e21d71c3bd94e4e8306a97 to your computer and use it in GitHub Desktop.

Select an option

Save Suleman-Elahi/81a0255dd3e21d71c3bd94e4e8306a97 to your computer and use it in GitHub Desktop.
temp
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