Stable diffusion img2img
In [ ]:
Copied!
!git clone https://github.com/soumik12345/wandb-addons
!pip install ./wandb-addons[huggingface]
!git clone https://github.com/soumik12345/wandb-addons
!pip install ./wandb-addons[huggingface]
In [ ]:
Copied!
import requests
import torch
from PIL import Image
from io import BytesIO
from diffusers import StableDiffusionImg2ImgPipeline
from wandb_addons.diffusers import get_wandb_callback
import requests
import torch
from PIL import Image
from io import BytesIO
from diffusers import StableDiffusionImg2ImgPipeline
from wandb_addons.diffusers import get_wandb_callback
In [ ]:
Copied!
pipe = StableDiffusionImg2ImgPipeline.from_pretrained(
"runwayml/stable-diffusion-v1-5", torch_dtype=torch.float16
)
pipe = pipe.to("cuda")
pipe = StableDiffusionImg2ImgPipeline.from_pretrained(
"runwayml/stable-diffusion-v1-5", torch_dtype=torch.float16
)
pipe = pipe.to("cuda")
In [ ]:
Copied!
url = "https://raw.githubusercontent.com/CompVis/stable-diffusion/main/assets/stable-samples/img2img/sketch-mountains-input.jpg"
response = requests.get(url)
init_image = Image.open(BytesIO(response.content)).convert("RGB")
init_image = init_image.resize((768, 512))
prompt = "A fantasy landscape, trending on artstation"
url = "https://raw.githubusercontent.com/CompVis/stable-diffusion/main/assets/stable-samples/img2img/sketch-mountains-input.jpg"
response = requests.get(url)
init_image = Image.open(BytesIO(response.content)).convert("RGB")
init_image = init_image.resize((768, 512))
prompt = "A fantasy landscape, trending on artstation"
In [ ]:
Copied!
num_images_per_prompt = 1
num_inference_steps = 50
strength = 0.75
callback = get_wandb_callback(
pipeline=pipe, prompt=prompt,
input_images=init_image,
wandb_project="diffusers-2",
wandb_entity="geekyrakshit",
weave_mode=True,
num_images_per_prompt=num_images_per_prompt,
num_inference_steps=num_inference_steps,
strength=strength,
)
results = pipe(
prompt=prompt,
image=init_image,
strength=strength,
num_images_per_prompt=num_images_per_prompt,
num_inference_steps=num_inference_steps,
callback=callback
)
num_images_per_prompt = 1
num_inference_steps = 50
strength = 0.75
callback = get_wandb_callback(
pipeline=pipe, prompt=prompt,
input_images=init_image,
wandb_project="diffusers-2",
wandb_entity="geekyrakshit",
weave_mode=True,
num_images_per_prompt=num_images_per_prompt,
num_inference_steps=num_inference_steps,
strength=strength,
)
results = pipe(
prompt=prompt,
image=init_image,
strength=strength,
num_images_per_prompt=num_images_per_prompt,
num_inference_steps=num_inference_steps,
callback=callback
)