Update app.py
Browse files
app.py
CHANGED
|
@@ -45,7 +45,23 @@ pipe = StableDiffusionXLFillPipeline.from_pretrained(
|
|
| 45 |
pipe.scheduler = TCDScheduler.from_config(pipe.scheduler.config)
|
| 46 |
|
| 47 |
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
def fill_image(prompt, image, model_selection, paste_back):
|
| 50 |
(
|
| 51 |
prompt_embeds,
|
|
@@ -80,6 +96,7 @@ def fill_image(prompt, image, model_selection, paste_back):
|
|
| 80 |
else:
|
| 81 |
cnet_image = image
|
| 82 |
|
|
|
|
| 83 |
yield source, cnet_image
|
| 84 |
|
| 85 |
|
|
|
|
| 45 |
pipe.scheduler = TCDScheduler.from_config(pipe.scheduler.config)
|
| 46 |
|
| 47 |
|
| 48 |
+
def add_watermark(image, text="ProFaker", font_path="BRLNSDB.TTF", font_size=25):
|
| 49 |
+
# Load the Berlin Sans Demi font with the specified size
|
| 50 |
+
font = ImageFont.truetype(font_path, font_size)
|
| 51 |
+
|
| 52 |
+
# Position the watermark in the bottom right corner, adjusting for text size
|
| 53 |
+
text_bbox = font.getbbox(text)
|
| 54 |
+
text_width, text_height = text_bbox[2], text_bbox[3]
|
| 55 |
+
watermark_position = (image.width - text_width - 100, image.height - text_height - 150)
|
| 56 |
+
|
| 57 |
+
# Draw the watermark text with a translucent white color
|
| 58 |
+
draw = ImageDraw.Draw(image)
|
| 59 |
+
draw.text(watermark_position, text, font=font, fill=(255, 255, 255, 150)) # RGBA for transparency
|
| 60 |
+
|
| 61 |
+
return image
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
@spaces.GPU
|
| 65 |
def fill_image(prompt, image, model_selection, paste_back):
|
| 66 |
(
|
| 67 |
prompt_embeds,
|
|
|
|
| 96 |
else:
|
| 97 |
cnet_image = image
|
| 98 |
|
| 99 |
+
cnet_image = add_watermark(cnet_image)
|
| 100 |
yield source, cnet_image
|
| 101 |
|
| 102 |
|