Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,14 +4,14 @@ from diffusers import StableDiffusionImg2ImgPipeline
|
|
| 4 |
from PIL import Image
|
| 5 |
|
| 6 |
def load_model():
|
| 7 |
-
device = "
|
| 8 |
-
model_id = "
|
| 9 |
-
return StableDiffusionImg2ImgPipeline.from_pretrained(model_id, torch_dtype=torch.float32).to(device)
|
| 10 |
|
| 11 |
def ghibli_transform(image):
|
| 12 |
pipe = load_model()
|
| 13 |
-
prompt = "Ghibli style painting, highly detailed,
|
| 14 |
-
result = pipe(prompt=prompt, image=image, strength=0.
|
| 15 |
return result
|
| 16 |
|
| 17 |
def main():
|
|
@@ -20,7 +20,7 @@ def main():
|
|
| 20 |
inputs=gr.Image(type="pil"),
|
| 21 |
outputs=gr.Image(type="pil"),
|
| 22 |
title="Ghibli Style Image Transformer",
|
| 23 |
-
description="Upload an image to convert it into a Studio Ghibli-style artwork!",
|
| 24 |
)
|
| 25 |
iface.launch()
|
| 26 |
|
|
|
|
| 4 |
from PIL import Image
|
| 5 |
|
| 6 |
def load_model():
|
| 7 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 8 |
+
model_id = "Linaqruf/animagine-xl" # Fine-tuned model for anime/Ghibli-style images
|
| 9 |
+
return StableDiffusionImg2ImgPipeline.from_pretrained(model_id, torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32).to(device)
|
| 10 |
|
| 11 |
def ghibli_transform(image):
|
| 12 |
pipe = load_model()
|
| 13 |
+
prompt = "Ghibli style painting, vibrant colors, highly detailed, soft lighting, Studio Ghibli artwork"
|
| 14 |
+
result = pipe(prompt=prompt, image=image, strength=0.5, num_inference_steps=30, guidance_scale=7.0).images[0] # Optimized for quality
|
| 15 |
return result
|
| 16 |
|
| 17 |
def main():
|
|
|
|
| 20 |
inputs=gr.Image(type="pil"),
|
| 21 |
outputs=gr.Image(type="pil"),
|
| 22 |
title="Ghibli Style Image Transformer",
|
| 23 |
+
description="Upload an image to convert it into a high-quality Studio Ghibli-style artwork!",
|
| 24 |
)
|
| 25 |
iface.launch()
|
| 26 |
|