Update app.py
Browse files
app.py
CHANGED
|
@@ -10,6 +10,12 @@ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
|
| 10 |
weights_path = "unet_model.pth"
|
| 11 |
model = load_model(weights_path, device)
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
def process_image(image, text, font_size, text_color):
|
| 14 |
image = image.convert("RGB")
|
| 15 |
print(f"image: {image}")
|
|
@@ -20,7 +26,7 @@ def process_image(image, text, font_size, text_color):
|
|
| 20 |
font = ImageFont.truetype(font_path, font_size)
|
| 21 |
text_position = (50, 50)
|
| 22 |
# text_color = (0, 0, 0)
|
| 23 |
-
text_color =
|
| 24 |
draw.text(text_position, text, fill=text_color, font=font)
|
| 25 |
|
| 26 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
|
|
|
| 10 |
weights_path = "unet_model.pth"
|
| 11 |
model = load_model(weights_path, device)
|
| 12 |
|
| 13 |
+
def hex_to_rgb(hex_color):
|
| 14 |
+
hex_color = hex_color.lstrip("#")
|
| 15 |
+
if len(hex_color) == 3:
|
| 16 |
+
hex_color = "".join([c * 2 for c in hex_color])
|
| 17 |
+
return tuple(int(hex_color[i:i+2], 16) for i in (0, 2, 4))
|
| 18 |
+
|
| 19 |
def process_image(image, text, font_size, text_color):
|
| 20 |
image = image.convert("RGB")
|
| 21 |
print(f"image: {image}")
|
|
|
|
| 26 |
font = ImageFont.truetype(font_path, font_size)
|
| 27 |
text_position = (50, 50)
|
| 28 |
# text_color = (0, 0, 0)
|
| 29 |
+
text_color = hex_to_rgb(text_color)
|
| 30 |
draw.text(text_position, text, fill=text_color, font=font)
|
| 31 |
|
| 32 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|