From 27164de8b84185c9b4d91b8482adb98d76776c7d Mon Sep 17 00:00:00 2001 From: Jonathan <34005131+JPPhoto@users.noreply.github.com> Date: Fri, 29 Sep 2023 06:55:34 -0500 Subject: [PATCH] Fix absolute path for font file Make the font file relative to this source file. Not ideal, but it will work no matter where InvokeAI is launched. --- invokeai/app/invocations/facetools.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/invokeai/app/invocations/facetools.py b/invokeai/app/invocations/facetools.py index c64a842dbb..f02e4d476a 100644 --- a/invokeai/app/invocations/facetools.py +++ b/invokeai/app/invocations/facetools.py @@ -1,5 +1,7 @@ import math +import os import re +from pathlib import Path from typing import Optional, TypedDict import cv2 @@ -75,8 +77,6 @@ def create_black_image(w: int, h: int) -> ImageType: FONT_SIZE = 32 FONT_STROKE_WIDTH = 4 -font = ImageFont.truetype("invokeai/assets/fonts/inter/Inter-Regular.ttf", FONT_SIZE) - def prepare_faces_list( face_result_list: list[FaceResultData], @@ -641,6 +641,10 @@ class FaceIdentifierInvocation(BaseInvocation): draw_mesh=False, ) + path = Path(__file__).resolve().parent.parent.parent + font_path = os.path.abspath(path / "assets/fonts/inter/Inter-Regular.ttf") + font = ImageFont.truetype(font_path, FONT_SIZE) + # Paste face IDs on the output image draw = ImageDraw.Draw(image) for face in all_faces: