LPX55's picture
Create raw.py
1250a66 verified
raw
history blame
913 Bytes
import torch
from diffusers.utils import load_image
from diffusers import FluxControlNetModel
from diffusers.pipelines import FluxControlNetPipeline
import spaces
# Load pipeline
controlnet = FluxControlNetModel.from_pretrained(
"jasperai/Flux.1-dev-Controlnet-Upscaler",
torch_dtype=torch.bfloat16
)
pipe = FluxControlNetPipeline.from_pretrained(
"black-forest-labs/FLUX.1-dev",
controlnet=controlnet,
torch_dtype=torch.bfloat16
)
pipe.to("cuda")
# Load a control image
control_image = load_image(
"https://img.getimg.ai/generated/img-HvTBfR1W1RUhykk7gmBUYp.png"
)
w, h = control_image.size
# Upscale x4
control_image = control_image.resize((w * 2, h * 2))
image = pipe(
prompt="",
control_image=control_image,
controlnet_conditioning_scale=0.6,
num_inference_steps=14,
guidance_scale=3.5,
height=control_image.size[1],
width=control_image.size[0]
).images[0]
image