MCPcopy Create free account
hub / github.com/Monalissaa/DisenDiff / text_under_image

Function text_under_image

sample.py:146–156  ·  view source on GitHub ↗
(image: np.ndarray, text: str, text_color: Tuple[int, int, int] = (0, 0, 0))

Source from the content-addressed store, hash-verified

144# from src import ptp_utils
145
146def text_under_image(image: np.ndarray, text: str, text_color: Tuple[int, int, int] = (0, 0, 0)):
147 h, w, c = image.shape
148 offset = int(h * .2)
149 img = np.ones((h + offset, w, c), dtype=np.uint8) * 255
150 font = cv2.FONT_HERSHEY_SIMPLEX
151 # font = ImageFont.truetype("/usr/share/fonts/truetype/noto/NotoMono-Regular.ttf", font_size)
152 img[:h] = image
153 textsize = cv2.getTextSize(text, font, 1, 2)[0]
154 text_x, text_y = (w - textsize[0]) // 2, h + offset - textsize[1] // 2
155 cv2.putText(img, text, (text_x, text_y ), font, 1, text_color, 2)
156 return img
157
158def view_images(images, save_path, base_count, num_rows=1, offset_ratio=0.02, step=None):
159 if type(images) is list:

Callers 1

show_cross_attentionFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected