Skip to content

Commit 4f93641

Browse files
authored
Merge pull request #98 from fastlabel/develop
Merge to main
2 parents 6de78b3 + 3880093 commit 4f93641

File tree

9 files changed

+211
-67
lines changed

9 files changed

+211
-67
lines changed

.pre-commit-config.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
repos:
2+
- repo: https://github.com/psf/black
3+
rev: 20.8b1
4+
hooks:
5+
- id: black
6+
files: '^.*\.py'
7+
types: [file]
8+
- repo: https://gitlab.com/pycqa/flake8
9+
rev: 3.8.4
10+
hooks:
11+
- id: flake8
12+
args: ['--extend-ignore=E203', '--max-line-length=88']
13+
files: '^.*\.py'
14+
types: [file]
15+
- repo: https://github.com/pycqa/isort
16+
rev: 5.6.4
17+
hooks:
18+
- id: isort
19+
args: ['--profile', 'black']
20+
files: '^.*\.py'
21+
types: [file]

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ task_id = client.create_image_task(
105105

106106
> Check [examples/create_image_task.py](/examples/create_image_task.py).
107107
108+
##### Limitation
109+
* You can upload up to a size of 20 MB.
110+
108111
#### Find Task
109112

110113
Find a single task.
@@ -321,6 +324,9 @@ task_id = client.create_image_classification_task(
321324
)
322325
```
323326

327+
##### Limitation
328+
* You can upload up to a size of 20 MB.
329+
324330
#### Find Task
325331

326332
Find a single task.
@@ -433,6 +439,7 @@ task = client.create_multi_image_task(
433439
```
434440

435441
##### Limitation
442+
* You can upload up to a size of 20 MB.
436443
* You can upload up to a total size of 512 MB.
437444
* You can upload up to 250 files in total.
438445

contributing/README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,18 @@ $ pip install -r contributing/requirements.txt
1818
### Run Formatter and Linter
1919

2020
```bash
21-
make all
21+
$ make all
22+
```
23+
24+
### Enable pre-commit hook
25+
26+
```bash
27+
$ pre-commit install
28+
```
29+
30+
Basically, `pre-commit` will only run on the changed files.
31+
But if you execute the bellow command, you can run on all files.
32+
33+
```bash
34+
$ pre-commit run --all-files
2235
```

contributing/requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
black==20.8b1
22
flake8==3.8.4
3-
isort==5.6.4
3+
isort==5.6.4
4+
pre-commit==2.16.0

fastlabel/__init__.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,10 @@ def create_image_task(
375375
if not utils.is_image_supported_ext(file_path):
376376
raise FastLabelInvalidException(
377377
"Supported extensions are png, jpg, jpeg.", 422)
378+
if not utils.is_image_supported_size(file_path):
379+
raise FastLabelInvalidException(
380+
f"Supported image size is under 20 MB.", 422)
381+
378382
file = utils.base64_encode(file_path)
379383
payload = {"project": project, "name": name, "file": file}
380384
if status:
@@ -424,6 +428,10 @@ def create_image_classification_task(
424428
if not utils.is_image_supported_ext(file_path):
425429
raise FastLabelInvalidException(
426430
"Supported extensions are png, jpg, jpeg.", 422)
431+
if not utils.is_image_supported_size(file_path):
432+
raise FastLabelInvalidException(
433+
f"Supported image size is under 20 MB.", 422)
434+
427435
file = utils.base64_encode(file_path)
428436
payload = {"project": project, "name": name, "file": file}
429437
if status:
@@ -483,6 +491,10 @@ def create_multi_image_task(
483491
raise FastLabelInvalidException(
484492
"Supported extensions are png, jpg, jpeg.", 422)
485493

494+
if not utils.is_image_supported_size(file_path):
495+
raise FastLabelInvalidException(
496+
f"Supported image size is under 20 MB.", 422)
497+
486498
if len(contents) == 250:
487499
raise FastLabelInvalidException(
488500
"The count of files should be under 250", 422)
@@ -543,7 +555,7 @@ def create_video_task(
543555
if not utils.is_video_supported_ext(file_path):
544556
raise FastLabelInvalidException(
545557
"Supported extensions are mp4.", 422)
546-
if os.path.getsize(file_path) > const.SUPPORTED_VIDEO_SIZE:
558+
if not utils.is_video_supported_size(file_path):
547559
raise FastLabelInvalidException(
548560
f"Supported video size is under 250 MB.", 422)
549561

@@ -596,7 +608,7 @@ def create_video_classification_task(
596608
if not utils.is_video_supported_ext(file_path):
597609
raise FastLabelInvalidException(
598610
"Supported extensions are mp4.", 422)
599-
if os.path.getsize(file_path) > const.SUPPORTED_VIDEO_SIZE:
611+
if not utils.is_video_supported_size(file_path):
600612
raise FastLabelInvalidException(
601613
f"Supported video size is under 250 MB.", 422)
602614

fastlabel/const.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import math
12
from enum import Enum
23

34
# only 57 types
@@ -7,8 +8,11 @@
78
# Because of V8's limitation, API only can accept the JSON string that length is under this.
89
SUPPORTED_CONTENTS_SIZE = 536870000
910

10-
# API can accept under 250 MB ( 250 * 1024 * 1024 )
11-
SUPPORTED_VIDEO_SIZE = 262144000
11+
# API can accept under 250 MB
12+
SUPPORTED_VIDEO_SIZE = 250 * math.pow(1024, 2)
13+
14+
# API can accept under 20 MB
15+
SUPPORTED_IMAGE_SIZE = 20 * math.pow(1024, 2)
1216

1317

1418
class AnnotationType(Enum):

0 commit comments

Comments
 (0)