| import gradio as gr |
| from PIL import Image |
| import torch |
| from diffusers import StableDiffusionImg2ImgPipeline |
|
|
| pipe = StableDiffusionImg2ImgPipeline.from_pretrained( |
| "hakurei/waifu-diffusion", |
| torch_dtype=torch.float32 |
| ).to("cpu") |
|
|
| def generate_ghibli_style(image, prompt): |
| result = pipe(prompt=prompt, image=image, strength=0.6, guidance_scale=7.5) |
| return result.images[0] |
|
|
| gr.Interface( |
| fn=generate_ghibli_style, |
| inputs=[gr.Image(type="pil"), gr.Textbox(label="Prompt")], |
| outputs=gr.Image(type="pil"), |
| title="Ghibli Style Generator (Anime Style)", |
| description="Upload a photo and get a Ghibli-inspired result using waifu-diffusion.", |
| ).launch() |