ghibli / app.py
daniissac's picture
Update app.py
1b4f79a verified
raw
history blame
781 Bytes
import gradio as gr
import torch
from diffusers import StableDiffusionPipeline
device = "cuda" if torch.cuda.is_available() else "cpu"
model_id = "nitrosocke/Ghibli-Diffusion"
# Load the model
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16 if device == "cuda" else torch.float32)
pipe.to(device)
def generate_ghibli_style(image):
prompt = "ghibli style portrait"
result = pipe(prompt, init_image=image, strength=0.75, guidance_scale=7.0, num_inference_steps=30).images[0]
return result
iface = gr.Interface(
fn=generate_ghibli_style,
inputs=gr.Image(type="pil"),
outputs=gr.Image(),
title="Studio Ghibli Portrait Generator",
description="Upload a photo to generate a Ghibli-style portrait!"
)
iface.launch()