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.
This commit is contained in:
Jonathan 2023-09-29 06:55:34 -05:00 committed by psychedelicious
parent 08e40d6d16
commit 27164de8b8

View File

@ -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: