Alexi Canales commited on
Commit
6d3dbcc
·
1 Parent(s): 0e178a1

Initial Commit

Browse files
Files changed (3) hide show
  1. .gitignore +1 -0
  2. app.py +37 -0
  3. requirements.txt +5 -0
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ venv
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from PIL import Image, ImageDraw, ImageFont
3
+ from diffusers import StableDiffusionInstructPix2PixPipeline
4
+ import torch
5
+
6
+ # Load the model (once)
7
+ pipe = StableDiffusionInstructPix2PixPipeline.from_pretrained(
8
+ "timbrooks/instruct-pix2pix",
9
+ torch_dtype=torch.float16,
10
+ safety_checker=None
11
+ ).to("cuda")
12
+
13
+ def stylize(image: Image.Image, quote: str) -> Image.Image:
14
+ # Step 1: Stylize with instruct-pix2pix
15
+ edited_image = pipe(image=image, prompt="neon filter", image_guidance_scale=1.5).images[0]
16
+
17
+ # Step 2: Overlay text
18
+ draw = ImageDraw.Draw(edited_image)
19
+ font = ImageFont.load_default()
20
+ width, height = edited_image.size
21
+ draw.text((10, height - 40), quote, font=font, fill="cyan")
22
+
23
+ return edited_image
24
+
25
+ interface = gr.Interface(
26
+ fn=stylize,
27
+ inputs=[
28
+ gr.Image(type="pil", label="Upload Your Photo"),
29
+ gr.Textbox(label="Your Quote")
30
+ ],
31
+ outputs=gr.Image(type="pil", label="Neon Image"),
32
+ title="Neon Image Stylizer",
33
+ description="Upload an image of your business or product and add your quote. We'll stylize it with a neon effect!"
34
+ )
35
+
36
+ if __name__ == "__main__":
37
+ interface.launch()
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ gradio
2
+ diffusers
3
+ transformers
4
+ torch
5
+ Pillow