Views
No views yet
1from diffusers.pipelines import BlipDiffusionPipeline
2from diffusers.utils import load_image
3import torch
4
5blip_diffusion_pipe = BlipDiffusionPipeline.from_pretrained(
6 "Salesforce/blipdiffusion", torch_dtype=torch.float16
7).to("cuda")
8
9cond_subject = "dog"
10tgt_subject = "dog"
11text_prompt_input = "swimming underwater"
12
13cond_image = load_image(
14 "https://huggingface.co/datasets/ayushtues/blipdiffusion_images/resolve/main/dog.jpg"
15)
16
17iter_seed = 88888
18guidance_scale = 7.5
19num_inference_steps = 25
20negative_prompt = "over-exposure, under-exposure, saturated, duplicate, out of frame, lowres, cropped, worst quality, low quality, jpeg artifacts, morbid, mutilated, out of frame, ugly, bad anatomy, bad proportions, deformed, blurry, duplicate"
21
22output = blip_diffusion_pipe(
23 text_prompt_input,
24 cond_image,
25 cond_subject,
26 tgt_subject,
27 guidance_scale=guidance_scale,
28 num_inference_steps=num_inference_steps,
29 neg_prompt=negative_prompt,
30 height=512,
31 width=512,
32).images
33output[0].save("image.png")

1from diffusers.pipelines import BlipDiffusionControlNetPipeline
2from diffusers.utils import load_image
3from controlnet_aux import CannyDetector
4
5blip_diffusion_pipe = BlipDiffusionControlNetPipeline.from_pretrained(
6 "Salesforce/blipdiffusion-controlnet", torch_dtype=torch.float16
7).to("cuda")
8
9style_subject = "flower" # subject that defines the style
10tgt_subject = "teapot" # subject to generate.
11text_prompt = "on a marble table"
12
13cldm_cond_image = load_image(
14 "https://huggingface.co/datasets/ayushtues/blipdiffusion_images/resolve/main/kettle.jpg"
15).resize((512, 512))
16canny = CannyDetector()
17cldm_cond_image = canny(cldm_cond_image, 30, 70, output_type="pil")
18style_image = load_image(
19 "https://huggingface.co/datasets/ayushtues/blipdiffusion_images/resolve/main/flower.jpg"
20)
21
22guidance_scale = 7.5
23num_inference_steps = 50
24negative_prompt = "over-exposure, under-exposure, saturated, duplicate, out of frame, lowres, cropped, worst quality, low quality, jpeg artifacts, morbid, mutilated, out of frame, ugly, bad anatomy, bad proportions, deformed, blurry, duplicate"
25
26output = blip_diffusion_pipe(
27 text_prompt,
28 style_image,
29 cldm_cond_image,
30 style_subject,
31 tgt_subject,
32 guidance_scale=guidance_scale,
33 num_inference_steps=num_inference_steps,
34 neg_prompt=negative_prompt,
35 height=512,
36 width=512,
37).images
38output[0].save("image.png")


1from diffusers.pipelines import BlipDiffusionControlNetPipeline
2from diffusers.utils import load_image
3from controlnet_aux import HEDdetector
4
5blip_diffusion_pipe = BlipDiffusionControlNetPipeline.from_pretrained(
6 "Salesforce/blipdiffusion-controlnet"
7)
8controlnet = ControlNetModel.from_pretrained("lllyasviel/sd-controlnet-scribble")
9blip_diffusion_pipe.controlnet = controlnet
10blip_diffusion_pipe.to("cuda")
11
12style_subject = "flower" # subject that defines the style
13tgt_subject = "bag" # subject to generate.
14text_prompt = "on a table"
15cldm_cond_image = load_image(
16 "https://huggingface.co/lllyasviel/sd-controlnet-scribble/resolve/main/images/bag.png"
17).resize((512, 512))
18hed = HEDdetector.from_pretrained("lllyasviel/Annotators")
19cldm_cond_image = hed(cldm_cond_image)
20style_image = load_image(
21 "https://huggingface.co/datasets/ayushtues/blipdiffusion_images/resolve/main/flower.jpg"
22)
23
24guidance_scale = 7.5
25num_inference_steps = 50
26negative_prompt = "over-exposure, under-exposure, saturated, duplicate, out of frame, lowres, cropped, worst quality, low quality, jpeg artifacts, morbid, mutilated, out of frame, ugly, bad anatomy, bad proportions, deformed, blurry, duplicate"
27
28output = blip_diffusion_pipe(
29 text_prompt,
30 style_image,
31 cldm_cond_image,
32 style_subject,
33 tgt_subject,
34 guidance_scale=guidance_scale,
35 num_inference_steps=num_inference_steps,
36 neg_prompt=negative_prompt,
37 height=512,
38 width=512,
39).images
40output[0].save("image.png")




@misc{li2023blipdiffusion,
title={BLIP-Diffusion: Pre-trained Subject Representation for Controllable Text-to-Image Generation and Editing},
author={Dongxu Li and Junnan Li and Steven C. H. Hoi},
year={2023},
eprint={2305.14720},
archivePrefix={arXiv},
primaryClass={cs.CV}
}