MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT / concat_visualizations

Function concat_visualizations

samples/python/efficientdet/visualize.py:193–219  ·  view source on GitHub ↗
(images, names, colors, output_path)

Source from the content-addressed store, hash-verified

191
192
193def concat_visualizations(images, names, colors, output_path):
194 def draw_text(draw, font, text, width, bar_height, offset, color):
195 left, top, right, bottom = font.getbbox(text)
196 text_width, text_height = right - left, bottom - top
197 draw.rectangle([(offset, 0), (offset + width, bar_height)], fill=color)
198 draw.text((offset + (width - text_width) / 2, text_height - text_height / 2), text, fill="black", font=font)
199
200 bar_height = 18
201 width = 0
202 height = 0
203 for im in images:
204 width += im.width
205 height = max(height, im.height)
206
207 concat = Image.new("RGB", (width, height + bar_height))
208 draw = ImageDraw.Draw(concat)
209 font = ImageFont.load_default()
210
211 offset = 0
212 for i, im in enumerate(images):
213 concat.paste(im, (offset, bar_height))
214 draw_text(draw, font, names[i], im.width, bar_height, offset, colors[i])
215 offset += im.width
216
217 if output_path is None:
218 return concat
219 concat.save(output_path)

Callers 1

compare_imagesFunction · 0.90

Calls 3

maxFunction · 0.85
draw_textFunction · 0.70
saveMethod · 0.45

Tested by

no test coverage detected