-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Az/chunk size #1315
Merged
Merged
Az/chunk size #1315
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 2.2.10 on 2020-03-24 12:22 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we splash the migration? |
||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('engine', '0024_auto_20191023_1025'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='data', | ||
name='chunk_size', | ||
field=models.PositiveIntegerField(null=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -227,17 +227,18 @@ def _create_thread(tid, data): | |
job.save_meta() | ||
|
||
db_images = [] | ||
extractors = [] | ||
extractor = None | ||
|
||
for media_type, media_files in media.items(): | ||
if not media_files: | ||
continue | ||
extractors.append(MEDIA_TYPES[media_type]['extractor']( | ||
source_path=[os.path.join(upload_dir, f) for f in media_files], | ||
step=db_data.get_frame_step(), | ||
start=db_data.start_frame, | ||
stop=db_data.stop_frame, | ||
)) | ||
if media_files: | ||
if extractor is not None: | ||
raise Exception('Combined data types are not supported') | ||
extractor = MEDIA_TYPES[media_type]['extractor']( | ||
source_path=[os.path.join(upload_dir, f) for f in media_files], | ||
step=db_data.get_frame_step(), | ||
start=db_data.start_frame, | ||
stop=db_data.stop_frame, | ||
) | ||
db_task.mode = task_mode | ||
db_data.compressed_chunk_type = models.DataChoice.VIDEO if task_mode == 'interpolation' and not data['use_zip_chunks'] else models.DataChoice.IMAGESET | ||
db_data.original_chunk_type = models.DataChoice.VIDEO if task_mode == 'interpolation' else models.DataChoice.IMAGESET | ||
|
@@ -252,25 +253,33 @@ def update_progress(progress): | |
compressed_chunk_writer = compressed_chunk_writer_class(db_data.image_quality) | ||
original_chunk_writer = original_chunk_writer_class(100) | ||
|
||
# calculate chunk size if it isn't specified | ||
if db_data.chunk_size is None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @azhavoro , will it be critical for current video decoder if somebody specify a wrong chunk_size (too small or even)? |
||
if isinstance(compressed_chunk_writer, ZipCompressedChunkWriter): | ||
w, h = extractor.get_image_size() | ||
area = h * w | ||
db_data.chunk_size = max(2, min(72, 36 * 1920 * 1080 // area)) | ||
else: | ||
db_data.chunk_size = 36 | ||
|
||
frame_counter = 0 | ||
total_len = sum(len(e) for e in extractors) or 100 | ||
total_len = len(extractor) or 100 | ||
image_names = [] | ||
image_sizes = [] | ||
for extractor in extractors: | ||
for chunk_idx, chunk_images in enumerate(extractor.slice_by_size(db_data.chunk_size)): | ||
for img in chunk_images: | ||
image_names.append(img[1]) | ||
for chunk_idx, chunk_images in enumerate(extractor.slice_by_size(db_data.chunk_size)): | ||
for img in chunk_images: | ||
image_names.append(img[1]) | ||
|
||
original_chunk_path = db_data.get_original_chunk_path(chunk_idx) | ||
original_chunk_writer.save_as_chunk(chunk_images, original_chunk_path) | ||
original_chunk_path = db_data.get_original_chunk_path(chunk_idx) | ||
original_chunk_writer.save_as_chunk(chunk_images, original_chunk_path) | ||
|
||
compressed_chunk_path = db_data.get_compressed_chunk_path(chunk_idx) | ||
img_sizes = compressed_chunk_writer.save_as_chunk(chunk_images, compressed_chunk_path) | ||
compressed_chunk_path = db_data.get_compressed_chunk_path(chunk_idx) | ||
img_sizes = compressed_chunk_writer.save_as_chunk(chunk_images, compressed_chunk_path) | ||
|
||
image_sizes.extend(img_sizes) | ||
image_sizes.extend(img_sizes) | ||
|
||
db_data.size += len(chunk_images) | ||
update_progress(db_data.size / total_len) | ||
db_data.size += len(chunk_images) | ||
update_progress(db_data.size / total_len) | ||
|
||
if db_task.mode == 'annotation': | ||
for image_name, image_size in zip(image_names, image_sizes): | ||
|
@@ -291,7 +300,7 @@ def update_progress(progress): | |
if db_data.stop_frame == 0: | ||
db_data.stop_frame = db_data.start_frame + (db_data.size - 1) * db_data.get_frame_step() | ||
|
||
extractors[0].save_preview(db_data.get_preview_path()) | ||
extractor.save_preview(db_data.get_preview_path()) | ||
|
||
slogger.glob.info("Founded frames {} for Data #{}".format(db_data.size, db_data.id)) | ||
_save_task_to_db(db_task) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,4 +38,4 @@ def import_tf(): | |
except AttributeError: | ||
pass | ||
|
||
return tf | ||
return tf |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@azhavoro , why the change is necessary for the patch?