Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from PIL import Image
|
3 |
+
|
4 |
+
|
5 |
+
def add_watermark(image):
|
6 |
+
image = Image.fromarray(np.uint8(image))
|
7 |
+
watermark = Image.open("watermark.png")
|
8 |
+
|
9 |
+
image = image.convert("RGBA")
|
10 |
+
watermark = watermark.convert("RGBA")
|
11 |
+
|
12 |
+
width = image.width()
|
13 |
+
height = image.height()
|
14 |
+
|
15 |
+
image.paste(watermark, (width, height), watermark)
|
16 |
+
return image
|
17 |
+
|
18 |
+
gr.Interface(fn=add_watermark,
|
19 |
+
inputs="image",
|
20 |
+
outputs="image",
|
21 |
+
title="Add watermark",
|
22 |
+
examples = ["example.jpg"]
|
23 |
+
).launch();
|