dataset-tools 0.2.2__tar.gz → 0.2.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/PKG-INFO +1 -1
- dataset_tools-0.2.3/dataset_tools/image/pillow_compat.py +18 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/image/renders/poster.py +4 -3
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/image/stats/heatmaps_for_classes.py +5 -4
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/image/stats/preview_for_classes.py +5 -4
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools.egg-info/PKG-INFO +1 -1
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools.egg-info/SOURCES.txt +1 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/LICENSE +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/README.md +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/__init__.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/convert/__init__.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/convert/cityscapes/__init__.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/convert/cityscapes/main.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/convert/coco/__init__.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/convert/coco/main.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/convert/pascal/__init__.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/convert/pascal/main.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/data/__init__.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/data/download_urls/__init__.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/data/download_urls/released_datasets.json +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/fonts/FiraSans-Black.ttf +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/fonts/FiraSans-BlackItalic.ttf +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/fonts/FiraSans-Bold.ttf +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/fonts/FiraSans-BoldItalic.ttf +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/fonts/FiraSans-ExtraBold.ttf +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/fonts/FiraSans-ExtraBoldItalic.ttf +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/fonts/FiraSans-ExtraLight.ttf +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/fonts/FiraSans-ExtraLightItalic.ttf +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/fonts/FiraSans-Italic.ttf +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/fonts/FiraSans-Light.ttf +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/fonts/FiraSans-LightItalic.ttf +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/fonts/FiraSans-Medium.ttf +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/fonts/FiraSans-MediumItalic.ttf +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/fonts/FiraSans-Regular.ttf +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/fonts/FiraSans-SemiBold.ttf +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/fonts/FiraSans-SemiBoldItalic.ttf +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/fonts/FiraSans-Thin.ttf +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/fonts/FiraSans-ThinItalic.ttf +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/image/__init__.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/image/renders/__init__.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/image/renders/convert.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/image/renders/horizontal_grid.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/image/renders/previews.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/image/renders/separated_anns_grid.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/image/renders/vertical_grid.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/image/renders/wrapper.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/image/stats/__init__.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/image/stats/basestats.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/image/stats/class_balance.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/image/stats/class_cooccurrence.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/image/stats/classes_per_image.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/image/stats/datasets_annotations.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/image/stats/object_and_class_sizes.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/image/stats/objects_distribution.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/image/stats/overview.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/image/stats/tags_cooccurrence.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/image/stats/wrapper.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/repo/__init__.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/repo/download.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/repo/heatmap_status.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/repo/project_repo.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/repo/sample_project.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/templates/__init__.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/templates/annotation_types.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/templates/applications.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/templates/categories.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/templates/cv_tasks.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/templates/licenses.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/text/__init__.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/text/generate_summary.py +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools.egg-info/dependency_links.txt +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools.egg-info/requires.txt +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools.egg-info/top_level.txt +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/pyproject.toml +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/setup.cfg +0 -0
- {dataset_tools-0.2.2 → dataset_tools-0.2.3}/setup.py +0 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from PIL import ImageDraw, ImageFont
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def _bbox_size(bbox):
|
|
5
|
+
left, top, right, bottom = bbox
|
|
6
|
+
return right - left, bottom - top
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def font_text_size(font: ImageFont.FreeTypeFont, text: str):
|
|
10
|
+
if hasattr(font, "getbbox"):
|
|
11
|
+
return _bbox_size(font.getbbox(text))
|
|
12
|
+
return font.getsize(text)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def draw_text_size(draw: ImageDraw.ImageDraw, text: str, font: ImageFont.FreeTypeFont):
|
|
16
|
+
if hasattr(draw, "textbbox"):
|
|
17
|
+
return _bbox_size(draw.textbbox((0, 0), text, font=font))
|
|
18
|
+
return draw.textsize(text, font=font)
|
|
@@ -10,6 +10,7 @@ from PIL import Image, ImageDraw, ImageFont
|
|
|
10
10
|
from supervisely.imaging import font as sly_font
|
|
11
11
|
from tqdm import tqdm
|
|
12
12
|
|
|
13
|
+
from dataset_tools.image.pillow_compat import draw_text_size, font_text_size
|
|
13
14
|
from dataset_tools.image.renders.convert import compress_png
|
|
14
15
|
|
|
15
16
|
CURENT_DIR = os.path.dirname(os.path.realpath(__file__))
|
|
@@ -311,7 +312,7 @@ class Poster:
|
|
|
311
312
|
x_pos_center = int(image_w * 0.5)
|
|
312
313
|
y_pos_percent = int(image_h * 0.5)
|
|
313
314
|
|
|
314
|
-
text_width, text_height = font
|
|
315
|
+
text_width, text_height = font_text_size(font, text)
|
|
315
316
|
text_color = (0, 0, 0, 210)
|
|
316
317
|
|
|
317
318
|
tmp_canvas = np.zeros(
|
|
@@ -323,7 +324,7 @@ class Poster:
|
|
|
323
324
|
|
|
324
325
|
tmp_canvas = Image.fromarray(tmp_canvas)
|
|
325
326
|
draw = ImageDraw.Draw(tmp_canvas)
|
|
326
|
-
text_width, text_height = draw
|
|
327
|
+
text_width, text_height = draw_text_size(draw, text, font=font)
|
|
327
328
|
draw.text((half_offset, -half_offset // 3), text, font=font, fill=text_color)
|
|
328
329
|
|
|
329
330
|
tmp_canvas = np.array(tmp_canvas, dtype=np.uint8)
|
|
@@ -347,7 +348,7 @@ class Poster:
|
|
|
347
348
|
while text_width > desired_text_width or text_height > desired_text_height:
|
|
348
349
|
font_size -= 1
|
|
349
350
|
font = font.font_variant(size=font_size)
|
|
350
|
-
text_width, text_height = font
|
|
351
|
+
text_width, text_height = font_text_size(font, text)
|
|
351
352
|
|
|
352
353
|
desired_font_height = math.ceil((image_h * text_height_percent) // 100)
|
|
353
354
|
desired_font_size = math.ceil(font_size * desired_text_width / text_width)
|
{dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/image/stats/heatmaps_for_classes.py
RENAMED
|
@@ -10,6 +10,7 @@ from PIL import Image, ImageDraw, ImageFont
|
|
|
10
10
|
from skimage.transform import resize
|
|
11
11
|
from typing import List, Dict
|
|
12
12
|
import supervisely as sly
|
|
13
|
+
from dataset_tools.image.pillow_compat import draw_text_size, font_text_size
|
|
13
14
|
from dataset_tools.image.stats.basestats import BaseVisual
|
|
14
15
|
from supervisely import FigureInfo, ImageInfo
|
|
15
16
|
|
|
@@ -270,7 +271,7 @@ class ClassesHeatmaps(BaseVisual):
|
|
|
270
271
|
|
|
271
272
|
for char in characters[1:]:
|
|
272
273
|
temp_line = current_line + char
|
|
273
|
-
size = font
|
|
274
|
+
size = font_text_size(font, temp_line)
|
|
274
275
|
|
|
275
276
|
if size[0] <= image.size[0]:
|
|
276
277
|
current_line = temp_line
|
|
@@ -315,7 +316,7 @@ class ClassesHeatmaps(BaseVisual):
|
|
|
315
316
|
font = self._font.font_variant(size=font_size)
|
|
316
317
|
text = f"{heatmap}"
|
|
317
318
|
text_color = (255, 255, 255)
|
|
318
|
-
text_width, _ = draw
|
|
319
|
+
text_width, _ = draw_text_size(draw, text, font=font)
|
|
319
320
|
text_position = (x_pos_center - int(text_width / 2), y_pos_percent)
|
|
320
321
|
draw.text(text_position, text, font=font, fill=text_color)
|
|
321
322
|
image.save(image_path)
|
|
@@ -329,12 +330,12 @@ class ClassesHeatmaps(BaseVisual):
|
|
|
329
330
|
font_size = 10
|
|
330
331
|
|
|
331
332
|
font = self._font.font_variant(size=font_size)
|
|
332
|
-
text_width, _ = font
|
|
333
|
+
text_width, _ = font_text_size(font, text)
|
|
333
334
|
|
|
334
335
|
while text_width > desired_text_width:
|
|
335
336
|
font_size -= 1
|
|
336
337
|
font = font.font_variant(size=font_size)
|
|
337
|
-
text_width, _ = font
|
|
338
|
+
text_width, _ = font_text_size(font, text)
|
|
338
339
|
font.font_variant
|
|
339
340
|
|
|
340
341
|
desired_font_height = math.ceil((self._heatmap_img_size[0] * text_height_percent) // 100)
|
{dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/image/stats/preview_for_classes.py
RENAMED
|
@@ -11,6 +11,7 @@ import supervisely as sly
|
|
|
11
11
|
from PIL import Image, ImageDraw, ImageFont
|
|
12
12
|
from tqdm import tqdm
|
|
13
13
|
|
|
14
|
+
from dataset_tools.image.pillow_compat import draw_text_size, font_text_size
|
|
14
15
|
from dataset_tools.image.renders.convert import compress_mp4, from_mp4_to_webm
|
|
15
16
|
from dataset_tools.image.stats.basestats import BaseVisual
|
|
16
17
|
|
|
@@ -388,7 +389,7 @@ class ClassesPreview(BaseVisual):
|
|
|
388
389
|
x_pos_center = int(image_w * 0.5)
|
|
389
390
|
y_pos_percent = self._gap * 2
|
|
390
391
|
|
|
391
|
-
text_width, text_height = font
|
|
392
|
+
text_width, text_height = font_text_size(font, text)
|
|
392
393
|
text_color = (255, 255, 255, 255)
|
|
393
394
|
|
|
394
395
|
tmp_canvas = np.zeros(
|
|
@@ -401,7 +402,7 @@ class ClassesPreview(BaseVisual):
|
|
|
401
402
|
tmp_canvas = Image.fromarray(tmp_canvas)
|
|
402
403
|
canvas_w, canvas_h = tmp_canvas.size
|
|
403
404
|
draw = ImageDraw.Draw(tmp_canvas)
|
|
404
|
-
text_width, text_height = draw
|
|
405
|
+
text_width, text_height = draw_text_size(draw, text, font=font)
|
|
405
406
|
x, y = (x_pos_center - int(text_width / 2), y_pos_percent)
|
|
406
407
|
draw.text((canvas_w // 2, canvas_h // 2), text, text_color, font, "mm")
|
|
407
408
|
|
|
@@ -421,14 +422,14 @@ class ClassesPreview(BaseVisual):
|
|
|
421
422
|
|
|
422
423
|
font = ImageFont.truetype(self._font, font_size)
|
|
423
424
|
|
|
424
|
-
text_width, text_height = font
|
|
425
|
+
text_width, text_height = font_text_size(font, text)
|
|
425
426
|
|
|
426
427
|
while text_width > desired_text_width or text_height > desired_text_height:
|
|
427
428
|
font_size -= 1
|
|
428
429
|
if font_size < 1:
|
|
429
430
|
break
|
|
430
431
|
font = ImageFont.truetype(self._font, font_size)
|
|
431
|
-
text_width, text_height = font
|
|
432
|
+
text_width, text_height = font_text_size(font, text)
|
|
432
433
|
|
|
433
434
|
desired_font_height = math.ceil((image_h * text_height_percent) // 100)
|
|
434
435
|
desired_font_size = math.ceil(font_size * desired_text_width / text_width)
|
|
@@ -37,6 +37,7 @@ dataset_tools/fonts/FiraSans-SemiBoldItalic.ttf
|
|
|
37
37
|
dataset_tools/fonts/FiraSans-Thin.ttf
|
|
38
38
|
dataset_tools/fonts/FiraSans-ThinItalic.ttf
|
|
39
39
|
dataset_tools/image/__init__.py
|
|
40
|
+
dataset_tools/image/pillow_compat.py
|
|
40
41
|
dataset_tools/image/renders/__init__.py
|
|
41
42
|
dataset_tools/image/renders/convert.py
|
|
42
43
|
dataset_tools/image/renders/horizontal_grid.py
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/data/download_urls/released_datasets.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/fonts/FiraSans-ExtraBoldItalic.ttf
RENAMED
|
File without changes
|
|
File without changes
|
{dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/fonts/FiraSans-ExtraLightItalic.ttf
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/image/renders/separated_anns_grid.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/image/stats/datasets_annotations.py
RENAMED
|
File without changes
|
{dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/image/stats/object_and_class_sizes.py
RENAMED
|
File without changes
|
{dataset_tools-0.2.2 → dataset_tools-0.2.3}/dataset_tools/image/stats/objects_distribution.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|