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
21 changes: 21 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
repos:
- repo: https://github.com/psf/black
rev: 20.8b1
hooks:
- id: black
files: '^.*\.py'
types: [file]
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
hooks:
- id: flake8
args: ['--extend-ignore=E203', '--max-line-length=88']
files: '^.*\.py'
types: [file]
- repo: https://github.com/pycqa/isort
rev: 5.6.4
hooks:
- id: isort
args: ['--profile', 'black']
files: '^.*\.py'
types: [file]
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
15 changes: 14 additions & 1 deletion contributing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,18 @@ $ pip install -r contributing/requirements.txt
### Run Formatter and Linter

```bash
make all
$ make all
```

### Enable pre-commit hook

```bash
$ pre-commit install
```

Basically, `pre-commit` will only run on the changed files.
But if you execute the bellow command, you can run on all files.

```bash
$ pre-commit run --all-files
```
3 changes: 2 additions & 1 deletion contributing/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
black==20.8b1
flake8==3.8.4
isort==5.6.4
isort==5.6.4
pre-commit==2.16.0
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:
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)

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


class AnnotationType(Enum):
Expand Down
Loading