joan772 commited on
Commit
25a39e8
·
verified ·
1 Parent(s): 12791d2

Create index.py

Browse files
Files changed (1) hide show
  1. index.py +27 -0
index.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ !pip install gradio diffusers transformers accelerate torch torchvision
2
+
3
+ from diffusers import StableDiffusionPipeline
4
+ import torch
5
+ import gradio as gr
6
+ from PIL import Image
7
+
8
+ # Stable Diffusion ka Ghibli-style model load karna
9
+ model_id = "nitrosocke/Ghibli-Diffusion"
10
+ pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
11
+ pipe.to("cuda" if torch.cuda.is_available() else "cpu")
12
+
13
+ def convert_to_ghibli(image):
14
+ prompt = "A Studio Ghibli-style anime painting"
15
+ ghibli_image = pipe(prompt, image=image).images[0]
16
+ return ghibli_image
17
+
18
+ # Gradio Web App
19
+ interface = gr.Interface(
20
+ fn=convert_to_ghibli,
21
+ inputs=gr.Image(type="pil"),
22
+ outputs="image",
23
+ title="Studio Ghibli Image Converter 🎨",
24
+ description="Upload an image, and convert it to a Studio Ghibli-style artwork!",
25
+ )
26
+
27
+ interface.launch(share=True)