Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increased default guide assets limitations #6575

Merged
merged 6 commits into from
Jul 31, 2023
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Increased default guide assets limitations (30 assets, up to 10Mb each)
(<https://github.com/opencv/cvat/pull/6575>)
- \[SDK\] Custom `ProgressReporter` implementations should now override `start2` instead of `start`
(<https://github.com/opencv/cvat/pull/6556>)


### Deprecated

- TDB
Expand Down
14 changes: 11 additions & 3 deletions cvat/apps/engine/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import io
import os
import os.path as osp
from PIL import Image
from types import SimpleNamespace
from typing import Optional
import pytz
Expand Down Expand Up @@ -2720,9 +2721,16 @@ def create(self, request, *args, **kwargs):
self.perform_create(serializer)
path = os.path.join(settings.ASSETS_ROOT, str(serializer.instance.uuid))
os.makedirs(path)
with open(os.path.join(path, file.name), 'wb+') as destination:
for chunk in file.chunks():
destination.write(chunk)
if file.content_type in ('image/jpeg', 'image/png'):
image = Image.open(file)
if any(map(lambda x: x > settings.ASSET_MAX_IMAGE_SIZE, image.size)):
scale_factor = settings.ASSET_MAX_IMAGE_SIZE / max(image.size)
image = image.resize((map(lambda x: int(x * scale_factor), image.size)))
image.save(os.path.join(path, file.name))
else:
with open(os.path.join(path, file.name), 'wb+') as destination:
for chunk in file.chunks():
destination.write(chunk)

headers = self.get_success_headers(serializer.data)
return Response(serializer.data, status=status.HTTP_201_CREATED, headers=headers)
Expand Down
5 changes: 3 additions & 2 deletions cvat/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,8 +695,9 @@ class CVAT_QUEUES(Enum):
IMPORT_CACHE_SUCCESS_TTL = timedelta(hours=1)
IMPORT_CACHE_CLEAN_DELAY = timedelta(hours=2)

ASSET_MAX_SIZE_MB = 2
ASSET_MAX_SIZE_MB = 10
ASSET_SUPPORTED_TYPES = ('image/jpeg', 'image/png', 'image/webp', 'image/gif', 'application/pdf', )
ASSET_MAX_COUNT_PER_GUIDE = 10
ASSET_MAX_IMAGE_SIZE = 1920
ASSET_MAX_COUNT_PER_GUIDE = 30

SMOKESCREEN_ENABLED = True