Skip to content

Commit d332477

Browse files
authored
Merge pull request #92 from fastlabel/develop
Merge to main
2 parents 9c63c2c + d4c7cd7 commit d332477

File tree

5 files changed

+53
-8
lines changed

5 files changed

+53
-8
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,10 @@ task = client.create_multi_image_task(
432432
)
433433
```
434434

435+
##### Limitation
436+
* You can upload up to a total size of 512 MB.
437+
* You can upload up to 250 files in total.
438+
435439
#### Find Task
436440

437441
Find a single task.
@@ -561,6 +565,9 @@ task_id = client.create_video_task(
561565
)
562566
```
563567

568+
##### Limitation
569+
* You can upload up to a size of 250 MB.
570+
564571
#### Find Task
565572

566573
Find a single task.
@@ -665,6 +672,9 @@ task_id = client.create_video_classification_task(
665672
)
666673
```
667674

675+
##### Limitation
676+
* You can upload up to a size of 250 MB.
677+
668678
#### Find Task
669679

670680
Find a single task.

fastlabel/__init__.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,15 +477,26 @@ def create_multi_image_task(
477477
raise FastLabelInvalidException(
478478
"Folder does not have any file.", 422)
479479
contents = []
480+
contents_size = 0
480481
for file_path in file_paths:
481482
if not utils.is_image_supported_ext(file_path):
482483
raise FastLabelInvalidException(
483484
"Supported extensions are png, jpg, jpeg.", 422)
485+
486+
if len(contents) == 250:
487+
raise FastLabelInvalidException(
488+
"The count of files should be under 250", 422)
489+
484490
file = utils.base64_encode(file_path)
485491
contents.append({
486492
"name": os.path.basename(file_path),
487493
"file": file
488494
})
495+
contents_size += utils.get_json_length(contents[-1])
496+
if contents_size > const.SUPPORTED_CONTENTS_SIZE:
497+
raise FastLabelInvalidException(
498+
f"Supported contents size is under {const.SUPPORTED_CONTENTS_SIZE}.", 422)
499+
489500
payload = {"project": project, "name": name, "contents": contents}
490501
if status:
491502
payload["status"] = status
@@ -532,6 +543,10 @@ def create_video_task(
532543
if not utils.is_video_supported_ext(file_path):
533544
raise FastLabelInvalidException(
534545
"Supported extensions are mp4.", 422)
546+
if os.path.getsize(file_path) > const.SUPPORTED_VIDEO_SIZE:
547+
raise FastLabelInvalidException(
548+
f"Supported video size is under 250 MB.", 422)
549+
535550
file = utils.base64_encode(file_path)
536551
payload = {"project": project, "name": name, "file": file}
537552
if status:
@@ -581,6 +596,10 @@ def create_video_classification_task(
581596
if not utils.is_video_supported_ext(file_path):
582597
raise FastLabelInvalidException(
583598
"Supported extensions are mp4.", 422)
599+
if os.path.getsize(file_path) > const.SUPPORTED_VIDEO_SIZE:
600+
raise FastLabelInvalidException(
601+
f"Supported video size is under 250 MB.", 422)
602+
584603
file = utils.base64_encode(file_path)
585604
payload = {"project": project, "name": name, "file": file}
586605
if status:
@@ -639,7 +658,7 @@ def update_image_task(
639658
status: str = None,
640659
external_status: str = None,
641660
tags: list = [],
642-
annotations: list[dict] = [],
661+
annotations: List[dict] = [],
643662
**kwargs,
644663
) -> str:
645664
"""

fastlabel/const.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,19 @@
33
# only 57 types
44
COLOR_PALETTE = [0, 0, 0, 228, 26, 28, 55, 126, 184, 77, 175, 74, 152, 78, 163, 255, 127, 0, 255, 255, 51, 166, 86, 40, 247, 129, 191, 153, 153, 153, 102, 194, 165, 252, 141, 98, 141, 160, 203, 231, 138, 195, 166, 216, 84, 255, 217, 47, 229, 196, 148, 179, 179, 179, 141, 211, 199, 255, 255, 179, 190, 186, 218, 251, 128, 114, 128, 177, 211, 253, 180, 98, 179, 222, 105, 252, 205, 229, 217, 217, 217, 188, 128, 189, 204, 235, 197, 255, 237, 111, 166, 206, 227, 31, 120, 180, 178, 223, 138, 51, 160, 44, 251, 154, 153, 227, 26, 28, 253, 191, 111, 255, 127, 0, 202, 178, 214, 106, 61, 154, 255, 255, 153, 177, 89, 40, 127, 201, 127, 190, 174, 212, 253, 192, 134, 255, 255, 153, 56, 108, 176, 240, 2, 127, 191, 91, 22, 102, 102, 102, 27, 158, 119, 217, 95, 2, 117, 112, 179, 231, 41, 138, 102, 166, 30, 230, 171, 2, 166, 118, 29, 102, 102, 102]
55

6+
# under 512 MB. Actual size is 536870888 bytes, but to consider other attributes, minus 888 bytes.
7+
# Because of V8's limitation, API only can accept the JSON string that length is under this.
8+
SUPPORTED_CONTENTS_SIZE = 536870000
9+
10+
# API can accept under 250 MB ( 250 * 1024 * 1024 )
11+
SUPPORTED_VIDEO_SIZE = 262144000
12+
13+
614
class AnnotationType(Enum):
715
bbox = "bbox"
816
polygon = "polygon"
917
keypoint = "keypoint"
1018
line = "line"
1119
segmentation = "segmentation"
1220
classification = "classification"
13-
pose_estimation = "pose_estimation"
21+
pose_estimation = "pose_estimation"

fastlabel/utils.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import base64
33
import numpy as np
44
import geojson
5+
import json
56
from typing import List
67

78

@@ -15,7 +16,7 @@ def is_image_supported_ext(file_path: str) -> bool:
1516

1617

1718
def is_video_supported_ext(file_path: str) -> bool:
18-
return file_path.lower().endswith(('.mp4'))
19+
return file_path.lower().endswith('.mp4')
1920

2021

2122
def get_basename(file_path: str) -> str:
@@ -44,13 +45,14 @@ def reverse_points(points: List[int]) -> List[int]:
4445
0, points[index])
4546
return reversed_points
4647

48+
4749
def is_clockwise(points: list) -> bool:
4850
"""
4951
points: [x1, y1, x2, y2, x3, y3, ... xn, yn]
50-
Sum over the edges, (x2 − x1)(y2 + y1).
52+
Sum over the edges, (x2 − x1)(y2 + y1).
5153
If the result is positive the curve is clockwise, if it's negative the curve is counter-clockwise.
52-
53-
The above is assumes a normal Cartesian coordinate system.
54+
55+
The above is assumes a normal Cartesian coordinate system.
5456
HTML5 canvas, use an inverted Y-axis.
5557
Therefore If the area is negative, the curve is clockwise.
5658
"""
@@ -65,4 +67,10 @@ def is_clockwise(points: list) -> bool:
6567

6668
if sum_edges < 0:
6769
return True
68-
return False
70+
return False
71+
72+
73+
def get_json_length(value) -> int:
74+
json_str = json.dumps(value)
75+
return len(json_str)
76+

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
setuptools.setup(
1010
name="fastlabel",
11-
version="0.11.10",
11+
version="0.11.11",
1212
author="eisuke-ueta",
1313
author_email="[email protected]",
1414
description="The official Python SDK for FastLabel API, the Data Platform for AI",

0 commit comments

Comments
 (0)