From c158024f58e351fb812f01527397cc2a88ab7172 Mon Sep 17 00:00:00 2001 From: Takafumi Iju Date: Wed, 24 Nov 2021 10:58:29 +0900 Subject: [PATCH 01/15] Add size check --- fastlabel/__init__.py | 15 +++++++++++++++ fastlabel/const.py | 6 +++++- fastlabel/utils.py | 15 ++++++++++++++- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/fastlabel/__init__.py b/fastlabel/__init__.py index 76df58f..b95a100 100644 --- a/fastlabel/__init__.py +++ b/fastlabel/__init__.py @@ -477,6 +477,7 @@ def create_multi_image_task( raise FastLabelInvalidException( "Folder does not have any file.", 422) contents = [] + contents_size = 0 for file_path in file_paths: if not utils.is_image_supported_ext(file_path): raise FastLabelInvalidException( @@ -486,6 +487,11 @@ def create_multi_image_task( "name": os.path.basename(file_path), "file": file }) + contents_size += utils.get_size(contents[-1]) + if contents_size > const.SUPPORTED_CONTENTS_SIZE: + raise FastLabelInvalidException( + f"Supported contents size is under {const.SUPPORTED_CONTENTS_SIZE}.", 422) + payload = {"project": project, "name": name, "contents": contents} if status: payload["status"] = status @@ -533,6 +539,11 @@ def create_video_task( raise FastLabelInvalidException( "Supported extensions are mp4.", 422) file = utils.base64_encode(file_path) + contents_size = utils.get_size(file) + if contents_size > const.SUPPORTED_CONTENTS_SIZE: + raise FastLabelInvalidException( + f"Supported contents size is under {const.SUPPORTED_CONTENTS_SIZE}.", 422) + payload = {"project": project, "name": name, "file": file} if status: payload["status"] = status @@ -582,6 +593,10 @@ def create_video_classification_task( raise FastLabelInvalidException( "Supported extensions are mp4.", 422) file = utils.base64_encode(file_path) + contents_size = utils.get_size(file) + if contents_size > const.SUPPORTED_CONTENTS_SIZE: + raise FastLabelInvalidException( + f"Supported contents size is under {const.SUPPORTED_CONTENTS_SIZE}.", 422) payload = {"project": project, "name": name, "file": file} if status: payload["status"] = status diff --git a/fastlabel/const.py b/fastlabel/const.py index 297bc28..3c8ef94 100644 --- a/fastlabel/const.py +++ b/fastlabel/const.py @@ -3,10 +3,14 @@ # only 57 types 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] +# under 512 MB +SUPPORTED_CONTENTS_SIZE = 536903383 + + class AnnotationType(Enum): bbox = "bbox" polygon = "polygon" keypoint = "keypoint" line = "line" segmentation = "segmentation" - classification = "classification" \ No newline at end of file + classification = "classification" diff --git a/fastlabel/utils.py b/fastlabel/utils.py index 605e9f2..2d3ac41 100644 --- a/fastlabel/utils.py +++ b/fastlabel/utils.py @@ -1,5 +1,6 @@ import os import base64 +import sys from typing import List @@ -13,7 +14,7 @@ def is_image_supported_ext(file_path: str) -> bool: def is_video_supported_ext(file_path: str) -> bool: - return file_path.lower().endswith(('.mp4')) + return file_path.lower().endswith('.mp4') def get_basename(file_path: str) -> str: @@ -41,3 +42,15 @@ def reverse_points(points: List[int]) -> List[int]: reversed_points.insert( 0, points[index]) return reversed_points + + +def get_size(value) -> int: + if isinstance(value, list): + size = sum(map(get_size, iter(value))) + elif isinstance(value, dict): + size = sum(map(get_size, value.keys())) + size += sum(map(get_size, value.values())) + else: + size = sys.getsizeof(value) + + return size From 5e1797e03ffb2e72dd85f9305ed7dafa4b4c4f1e Mon Sep 17 00:00:00 2001 From: Takafumi Iju Date: Wed, 24 Nov 2021 11:25:24 +0900 Subject: [PATCH 02/15] Change to actual size. --- fastlabel/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastlabel/const.py b/fastlabel/const.py index 3c8ef94..9c4b2ed 100644 --- a/fastlabel/const.py +++ b/fastlabel/const.py @@ -4,7 +4,7 @@ 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] # under 512 MB -SUPPORTED_CONTENTS_SIZE = 536903383 +SUPPORTED_CONTENTS_SIZE = 536870888 class AnnotationType(Enum): From a00bc7fe8fea4a9aa967279a6e3ee821b51a7e59 Mon Sep 17 00:00:00 2001 From: Takafumi Iju Date: Wed, 24 Nov 2021 12:15:58 +0900 Subject: [PATCH 03/15] Minus size for extra information. --- fastlabel/const.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fastlabel/const.py b/fastlabel/const.py index 9c4b2ed..da49c60 100644 --- a/fastlabel/const.py +++ b/fastlabel/const.py @@ -3,8 +3,8 @@ # only 57 types 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] -# under 512 MB -SUPPORTED_CONTENTS_SIZE = 536870888 +# under 512 MB. Actual size is 536870888, but to consider other attributes, minus 888. +SUPPORTED_CONTENTS_SIZE = 536870000 class AnnotationType(Enum): From 195d8f4ddbc75d3376b5512601c053d551866510 Mon Sep 17 00:00:00 2001 From: Takafumi Iju Date: Thu, 25 Nov 2021 14:05:24 +0900 Subject: [PATCH 04/15] Update comment --- fastlabel/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastlabel/const.py b/fastlabel/const.py index da49c60..856d6b0 100644 --- a/fastlabel/const.py +++ b/fastlabel/const.py @@ -3,7 +3,7 @@ # only 57 types 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] -# under 512 MB. Actual size is 536870888, but to consider other attributes, minus 888. +# under 512 MB. Actual size is 536870888 bytes, but to consider other attributes, minus 888 bytes. SUPPORTED_CONTENTS_SIZE = 536870000 From 54fc4616e8928d4f3c30314909a82569310d4a7f Mon Sep 17 00:00:00 2001 From: Takafumi Iju Date: Sat, 4 Dec 2021 10:20:32 +0900 Subject: [PATCH 05/15] Add check of image file count. --- fastlabel/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fastlabel/__init__.py b/fastlabel/__init__.py index 1f6cf1a..f19a83a 100644 --- a/fastlabel/__init__.py +++ b/fastlabel/__init__.py @@ -481,6 +481,11 @@ def create_multi_image_task( if not utils.is_image_supported_ext(file_path): raise FastLabelInvalidException( "Supported extensions are png, jpg, jpeg.", 422) + + if len(contents) == 250: + raise FastLabelInvalidException( + "The count of files should be under 250", 422) + file = utils.base64_encode(file_path) contents.append({ "name": os.path.basename(file_path), @@ -639,7 +644,7 @@ def update_image_task( status: str = None, external_status: str = None, tags: list = [], - annotations: list[dict] = [], + annotations: List[dict] = [], **kwargs, ) -> str: """ From c877427c317938ebd7a50be4ef8b8d9503d9d78e Mon Sep 17 00:00:00 2001 From: ryoKaz Date: Mon, 6 Dec 2021 10:23:07 +0900 Subject: [PATCH 06/15] fix type decralation --- fastlabel/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastlabel/__init__.py b/fastlabel/__init__.py index 1f6cf1a..8e6e946 100644 --- a/fastlabel/__init__.py +++ b/fastlabel/__init__.py @@ -639,7 +639,7 @@ def update_image_task( status: str = None, external_status: str = None, tags: list = [], - annotations: list[dict] = [], + annotations: list = [], **kwargs, ) -> str: """ From 6ce84d4859020e0755d682a0bc3352d763d571d6 Mon Sep 17 00:00:00 2001 From: ryoKaz Date: Mon, 6 Dec 2021 10:24:14 +0900 Subject: [PATCH 07/15] fix version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index bcf9fc4..0243625 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setuptools.setup( name="fastlabel", - version="0.11.10", + version="0.11.11", author="eisuke-ueta", author_email="eisuke.ueta@fastlabel.ai", description="The official Python SDK for FastLabel API, the Data Platform for AI", From 6c5393de97c965a5fa4bba47bc8b4712d40811e5 Mon Sep 17 00:00:00 2001 From: ryoKaz Date: Wed, 8 Dec 2021 09:34:50 +0900 Subject: [PATCH 08/15] fix --- fastlabel/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastlabel/__init__.py b/fastlabel/__init__.py index 8e6e946..f02b358 100644 --- a/fastlabel/__init__.py +++ b/fastlabel/__init__.py @@ -639,7 +639,7 @@ def update_image_task( status: str = None, external_status: str = None, tags: list = [], - annotations: list = [], + annotations: List[dict] = [], **kwargs, ) -> str: """ From 607827762658d159de3cc7b8edb885beb2702b51 Mon Sep 17 00:00:00 2001 From: Takafumi Iju Date: Wed, 8 Dec 2021 19:47:17 +0900 Subject: [PATCH 09/15] Add limitation to README.md. --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 28ccca2..e542211 100644 --- a/README.md +++ b/README.md @@ -432,6 +432,10 @@ task = client.create_multi_image_task( ) ``` +##### Limitation + +* You allow uploading 250 files in maximum. + #### Find Task Find a single task. From cb999df21c4fd07d8a8f35d8e452719d5f835348 Mon Sep 17 00:00:00 2001 From: Takafumi Iju Date: Thu, 9 Dec 2021 06:53:01 +0900 Subject: [PATCH 10/15] Fixed calculate method of length. --- fastlabel/__init__.py | 6 +++--- fastlabel/utils.py | 22 +++++++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/fastlabel/__init__.py b/fastlabel/__init__.py index 2da71a6..7f88226 100644 --- a/fastlabel/__init__.py +++ b/fastlabel/__init__.py @@ -492,7 +492,7 @@ def create_multi_image_task( "name": os.path.basename(file_path), "file": file }) - contents_size += utils.get_size(contents[-1]) + contents_size += utils.get_length(contents[-1]) if contents_size > const.SUPPORTED_CONTENTS_SIZE: raise FastLabelInvalidException( f"Supported contents size is under {const.SUPPORTED_CONTENTS_SIZE}.", 422) @@ -544,7 +544,7 @@ def create_video_task( raise FastLabelInvalidException( "Supported extensions are mp4.", 422) file = utils.base64_encode(file_path) - contents_size = utils.get_size(file) + contents_size = utils.get_length(file) if contents_size > const.SUPPORTED_CONTENTS_SIZE: raise FastLabelInvalidException( f"Supported contents size is under {const.SUPPORTED_CONTENTS_SIZE}.", 422) @@ -598,7 +598,7 @@ def create_video_classification_task( raise FastLabelInvalidException( "Supported extensions are mp4.", 422) file = utils.base64_encode(file_path) - contents_size = utils.get_size(file) + contents_size = utils.get_length(file) if contents_size > const.SUPPORTED_CONTENTS_SIZE: raise FastLabelInvalidException( f"Supported contents size is under {const.SUPPORTED_CONTENTS_SIZE}.", 422) diff --git a/fastlabel/utils.py b/fastlabel/utils.py index e325d49..21ba1e9 100644 --- a/fastlabel/utils.py +++ b/fastlabel/utils.py @@ -2,7 +2,6 @@ import base64 import numpy as np import geojson -import sys from typing import List @@ -45,6 +44,7 @@ def reverse_points(points: List[int]) -> List[int]: 0, points[index]) return reversed_points + def is_clockwise(points: list) -> bool: """ points: [x1, y1, x2, y2, x3, y3, ... xn, yn] @@ -69,13 +69,21 @@ def is_clockwise(points: list) -> bool: return False -def get_size(value) -> int: +def get_length(value) -> int: if isinstance(value, list): - size = sum(map(get_size, iter(value))) + length = sum(map(get_length, iter(value))) + length += 2 elif isinstance(value, dict): - size = sum(map(get_size, value.keys())) - size += sum(map(get_size, value.values())) + length = sum(map(get_length, value.keys())) + length += sum(map(get_length, value.values())) + length += len(value.keys()) * 2 + length += (len(value.keys()) - 1) * 2 + length += 2 else: - size = sys.getsizeof(value) + if isinstance(value, str): + length = len(value) + length += 2 + else: + length = len(str(value)) - return size + return length From bf5ede800ab2d927040f39b67e44aa09cc43a2cc Mon Sep 17 00:00:00 2001 From: Takafumi Iju Date: Thu, 9 Dec 2021 06:53:41 +0900 Subject: [PATCH 11/15] Add description of API limitation --- fastlabel/const.py | 1 + 1 file changed, 1 insertion(+) diff --git a/fastlabel/const.py b/fastlabel/const.py index aacb7a4..eda6f77 100644 --- a/fastlabel/const.py +++ b/fastlabel/const.py @@ -4,6 +4,7 @@ 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] # under 512 MB. Actual size is 536870888 bytes, but to consider other attributes, minus 888 bytes. +# Because of V8's limitation, API only can accept the JSON string that length is under this. SUPPORTED_CONTENTS_SIZE = 536870000 From 1bc60d88bb7374908144a4740c2f6ec8463198f0 Mon Sep 17 00:00:00 2001 From: Takafumi Iju Date: Thu, 9 Dec 2021 08:07:07 +0900 Subject: [PATCH 12/15] Modify to use json for calculation length --- fastlabel/__init__.py | 6 +++--- fastlabel/utils.py | 23 +++++------------------ 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/fastlabel/__init__.py b/fastlabel/__init__.py index 7f88226..8d1cf45 100644 --- a/fastlabel/__init__.py +++ b/fastlabel/__init__.py @@ -492,7 +492,7 @@ def create_multi_image_task( "name": os.path.basename(file_path), "file": file }) - contents_size += utils.get_length(contents[-1]) + contents_size += utils.get_json_length(contents[-1]) if contents_size > const.SUPPORTED_CONTENTS_SIZE: raise FastLabelInvalidException( f"Supported contents size is under {const.SUPPORTED_CONTENTS_SIZE}.", 422) @@ -544,7 +544,7 @@ def create_video_task( raise FastLabelInvalidException( "Supported extensions are mp4.", 422) file = utils.base64_encode(file_path) - contents_size = utils.get_length(file) + contents_size = utils.get_json_length(file) if contents_size > const.SUPPORTED_CONTENTS_SIZE: raise FastLabelInvalidException( f"Supported contents size is under {const.SUPPORTED_CONTENTS_SIZE}.", 422) @@ -598,7 +598,7 @@ def create_video_classification_task( raise FastLabelInvalidException( "Supported extensions are mp4.", 422) file = utils.base64_encode(file_path) - contents_size = utils.get_length(file) + contents_size = utils.get_json_length(file) if contents_size > const.SUPPORTED_CONTENTS_SIZE: raise FastLabelInvalidException( f"Supported contents size is under {const.SUPPORTED_CONTENTS_SIZE}.", 422) diff --git a/fastlabel/utils.py b/fastlabel/utils.py index 21ba1e9..1af798f 100644 --- a/fastlabel/utils.py +++ b/fastlabel/utils.py @@ -2,6 +2,7 @@ import base64 import numpy as np import geojson +import json from typing import List @@ -69,21 +70,7 @@ def is_clockwise(points: list) -> bool: return False -def get_length(value) -> int: - if isinstance(value, list): - length = sum(map(get_length, iter(value))) - length += 2 - elif isinstance(value, dict): - length = sum(map(get_length, value.keys())) - length += sum(map(get_length, value.values())) - length += len(value.keys()) * 2 - length += (len(value.keys()) - 1) * 2 - length += 2 - else: - if isinstance(value, str): - length = len(value) - length += 2 - else: - length = len(str(value)) - - return length +def get_json_length(value) -> int: + json_str = json.dumps(value) + return len(json_str) + From 26e26149eb34e28026674785284767685a271fe4 Mon Sep 17 00:00:00 2001 From: Takafumi Iju Date: Thu, 9 Dec 2021 08:24:13 +0900 Subject: [PATCH 13/15] Add limitation to README.md. --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 28ccca2..3cc65e8 100644 --- a/README.md +++ b/README.md @@ -432,6 +432,9 @@ task = client.create_multi_image_task( ) ``` +##### Limitation +* You can upload up to a total size of about 380 MB. + #### Find Task Find a single task. From 560e7f5feaeaa5cafbb74694580a0432e9655774 Mon Sep 17 00:00:00 2001 From: Takafumi Iju Date: Thu, 9 Dec 2021 08:37:11 +0900 Subject: [PATCH 14/15] Change limitation of video. --- README.md | 6 ++++++ fastlabel/__init__.py | 15 +++++++-------- fastlabel/const.py | 3 +++ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 3cc65e8..cfd7012 100644 --- a/README.md +++ b/README.md @@ -564,6 +564,9 @@ task_id = client.create_video_task( ) ``` +##### Limitation +* You can upload up to a size of about 250 MB. + #### Find Task Find a single task. @@ -668,6 +671,9 @@ task_id = client.create_video_classification_task( ) ``` +##### Limitation +* You can upload up to a size of about 250 MB. + #### Find Task Find a single task. diff --git a/fastlabel/__init__.py b/fastlabel/__init__.py index 8d1cf45..51bcb67 100644 --- a/fastlabel/__init__.py +++ b/fastlabel/__init__.py @@ -543,12 +543,11 @@ def create_video_task( if not utils.is_video_supported_ext(file_path): raise FastLabelInvalidException( "Supported extensions are mp4.", 422) - file = utils.base64_encode(file_path) - contents_size = utils.get_json_length(file) - if contents_size > const.SUPPORTED_CONTENTS_SIZE: + if os.path.getsize(file_path) > const.SUPPORTED_VIDEO_SIZE: raise FastLabelInvalidException( - f"Supported contents size is under {const.SUPPORTED_CONTENTS_SIZE}.", 422) + f"Supported video size is under 250 MB.", 422) + file = utils.base64_encode(file_path) payload = {"project": project, "name": name, "file": file} if status: payload["status"] = status @@ -597,11 +596,11 @@ def create_video_classification_task( if not utils.is_video_supported_ext(file_path): raise FastLabelInvalidException( "Supported extensions are mp4.", 422) - file = utils.base64_encode(file_path) - contents_size = utils.get_json_length(file) - if contents_size > const.SUPPORTED_CONTENTS_SIZE: + if os.path.getsize(file_path) > const.SUPPORTED_VIDEO_SIZE: raise FastLabelInvalidException( - f"Supported contents size is under {const.SUPPORTED_CONTENTS_SIZE}.", 422) + f"Supported video size is under 250 MB.", 422) + + file = utils.base64_encode(file_path) payload = {"project": project, "name": name, "file": file} if status: payload["status"] = status diff --git a/fastlabel/const.py b/fastlabel/const.py index eda6f77..ef10f5e 100644 --- a/fastlabel/const.py +++ b/fastlabel/const.py @@ -7,6 +7,9 @@ # Because of V8's limitation, API only can accept the JSON string that length is under this. SUPPORTED_CONTENTS_SIZE = 536870000 +# API can accept under 250 MB ( 250 * 1024 * 1024 ) +SUPPORTED_VIDEO_SIZE = 262144000 + class AnnotationType(Enum): bbox = "bbox" From 8fc8803d4247fce03acf0c18bf02a89e264e98ca Mon Sep 17 00:00:00 2001 From: Takafumi Iju Date: Thu, 9 Dec 2021 08:38:58 +0900 Subject: [PATCH 15/15] Change description. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e542211..d71d322 100644 --- a/README.md +++ b/README.md @@ -434,7 +434,7 @@ task = client.create_multi_image_task( ##### Limitation -* You allow uploading 250 files in maximum. +* You can upload up to 250 files in total. #### Find Task