Skip to content
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.

Commit

Permalink
Increased default guide assets limitations (cvat-ai#6575)
Browse files Browse the repository at this point in the history
<!-- Raise an issue to propose your change
(https://github.com/opencv/cvat/issues).
It helps to avoid duplication of efforts from multiple independent
contributors.
Discuss your ideas with maintainers to be sure that changes will be
approved and merged.
Read the [Contribution
guide](https://opencv.github.io/cvat/docs/contributing/). -->

<!-- Provide a general summary of your changes in the Title above -->

### Motivation and context
Current default assets limitations are too strict

### How has this been tested?
<!-- Please describe in detail how you tested your changes.
Include details of your testing environment, and the tests you ran to
see how your change affects other areas of the code, etc. -->

### Checklist
<!-- Go over all the following points, and put an `x` in all the boxes
that apply.
If an item isn't applicable for some reason, then ~~explicitly
strikethrough~~ the whole
line. If you don't do that, GitHub will show incorrect progress for the
pull request.
If you're unsure about any of these, don't hesitate to ask. We're here
to help! -->
- [x] I submit my changes into the `develop` branch
- [x] I have added a description of my changes into the
[CHANGELOG](https://github.com/opencv/cvat/blob/develop/CHANGELOG.md)
file
- [ ] I have updated the documentation accordingly
- [ ] I have added tests to cover my changes
- [ ] I have linked related issues (see [GitHub docs](

https://help.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword))
- [ ] I have increased versions of npm packages if it is necessary

([cvat-canvas](https://github.com/opencv/cvat/tree/develop/cvat-canvas#versioning),

[cvat-core](https://github.com/opencv/cvat/tree/develop/cvat-core#versioning),

[cvat-data](https://github.com/opencv/cvat/tree/develop/cvat-data#versioning)
and

[cvat-ui](https://github.com/opencv/cvat/tree/develop/cvat-ui#versioning))

### License

- [x] I submit _my code changes_ under the same [MIT License](
https://github.com/opencv/cvat/blob/develop/LICENSE) that covers the
project.
  Feel free to contact the maintainers if that's a concern.
  • Loading branch information
bsekachev authored and mikhail-treskin committed Oct 25, 2023
1 parent 57fa61a commit ce746ad
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
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

0 comments on commit ce746ad

Please sign in to comment.