From c93e865d43c011a7cac50e814cd707a317e443aa Mon Sep 17 00:00:00 2001 From: David Traparic Date: Wed, 11 Sep 2024 16:32:51 +0200 Subject: [PATCH 1/3] fixed issue #2470 (some windows support for ffmpeg calls) --- mmcv/utils/misc.py | 15 +++++++++++---- mmcv/video/processing.py | 4 ++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/mmcv/utils/misc.py b/mmcv/utils/misc.py index 7957ea89b7..1313c74197 100644 --- a/mmcv/utils/misc.py +++ b/mmcv/utils/misc.py @@ -8,6 +8,7 @@ from importlib import import_module from inspect import getfullargspec from itertools import repeat +import platform # From PyTorch internals @@ -251,10 +252,16 @@ def _check_py_package(package): def _check_executable(cmd): - if subprocess.call(f'which {cmd}', shell=True) != 0: - return False - else: - return True + if platform.system() == 'Linux': + if subprocess.call(f'which {cmd}', shell=True) != 0: + return False + else: + return True + if platform.system() == 'Windows': + if subprocess.call(f'where {cmd}', shell=True) != 0: + return False + else: + return True def requires_package(prerequisites): diff --git a/mmcv/video/processing.py b/mmcv/video/processing.py index 90e2a4c022..88d0b0e34e 100644 --- a/mmcv/video/processing.py +++ b/mmcv/video/processing.py @@ -45,8 +45,8 @@ def convert_video(in_file: str, options.append(f'-loglevel {v}') else: options.append(f'-{k} {v}') - cmd = f'ffmpeg -y {pre_options} -i {in_file} {" ".join(options)} ' \ - f'{out_file}' + cmd = f'ffmpeg -y {pre_options} -i "{in_file}" {" ".join(options)} ' \ + f'"{out_file}"' if print_cmd: print(cmd) subprocess.call(cmd, shell=True) From 29790440b3d310b5839cb2f66c3b7e373783531c Mon Sep 17 00:00:00 2001 From: David Traparic Date: Fri, 13 Sep 2024 17:00:10 +0200 Subject: [PATCH 2/3] dev: fixed conflict of mmcv/io -> changed to mmcv/mm_io + preparation for grabcut+SITI analysis for perceptual study, but it needs some heavy refacto --- __init__.py | 0 mmcv/__init__.py | 26 -------------------------- mmcv/video/__init__.py | 2 +- mmcv/video/{io.py => mm_io.py} | 22 ++++++++++++++++------ 4 files changed, 17 insertions(+), 33 deletions(-) create mode 100644 __init__.py rename mmcv/video/{io.py => mm_io.py} (92%) diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/mmcv/__init__.py b/mmcv/__init__.py index e87858c594..e69de29bb2 100644 --- a/mmcv/__init__.py +++ b/mmcv/__init__.py @@ -1,26 +0,0 @@ -# Copyright (c) OpenMMLab. All rights reserved. -# flake8: noqa -import warnings - -from .arraymisc import * -from .fileio import * -from .image import * -from .utils import * -from .version import * -from .video import * -from .visualization import * - -# The following modules are not imported to this level, so mmcv may be used -# without PyTorch. -# - runner -# - parallel -# - op -# - device - -warnings.warn( - 'On January 1, 2023, MMCV will release v2.0.0, in which it will remove ' - 'components related to the training process and add a data transformation ' - 'module. In addition, it will rename the package names mmcv to mmcv-lite ' - 'and mmcv-full to mmcv. ' - 'See https://github.com/open-mmlab/mmcv/blob/master/docs/en/compatibility.md ' - 'for more details.') diff --git a/mmcv/video/__init__.py b/mmcv/video/__init__.py index 73199b01de..dfdf494d2e 100644 --- a/mmcv/video/__init__.py +++ b/mmcv/video/__init__.py @@ -1,5 +1,5 @@ # Copyright (c) OpenMMLab. All rights reserved. -from .io import Cache, VideoReader, frames2video +from .mm_io import Cache, VideoReader, frames2video from .optflow import (dequantize_flow, flow_from_bytes, flow_warp, flowread, flowwrite, quantize_flow, sparse_flow_from_bytes) from .processing import concat_video, convert_video, cut_video, resize_video diff --git a/mmcv/video/io.py b/mmcv/video/mm_io.py similarity index 92% rename from mmcv/video/io.py rename to mmcv/video/mm_io.py index 0b2b688763..894c1a3719 100644 --- a/mmcv/video/io.py +++ b/mmcv/video/mm_io.py @@ -7,6 +7,7 @@ CAP_PROP_FRAME_HEIGHT, CAP_PROP_FRAME_WIDTH, CAP_PROP_POS_FRAMES, VideoWriter_fourcc) +# if error here, please add mmcv_forked/ to PYTHON_PATH from mmcv.utils import (check_file_exist, mkdir_or_exist, scandir, track_progress) @@ -38,6 +39,12 @@ def get(self, key, default=None): val = self._cache[key] if key in self._cache else default return val +def encule_de_la_mort(): + """ + Doctest de merde, qui nous fait un autre point d'entrée vers VideoReader + >>> print("bites de merde") + """ + pass class VideoReader: """Video class with similar usage to a list object. @@ -49,15 +56,18 @@ class VideoReader: Cache is used when decoding videos. So if the same frame is visited for the second time, there is no need to decode again if it is stored in the cache. + # import dependencies.mmcv_forked.mmcv.video.io, dependencies.mmcv_forked.mmcv.visualization + # from dependencies.mmcv_forked.mmcv.video import VideoReader Examples: - >>> import mmcv - >>> v = mmcv.VideoReader('sample.mp4') + >>> import dependencies.mmcv_forked.mmcv as mmcv + >>> import dependencies.mmcv_forked.mmcv.video + >>> import dependencies.mmcv_forked.mmcv.visualization + >>> from path_config import PATHS + >>> v = mmcv.video.VideoReader(str(PATHS.examples_vid / 'in.mp4')) >>> len(v) # get the total frame number with `len()` - 120 - >>> for img in v: # v is iterable - >>> mmcv.imshow(img) - >>> v[5] # get the 6th frame + 8 + >>> mmcv.visualization.imshow(v[5], wait_time=1) # get the 6th frame """ def __init__(self, filename, cache_capacity=10): From d69e9ab411042669cd5b46b19db71d71c22e6c5a Mon Sep 17 00:00:00 2001 From: David Traparic Date: Wed, 13 Nov 2024 13:51:00 +0100 Subject: [PATCH 3/3] debug intern library --- mmcv/__init__.py | 13 +++++++++++++ mmcv/ops/__init__.py | 2 +- mmcv/parallel/distributed.py | 2 +- mmcv/utils/ext_loader.py | 2 ++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/mmcv/__init__.py b/mmcv/__init__.py index e69de29bb2..ec2d6b1304 100644 --- a/mmcv/__init__.py +++ b/mmcv/__init__.py @@ -0,0 +1,13 @@ +# Copyright (c) OpenMMLab. All rights reserved. +# flake8: noqa +from .arraymisc import * +from .image import * +# from .transforms import * +from .version import * +from .video import * +from .visualization import * +from .utils import * +# The following modules are not imported to this level, so mmcv may be used +# without PyTorch. +# - op +# - utils \ No newline at end of file diff --git a/mmcv/ops/__init__.py b/mmcv/ops/__init__.py index bdad553736..c2948dfaa2 100755 --- a/mmcv/ops/__init__.py +++ b/mmcv/ops/__init__.py @@ -1,6 +1,6 @@ # Copyright (c) OpenMMLab. All rights reserved. from mmcv.utils import IS_MLU_AVAILABLE -from .active_rotated_filter import active_rotated_filter +# from .active_rotated_filter import active_rotated_filter from .assign_score_withk import assign_score_withk from .ball_query import ball_query from .bbox import bbox_overlaps diff --git a/mmcv/parallel/distributed.py b/mmcv/parallel/distributed.py index bf34cb5906..0483f5b1b2 100644 --- a/mmcv/parallel/distributed.py +++ b/mmcv/parallel/distributed.py @@ -5,7 +5,7 @@ from torch.nn.parallel.distributed import (DistributedDataParallel, _find_tensors) -from mmcv import print_log +from mmcv.utils.logging import print_log from mmcv.utils import TORCH_VERSION, digit_version from .scatter_gather import ScatterInputs, scatter_kwargs diff --git a/mmcv/utils/ext_loader.py b/mmcv/utils/ext_loader.py index a31e107dfe..d7845826d7 100644 --- a/mmcv/utils/ext_loader.py +++ b/mmcv/utils/ext_loader.py @@ -10,6 +10,8 @@ if torch.__version__ != 'parrots': def load_ext(name, funcs): + if name == '_ext': + return 0 ext = importlib.import_module('mmcv.' + name) for fun in funcs: assert hasattr(ext, fun), f'{fun} miss in module {name}'