-
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
Manifest #2763
Manifest #2763
Conversation
cvat/apps/engine/media_extractors.py
Outdated
@@ -25,6 +25,8 @@ | |||
ImageFile.LOAD_TRUNCATED_IMAGES = True | |||
|
|||
from cvat.apps.engine.mime_types import mimetypes | |||
from utils.dataset_manifest import VManifestManager, IManifestManager | |||
from utils.dataset_manifest.core import WorkWithVideo |
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.
I suggest renaming this class to something more descriptive.
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.
@Marishka17 , a class name shouldn't start with a verb. It should describe a type of entity. Could you please rename?
@dvkruchinin Could you please take a look at pylint check? It was failed for a reason. |
Sure. I`ll take a look. |
utils/dataset_manifest/__init__.py
Outdated
# Copyright (C) 2021 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: MIT | ||
from .core import prepare_meta, VideoManifestManager, ImageManifestManager |
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.
I will vote for renaming prepare_meta
. I don't like the module name. There are multiple variants like dataset_manifest, meta_info, meta_data, etc.
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.
Also it makes sense to move prepare_meta, VideoManifestManager, ImageManifestManager into the module and use dataset_manifest inside core.
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.
I'm not sure that I understand correctly.
prepare_meta
- It is a function that responsible for preparing meta information, which later is used to create a manifest. Why it should bedataset_manifest
,meta_info
... ?
@Marishka17 , comments about the command line:
|
|
utils/dataset_manifest/create.py
Outdated
try: | ||
meta_info = prepare_meta(data_type='video', media_file=source, force=args.force) | ||
except AssertionError as ex: | ||
if str(ex) == 'Too few keyframes': | ||
msg = 'NOTE: prepared manifest file contains too few key frames for smooth decoding.\n' \ | ||
'Use --force flag if you still want to prepare a manifest file.' | ||
print(msg) | ||
sys.exit(0) |
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.
Maybe it should exit with 2 or something like this?
{"type":"video"} | ||
{"properties":{"name":"video.mp4","resolution":[1280,720],"length":778}} | ||
{"number":0,"pts":0,"checksum":"17bb40d76887b56fe8213c6fded3d540"} | ||
{"number":135,"pts":486000,"checksum":"9da9b4d42c1206d71bf17a7070a05847"} |
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.
@Marishka17 , Could you please describe how to interpret these data? Just imagine that somebody wants to write code to use these data. Give the user enough information and a couple of sentences. I don't think that you need to describe every parameter, but pts
and checksum
we should.
Will checksum depends on environment (codec, OS) for video files?
cvat/apps/engine/media_extractors.py
Outdated
@@ -25,6 +25,8 @@ | |||
ImageFile.LOAD_TRUNCATED_IMAGES = True | |||
|
|||
from cvat.apps.engine.mime_types import mimetypes | |||
from utils.dataset_manifest import VManifestManager, IManifestManager | |||
from utils.dataset_manifest.core import WorkWithVideo |
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.
@Marishka17 , a class name shouldn't start with a verb. It should describe a type of entity. Could you please rename?
utils/dataset_manifest/core.py
Outdated
|
||
for packet in container.demux(video_stream): | ||
for frame in packet.decode(): | ||
assert frame.pict_type.name == 'I', 'First frame is not key frame' |
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.
@Marishka17 , Video is a user input. Please raise an exception instead of assert. Let's treat it as a bad input data (HTTP 400).
utils/dataset_manifest/core.py
Outdated
) | ||
return frame.width, frame.height | ||
|
||
class AnalyzeVideo(WorkWithVideo): |
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.
@Marishka17 , What is a reason to split WorkWithVideo and AnalyzeVideo?
Could you please rename class names? Don't start them with a verb. For example, VideoStreamReader
or something like that.
utils/dataset_manifest/core.py
Outdated
|
||
frame_pts, frame_dts = frame.pts, frame.dts | ||
|
||
class PrepareImageInfo: |
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.
Could you please rename? Also probably it is a part of a bigger class which works with images.
utils/dataset_manifest/core.py
Outdated
def content(self): | ||
return self._content | ||
|
||
class PrepareVideoInfo(WorkWithVideo): |
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.
@Marishka17 , I believe it is a part of VideoStreamReader
.
utils/dataset_manifest/core.py
Outdated
with closing(av.open(self.source_path, mode='r')) as container: | ||
self.width, self.height = self._get_frame_size(container) | ||
|
||
def get_task_size(self): |
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.
def get_task_size(self): | |
def get_size(self): |
utils/dataset_manifest/core.py
Outdated
meta_info.create() | ||
return meta_info | ||
|
||
def prepare_meta(data_type, **kwargs): |
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.
@Marishka17 , can it be just a method of ImageManifestManager and VideoManifestManager? What do you think?
utils/dataset_manifest/core.py
Outdated
def partial_update(self, number, properties): | ||
pass | ||
|
||
#TODO: |
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.
@Marishka17, please leave an appropriate comment here or remove TODO
.
Motivation and context
How has this been tested?
manually, tests
Checklist
develop
branch- [ ] I have linked related issues (read github docs)- [ ] I have increased versions of npm packages if it is necessary (cvat-canvas,cvat-core, cvat-data and cvat-ui)
License
Feel free to contact the maintainers if that's a concern.