-
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
Audio upload handler #7113
Audio upload handler #7113
Changes from 37 commits
b428863
0551bde
4135657
1f1cdd7
746e44e
30bd9bf
2f5c7f3
ce4ab15
8550ed2
e9b7961
678afc7
230b28b
7223610
b0c1335
a9a53e4
ab36c8a
20223f4
d188ab1
cf97b3b
7912982
b933f1d
e773d31
0e42dae
6589411
2d29065
2da6517
74e6743
6a602b6
97a158b
bfaebcc
531de53
44df236
c696325
5c8895a
0799c54
9991d03
16e0509
f3beafa
111d2b6
32a065b
0bde3ff
62e94bb
0ff4e30
4cc294c
e2b4c07
9b7d1ac
030e245
ebe46a5
2cf5d5a
a52c010
f23cd60
a628c20
95253ff
6779ccf
90d8d08
66733ca
7a86c95
ac9f840
d1e3411
ab6c2ef
2c46ad8
ecc54b4
b9a2fc6
1dbdfeb
025d5aa
5f2d84c
2340bd3
7f6387c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Copyright (C) 2024 CVAT.ai Corporation | ||
# | ||
# SPDX-License-Identifier: MIT | ||
|
||
# Copyright (C) 2019-2022 Intel Corporation | ||
# Copyright (C) 2023 CVAT.ai Corporation | ||
# | ||
# SPDX-License-Identifier: MIT | ||
|
||
import os.path as osp | ||
from glob import glob | ||
|
||
from pyunpack import Archive | ||
|
||
from cvat.apps.dataset_manager.bindings import (GetCVATDataExtractor, | ||
import_dm_annotations, match_dm_item, find_dataset_root) | ||
from cvat.apps.dataset_manager.util import make_zip_archive | ||
from datumaro.components.extractor import DatasetItem | ||
from datumaro.components.project import Dataset | ||
from datumaro.plugins.yolo_format.extractor import YoloExtractor | ||
|
||
from .registry import dm_env, exporter, importer | ||
from cvat.apps.engine.log import ServerLogManager | ||
slogger = ServerLogManager(__name__) | ||
|
||
|
||
@exporter(name='YOLO', ext='ZIP', version='1.1') | ||
def _export(dst_file, temp_dir, instance_data, save_images=False): | ||
slogger.glob.info("HEYLO YOLO EXPORTER AUDINO") | ||
# slogger.glob.debug() | ||
dataset = Dataset.from_extractors(GetCVATDataExtractor( | ||
instance_data, include_images=save_images), env=dm_env) | ||
|
||
dataset.export(temp_dir, 'yolo', save_images=save_images) | ||
|
||
make_zip_archive(temp_dir, dst_file) | ||
|
||
@importer(name='YOLO', ext='ZIP', version='1.1') | ||
def _import(src_file, temp_dir, instance_data, load_data_callback=None, **kwargs): | ||
Archive(src_file.name).extractall(temp_dir) | ||
|
||
image_info = {} | ||
frames = [YoloExtractor.name_from_path(osp.relpath(p, temp_dir)) | ||
for p in glob(osp.join(temp_dir, '**', '*.txt'), recursive=True)] | ||
root_hint = find_dataset_root( | ||
[DatasetItem(id=frame) for frame in frames], instance_data) | ||
for frame in frames: | ||
frame_info = None | ||
try: | ||
frame_id = match_dm_item(DatasetItem(id=frame), instance_data, | ||
root_hint=root_hint) | ||
frame_info = instance_data.frame_info[frame_id] | ||
except Exception: # nosec | ||
pass | ||
if frame_info is not None: | ||
image_info[frame] = (frame_info['height'], frame_info['width']) | ||
|
||
dataset = Dataset.import_from(temp_dir, 'yolo', | ||
env=dm_env, image_info=image_info) | ||
if load_data_callback is not None: | ||
load_data_callback(dataset, instance_data) | ||
import_dm_annotations(dataset, instance_data) | ||
Comment on lines
+38
to
+62
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. Consider adding error logging in the exception handling block to aid in debugging. |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -16,10 +16,13 @@ | |||||||||||||||||||||||||||||
from datumaro.plugins.yolo_format.extractor import YoloExtractor | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
from .registry import dm_env, exporter, importer | ||||||||||||||||||||||||||||||
from cvat.apps.engine.log import ServerLogManager | ||||||||||||||||||||||||||||||
slogger = ServerLogManager(__name__) | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
@exporter(name='YOLO', ext='ZIP', version='1.1') | ||||||||||||||||||||||||||||||
def _export(dst_file, temp_dir, instance_data, save_images=False): | ||||||||||||||||||||||||||||||
slogger.glob.info("HEYLO YOLO EXPORTER") | ||||||||||||||||||||||||||||||
Comment on lines
+19
to
+25
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. Introduction of logging in YOLO export function is good for traceability. Consider refining the log message to be more descriptive of the operation being performed. - slogger.glob.info("HEYLO YOLO EXPORTER")
+ slogger.glob.info("Starting export of YOLO dataset") Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||
dataset = Dataset.from_extractors(GetCVATDataExtractor( | ||||||||||||||||||||||||||||||
instance_data, include_images=save_images), env=dm_env) | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
|
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.
Consider renaming
_export
to reflect its specific use for YOLO format or add a comment clarifying its purpose.