ultralytics 8.0.24 mosaic, DDP, download fixes (#703)
Co-authored-by: Laughing <61612323+Laughing-q@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
899abe9f82
commit
aecd17d455
15 changed files with 120 additions and 98 deletions
|
|
@ -10,10 +10,11 @@ import numpy as np
|
|||
import pandas as pd
|
||||
import torch
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
from PIL import __version__ as pil_version
|
||||
|
||||
from ultralytics.yolo.utils import threaded
|
||||
|
||||
from .checks import check_font, is_ascii
|
||||
from .checks import check_font, check_version, is_ascii
|
||||
from .files import increment_path
|
||||
from .ops import clip_coords, scale_image, xywh2xyxy, xyxy2xywh
|
||||
|
||||
|
|
@ -46,6 +47,7 @@ class Annotator:
|
|||
non_ascii = not is_ascii(example) # non-latin labels, i.e. asian, arabic, cyrillic
|
||||
self.pil = pil or non_ascii
|
||||
if self.pil: # use PIL
|
||||
self.pil_9_2_0_check = check_version(pil_version, '9.2.0') # deprecation check
|
||||
self.im = im if isinstance(im, Image.Image) else Image.fromarray(im)
|
||||
self.draw = ImageDraw.Draw(self.im)
|
||||
try:
|
||||
|
|
@ -65,8 +67,10 @@ class Annotator:
|
|||
if self.pil or not is_ascii(label):
|
||||
self.draw.rectangle(box, width=self.lw, outline=color) # box
|
||||
if label:
|
||||
w, h = self.font.getsize(label) # text width, height (WARNING: deprecated) in 9.2.0
|
||||
# _, _, w, h = self.font.getbbox(label) # text width, height (New)
|
||||
if self.pil_9_2_0_check:
|
||||
_, _, w, h = self.font.getbbox(label) # text width, height (New)
|
||||
else:
|
||||
w, h = self.font.getsize(label) # text width, height (Old, deprecated in 9.2.0)
|
||||
outside = box[1] - h >= 0 # label fits outside box
|
||||
self.draw.rectangle(
|
||||
(box[0], box[1] - h if outside else box[1], box[0] + w + 1,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue