ghibli / app.py
daniissac's picture
Update app.py
ddd1d55 verified
raw
history blame
815 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 = "Studio Ghibli style portrait of a person, highly detailed, beautiful colors"
result = pipe(prompt, init_image=image, strength=0.75).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, and this AI will transform it into a Ghibli-style portrait!"
)
iface.launch()