forked from Uminosachi/sd-webui-inpaint-anything
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ia_logging.py
30 lines (23 loc) · 1.01 KB
/
ia_logging.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import logging
import warnings
from typing import Union
import numpy as np
from PIL import Image, ImageDraw
warnings.filterwarnings(action="ignore", category=FutureWarning, module="transformers")
warnings.filterwarnings(action="ignore", category=FutureWarning, module="huggingface_hub")
ia_logging = logging.getLogger("Inpaint Anything")
ia_logging.setLevel(logging.INFO)
ia_logging.propagate = False
ia_logging_sh = logging.StreamHandler()
ia_logging_sh.setFormatter(logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s"))
ia_logging_sh.setLevel(logging.INFO)
ia_logging.addHandler(ia_logging_sh)
def draw_text_image(
input_image: Union[np.ndarray, Image.Image],
draw_text: str,
) -> Image.Image:
input_image = np.array(input_image) if isinstance(input_image, Image.Image) else input_image
ret_image = Image.fromarray(np.zeros_like(input_image))
draw_ret_image = ImageDraw.Draw(ret_image)
draw_ret_image.text((0, 0), draw_text, fill=(224, 224, 224))
return ret_image