Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ task_id = client.create_image_task(

> Check [examples/create_image_task.py](/examples/create_image_task.py).

##### Limitation
* You can upload up to a size of 20 MB.

#### Find Task

Find a single task.
Expand Down Expand Up @@ -321,6 +324,9 @@ task_id = client.create_image_classification_task(
)
```

##### Limitation
* You can upload up to a size of 20 MB.

#### Find Task

Find a single task.
Expand Down Expand Up @@ -433,6 +439,7 @@ task = client.create_multi_image_task(
```

##### Limitation
* You can upload up to a size of 20 MB.
* You can upload up to a total size of 512 MB.
* You can upload up to 250 files in total.

Expand Down
16 changes: 14 additions & 2 deletions fastlabel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,10 @@ def create_image_task(
if not utils.is_image_supported_ext(file_path):
raise FastLabelInvalidException(
"Supported extensions are png, jpg, jpeg.", 422)
if not utils.is_image_supported_size(file_path):
raise FastLabelInvalidException(
f"Supported image size is under 20 MB.", 422)

file = utils.base64_encode(file_path)
payload = {"project": project, "name": name, "file": file}
if status:
Expand Down Expand Up @@ -424,6 +428,10 @@ def create_image_classification_task(
if not utils.is_image_supported_ext(file_path):
raise FastLabelInvalidException(
"Supported extensions are png, jpg, jpeg.", 422)
if not utils.is_image_supported_size(file_path):
raise FastLabelInvalidException(
f"Supported image size is under 20 MB.", 422)

file = utils.base64_encode(file_path)
payload = {"project": project, "name": name, "file": file}
if status:
Expand Down Expand Up @@ -483,6 +491,10 @@ def create_multi_image_task(
raise FastLabelInvalidException(
"Supported extensions are png, jpg, jpeg.", 422)

if not utils.is_image_supported_size(file_path):
raise FastLabelInvalidException(
f"Supported image size is under 20 MB.", 422)

if len(contents) == 250:
raise FastLabelInvalidException(
"The count of files should be under 250", 422)
Expand Down Expand Up @@ -543,7 +555,7 @@ def create_video_task(
if not utils.is_video_supported_ext(file_path):
raise FastLabelInvalidException(
"Supported extensions are mp4.", 422)
if os.path.getsize(file_path) > const.SUPPORTED_VIDEO_SIZE:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

拡張子と同じように、utilを作成してチェックするようにしました。

if not utils.is_video_supported_size(file_path):
raise FastLabelInvalidException(
f"Supported video size is under 250 MB.", 422)

Expand Down Expand Up @@ -596,7 +608,7 @@ def create_video_classification_task(
if not utils.is_video_supported_ext(file_path):
raise FastLabelInvalidException(
"Supported extensions are mp4.", 422)
if os.path.getsize(file_path) > const.SUPPORTED_VIDEO_SIZE:
if not utils.is_video_supported_size(file_path):
raise FastLabelInvalidException(
f"Supported video size is under 250 MB.", 422)

Expand Down
8 changes: 6 additions & 2 deletions fastlabel/const.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import math
from enum import Enum

# only 57 types
Expand All @@ -7,8 +8,11 @@
# 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
# API can accept under 250 MB
SUPPORTED_VIDEO_SIZE = 250 * math.pow(1024, 2)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

math.pow を使って記述した方がわかりやすいと思ったので、変更しました


# API can accept under 20 MB
SUPPORTED_IMAGE_SIZE = 20 * math.pow(1024, 2)


class AnnotationType(Enum):
Expand Down
9 changes: 9 additions & 0 deletions fastlabel/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import geojson
import json
from typing import List
from fastlabel import const


def base64_encode(file_path: str) -> str:
Expand All @@ -19,6 +20,14 @@ def is_video_supported_ext(file_path: str) -> bool:
return file_path.lower().endswith('.mp4')


def is_image_supported_size(file_path: str) -> bool:
return os.path.getsize(file_path) <= const.SUPPORTED_IMAGE_SIZE


def is_video_supported_size(file_path: str) -> bool:
return os.path.getsize(file_path) <= const.SUPPORTED_VIDEO_SIZE


def is_json_ext(file_name: str) -> bool:
return file_name.lower().endswith('.json')

Expand Down