Spaces:
Sleeping
Sleeping
File size: 1,041 Bytes
2562825 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
import gradio as gr
import torch
from diffusers import StableDiffusionPipeline
from PIL import Image
# Load the pre-trained Ghibli-Diffusion model
model_id = "nitrosocke/Ghibli-Diffusion"
pipeline = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
pipeline.to("cuda") # Ensure GPU acceleration
def generate_ghibli_portrait(image):
# Convert input image to PIL format
input_image = Image.open(image).convert("RGB").resize((512, 512))
# Generate image using the model
prompt = "Ghibli-style portrait of a person, highly detailed, soft lighting"
result = pipeline(prompt=prompt, image=input_image).images[0]
return result
# Gradio UI
demo = gr.Interface(
fn=generate_ghibli_portrait,
inputs=gr.Image(type="file", label="Upload your photo"),
outputs=gr.Image(label="Ghibli-style Portrait"),
title="Studio Ghibli Portrait Generator",
description="Upload your photo to generate a Ghibli-style portrait using AI."
)
if __name__ == "__main__":
demo.launch()
|