mikeee/diffusers-test
0
1"""https://pypi.org/project/diffusers/.2 3!pip install git+https://github.com/patil-suraj/transformers@ldm-bert4!git clone https://github.com/huggingface/diffusers5!cd diffusers && pip install -e .6!pip install git+file:///content/diffusers7!pip install torch8 9https://github.com/CompVis/latent-diffusion/blob/main/scripts/txt2img.py10 11https://medium.com/tag/diffusion-models12 13 !pip install einops14 15"""16from diffusers import DiffusionPipeline17 18ldm = DiffusionPipeline.from_pretrained("fu sing/latent-diffusion-text2im-large")19 20generator = torch.manual_seed(42)21 22prompt = "A painting of a squirrel eating a burger"23image = ldm([prompt], generator=generator, eta=0.3, guidance_scale=6.0, num_inference_steps=50)24 25image_processed = image.cpu().permute(0, 2, 3, 1)26image_processed = image_processed * 255.27image_processed = image_processed.numpy().astype(np.uint8)28image_pil = PIL.Image.fromarray(image_processed[0])29 30# save image31image_pil.save("test.png")