prafullcodes commited on
Commit
509ce6f
·
verified ·
1 Parent(s): 9873893

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -4,14 +4,14 @@ from diffusers import StableDiffusionImg2ImgPipeline
4
  from PIL import Image
5
 
6
  def load_model():
7
- device = "cpu" # Force CPU usage for low-end machines
8
- model_id = "runwayml/stable-diffusion-v1-5" # Use a lighter model for better performance
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, colorful, fantasy world"
14
- result = pipe(prompt=prompt, image=image, strength=0.6, guidance_scale=5.0).images[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