diff --git a/nodes.py b/nodes.py index 2553d58..d3b9c86 100644 --- a/nodes.py +++ b/nodes.py @@ -618,7 +618,10 @@ class CreateTextMask: text_height = font_size text_center_x = text_x + text_width / 2 text_center_y = text_y + text_height / 2 - draw.text((text_x, text_y), text, font=font, fill=font_color, features=['-liga']) + try: + draw.text((text_x, text_y), text, font=font, fill=font_color, features=['-liga']) + except: + draw.text((text_x, text_y), text, font=font, fill=font_color) if start_rotation != end_rotation: image = image.rotate(rotation, center=(text_center_x, text_center_y)) rotation += rotation_increment @@ -1386,7 +1389,10 @@ class ImageBatchTestPattern: text_x = (width - text_width / 2) // 2 text_y = (height - text_height) // 2 - draw.text((text_x, text_y), str(number + start_from), font=font, fill=color, features=['-liga']) + try: + draw.text((text_x, text_y), text, font=font, fill=font_color, features=['-liga']) + except: + draw.text((text_x, text_y), text, font=font, fill=font_color) # Convert the image to a numpy array and normalize the pixel values image = np.array(image).astype(np.float32) / 255.0 @@ -2759,7 +2765,11 @@ class AddLabel: label_image = Image.new("RGB", (width, height), label_color) draw = ImageDraw.Draw(label_image) font = ImageFont.truetype(font_path, font_size) - draw.text((text_x, text_y), text, font=font, fill=font_color, features=['-liga']) + try: + draw.text((text_x, text_y), text, font=font, fill=font_color, features=['-liga']) + except: + draw.text((text_x, text_y), text, font=font, fill=font_color) + label_image = np.array(label_image).astype(np.float32) / 255.0 label_image = torch.from_numpy(label_image)[None, :, :, :] # Duplicate the label image for the entire batch