Spaces:
Build error
Build error
Commit
·
56e36e2
1
Parent(s):
1db7700
Update app.py
Browse files
app.py
CHANGED
@@ -62,26 +62,30 @@ def get_pose(image):
|
|
62 |
|
63 |
|
64 |
def generate_an_image_from_text(text, text_size_, width, lenght):
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
|
|
|
|
|
|
|
|
85 |
|
86 |
def to_Canny(image):
|
87 |
# Let's load the popular vermeer image
|
|
|
62 |
|
63 |
|
64 |
def generate_an_image_from_text(text, text_size_, width, lenght):
|
65 |
+
# Create a blank image
|
66 |
+
image = Image.new('RGB', (width, lenght), color = (255, 255, 255))
|
67 |
+
# Create a drawing object
|
68 |
+
draw = ImageDraw.Draw(image)
|
69 |
+
# font def
|
70 |
+
font_dir = ''
|
71 |
+
# Get a list of all the font files in the directory
|
72 |
+
font_files = glob.glob(os.path.join(dir_path, 'fonts', '*.ttf'))
|
73 |
+
# Get a list of font paths
|
74 |
+
font_paths = []
|
75 |
+
for font_file in font_files:
|
76 |
+
font_paths.append(font_file)
|
77 |
+
# Select a random font
|
78 |
+
font_path = random.choice(font_paths)
|
79 |
+
#print(font_path)
|
80 |
+
font = ImageFont.truetype(font_path, text_size_)
|
81 |
+
# Get the text size
|
82 |
+
text_size = draw.textsize(text, font)
|
83 |
+
# Calculate the x and y positions for the text
|
84 |
+
x = (image.width - text_size[0]) / 2
|
85 |
+
y = (image.height - text_size[1]) / 2
|
86 |
+
# Draw the text on the image
|
87 |
+
draw.text((x, y), text, fill=(0, 0, 0), font=font)
|
88 |
+
return image
|
89 |
|
90 |
def to_Canny(image):
|
91 |
# Let's load the popular vermeer image
|