index int64 0 731k | package stringlengths 2 98 ⌀ | name stringlengths 1 76 | docstring stringlengths 0 281k ⌀ | code stringlengths 4 8.19k | signature stringlengths 2 42.8k ⌀ | embed_func_code listlengths 768 768 |
|---|---|---|---|---|---|---|
730,238 | mmengine.fileio.handlers.pickle_handler | load_from_path | null | def load_from_path(self, filepath, **kwargs):
return super().load_from_path(filepath, mode='rb', **kwargs)
| (self, filepath, **kwargs) | [
0.0009484388865530491,
-0.07140374183654785,
-0.028243841603398323,
0.03628884628415108,
-0.02372068352997303,
-0.015244077891111374,
0.010902191512286663,
0.11760210245847702,
0.01737617701292038,
-0.015485773794353008,
0.028606384992599487,
0.051170382648706436,
-0.04768306016921997,
0.0... |
730,239 | mmengine.utils.progressbar | ProgressBar | A progress bar which can print the progress.
Args:
task_num (int): Number of total steps. Defaults to 0.
bar_width (int): Width of the progress bar. Defaults to 50.
start (bool): Whether to start the progress bar in the constructor.
Defaults to True.
file (callable): Pro... | class ProgressBar:
"""A progress bar which can print the progress.
Args:
task_num (int): Number of total steps. Defaults to 0.
bar_width (int): Width of the progress bar. Defaults to 50.
start (bool): Whether to start the progress bar in the constructor.
Defaults to True.
... | (task_num: int = 0, bar_width: int = 50, start: bool = True, file=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>) | [
0.046378906816244125,
-0.0002092522190650925,
-0.12516717612743378,
0.020134778693318367,
0.0740944966673851,
0.018020719289779663,
-0.04343598708510399,
0.027343066409230232,
-0.06124250963330269,
-0.03300539031624794,
0.05129618942737579,
-0.009750746190547943,
0.036767855286598206,
0.01... |
730,240 | mmengine.utils.progressbar | __init__ | null | def __init__(self,
task_num: int = 0,
bar_width: int = 50,
start: bool = True,
file=sys.stdout):
self.task_num = task_num
self.bar_width = bar_width
self.completed = 0
self.file = file
if start:
self.start()
| (self, task_num: int = 0, bar_width: int = 50, start: bool = True, file=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>) | [
0.023266052827239037,
0.06197309494018555,
-0.06768939644098282,
0.016896208748221397,
0.036667995154857635,
0.032659612596035004,
-0.023841168731451035,
0.015493273735046387,
-0.06890933960676193,
-0.021035300567746162,
0.045834995806217194,
0.033513572067022324,
0.026403049007058144,
-0.... |
730,241 | mmengine.utils.progressbar | start | null | def start(self):
if self.task_num > 0:
self.file.write(f'[{" " * self.bar_width}] 0/{self.task_num}, '
'elapsed: 0s, ETA:')
else:
self.file.write('completed: 0, elapsed: 0s')
self.file.flush()
self.timer = Timer()
| (self) | [
0.023740652948617935,
0.07449162751436234,
-0.05835651233792305,
0.02503785863518715,
0.06766796857118607,
0.026477225124835968,
-0.06514463573694229,
0.06269238144159317,
-0.09062673896551132,
-0.013736170716583729,
0.026974782347679138,
-0.00988009199500084,
0.058498673141002655,
-0.0320... |
730,242 | mmengine.utils.progressbar | update | update progressbar.
Args:
num_tasks (int): Update step size.
| def update(self, num_tasks: int = 1):
"""update progressbar.
Args:
num_tasks (int): Update step size.
"""
assert num_tasks > 0
self.completed += num_tasks
elapsed = self.timer.since_start()
if elapsed > 0:
fps = self.completed / elapsed
else:
fps = float('inf')
... | (self, num_tasks: int = 1) | [
0.026249118149280548,
-0.007727128453552723,
-0.12470109760761261,
0.040725257247686386,
0.03323821350932121,
0.017241545021533966,
-0.04812338203191757,
0.03841334208846092,
-0.06985537707805634,
-0.011008268222212791,
0.04186343029141426,
-0.056446272879838943,
0.051893580704927444,
0.01... |
730,243 | mmengine.registry.registry | Registry | A registry to map strings to classes or functions.
Registered object could be built from registry. Meanwhile, registered
functions could be called from registry.
Args:
name (str): Registry name.
build_func (callable, optional): A function to construct instance
from Registry. :f... | class Registry:
"""A registry to map strings to classes or functions.
Registered object could be built from registry. Meanwhile, registered
functions could be called from registry.
Args:
name (str): Registry name.
build_func (callable, optional): A function to construct instance
... | (name: str, build_func: Optional[collections.abc.Callable] = None, parent: Optional[ForwardRef('Registry')] = None, scope: Optional[str] = None, locations: List = []) | [
0.09000343084335327,
-0.03299305960536003,
-0.01909908838570118,
-0.021373765543103218,
0.019703619182109833,
0.018545787781476974,
-0.016537515446543694,
0.0017790124984458089,
0.002991917310282588,
-0.04153846949338913,
0.010973778553307056,
-0.018515050411224365,
0.021414751186966896,
0... |
730,244 | mmengine.registry.registry | __contains__ | null | def __contains__(self, key):
return self.get(key) is not None
| (self, key) | [
0.04607151448726654,
-0.05245491862297058,
-0.04020849987864494,
0.027805963531136513,
0.000829365337267518,
-0.01387696247547865,
0.017814550548791885,
-0.021648060530424118,
0.04825713858008385,
-0.042532891035079956,
-0.040486037731170654,
-0.010451087728142738,
0.07451929152011871,
-0.... |
730,245 | mmengine.registry.registry | __init__ | null | def __init__(self,
name: str,
build_func: Optional[Callable] = None,
parent: Optional['Registry'] = None,
scope: Optional[str] = None,
locations: List = []):
from .build_functions import build_from_cfg
self._name = name
self._module_dict: Dict... | (self, name: str, build_func: Optional[collections.abc.Callable] = None, parent: Optional[mmengine.registry.registry.Registry] = None, scope: Optional[str] = None, locations: List = []) | [
0.03731317073106766,
-0.034570369869470596,
-0.0016854895511642098,
0.01658567786216736,
-0.022421037778258324,
0.03284000977873802,
-0.009645831771194935,
0.036135055124759674,
-0.04539431631565094,
-0.038730595260858536,
0.023507114499807358,
0.05043812841176987,
0.011725944466888905,
0.... |
730,246 | mmengine.registry.registry | __len__ | null | def __len__(self):
return len(self._module_dict)
| (self) | [
0.02496761828660965,
-0.03564004972577095,
-0.0038552938494831324,
0.03472620248794556,
0.04220017045736313,
0.03932807594537735,
-0.014197273179888725,
0.008608116768300533,
-0.002604873152449727,
-0.01276122685521841,
0.005434128455817699,
-0.05049007013440132,
0.022764593362808228,
0.00... |
730,247 | mmengine.registry.registry | __repr__ | null | def __repr__(self):
table = Table(title=f'Registry of {self._name}')
table.add_column('Names', justify='left', style='cyan')
table.add_column('Objects', justify='left', style='green')
for name, obj in sorted(self._module_dict.items()):
table.add_row(name, str(obj))
console = Console()
wi... | (self) | [
0.04561691731214523,
-0.07153480499982834,
-0.0039272247813642025,
-0.05668863654136658,
0.04863647744059563,
-0.02708616852760315,
-0.010343789122998714,
-0.0006683921092189848,
0.0003867125487886369,
-0.016463788226246834,
-0.017829779535531998,
0.01115259900689125,
-0.005724581424146891,
... |
730,248 | mmengine.registry.registry | _add_child | Add a child for a registry.
Args:
registry (:obj:`Registry`): The ``registry`` will be added as a
child of the ``self``.
| def _add_child(self, registry: 'Registry') -> None:
"""Add a child for a registry.
Args:
registry (:obj:`Registry`): The ``registry`` will be added as a
child of the ``self``.
"""
assert isinstance(registry, Registry)
assert registry.scope is not None
assert registry.scope no... | (self, registry: mmengine.registry.registry.Registry) -> NoneType | [
0.03978492319583893,
-0.004400155041366816,
-0.04787798225879669,
0.04096665233373642,
0.010492333211004734,
0.06517422199249268,
0.022972121834754944,
0.06825388222932816,
0.004923876374959946,
0.029024014249444008,
0.06324047595262527,
0.01935531012713909,
0.03942682221531868,
-0.0379227... |
730,249 | mmengine.registry.registry | _get_root_registry | Return the root registry. | def _get_root_registry(self) -> 'Registry':
"""Return the root registry."""
root = self
while root.parent is not None:
root = root.parent
return root
| (self) -> mmengine.registry.registry.Registry | [
0.03736418858170509,
-0.04172452539205551,
-0.004861066583544016,
0.006881710607558489,
-0.00499843480065465,
0.06030026823282242,
0.003968172241002321,
0.03786048665642738,
0.05824417248368263,
0.02259930595755577,
0.01822124421596527,
-0.04828275367617607,
-0.001966361189261079,
0.021004... |
730,250 | mmengine.registry.registry | _register_module | Register a module.
Args:
module (type): Module to be registered. Typically a class or a
function, but generally all ``Callable`` are acceptable.
module_name (str or list of str, optional): The module name to be
registered. If not specified, the class name... | def _register_module(self,
module: Type,
module_name: Optional[Union[str, List[str]]] = None,
force: bool = False) -> None:
"""Register a module.
Args:
module (type): Module to be registered. Typically a class or a
function, but ... | (self, module: Type, module_name: Union[str, List[str], NoneType] = None, force: bool = False) -> NoneType | [
0.019821153953671455,
-0.013049716129899025,
0.01580001972615719,
0.028375545516610146,
-0.025739047676324844,
-0.007918977178633213,
-0.05879959464073181,
0.061568863689899445,
0.025549370795488358,
-0.07063538581132889,
0.029817083850502968,
-0.02463892661035061,
0.028565222397446632,
0.... |
730,251 | mmengine.registry.registry | _search_child | Depth-first search for the corresponding registry in its children.
Note that the method only search for the corresponding registry from
the current registry. Therefore, if we want to search from the root
registry, :meth:`_get_root_registry` should be called to get the
root registry firs... | def _search_child(self, scope: str) -> Optional['Registry']:
"""Depth-first search for the corresponding registry in its children.
Note that the method only search for the corresponding registry from
the current registry. Therefore, if we want to search from the root
registry, :meth:`_get_root_registry`... | (self, scope: str) -> Optional[mmengine.registry.registry.Registry] | [
0.07053475081920624,
-0.06426342576742172,
-0.05334146320819855,
0.0022416450083255768,
0.00015592975250910968,
0.0325544998049736,
0.047211069613695145,
0.03625387325882912,
0.06909023225307465,
-0.013529142364859581,
0.05320053547620773,
-0.009037043899297714,
0.010287784971296787,
-0.04... |
730,252 | mmengine.registry.registry | build | Build an instance.
Build an instance by calling :attr:`build_func`.
Args:
cfg (dict): Config dict needs to be built.
Returns:
Any: The constructed object.
Examples:
>>> from mmengine import Registry
>>> MODELS = Registry('models')
... | def build(self, cfg: dict, *args, **kwargs) -> Any:
"""Build an instance.
Build an instance by calling :attr:`build_func`.
Args:
cfg (dict): Config dict needs to be built.
Returns:
Any: The constructed object.
Examples:
>>> from mmengine import Registry
>>> MODELS = R... | (self, cfg: dict, *args, **kwargs) -> Any | [
0.06651382893323898,
-0.04346486181020737,
0.006439592223614454,
-0.01659029722213745,
-0.02152254804968834,
0.013480212539434433,
-0.0503719188272953,
-0.020015206187963486,
0.012325855903327465,
-0.029746145009994507,
-0.008152046240866184,
0.0517456978559494,
-0.01466318964958191,
0.032... |
730,253 | mmengine.registry.registry | get | Get the registry record.
If `key`` represents the whole object name with its module
information, for example, `mmengine.model.BaseModel`, ``get``
will directly return the class object :class:`BaseModel`.
Otherwise, it will first parse ``key`` and check whether it
contains a sco... | def get(self, key: str) -> Optional[Type]:
"""Get the registry record.
If `key`` represents the whole object name with its module
information, for example, `mmengine.model.BaseModel`, ``get``
will directly return the class object :class:`BaseModel`.
Otherwise, it will first parse ``key`` and check w... | (self, key: str) -> Optional[Type] | [
0.09342510253190994,
-0.048335615545511246,
-0.04714800789952278,
0.019130373373627663,
0.03198622167110443,
0.004661358427256346,
0.027928562834858894,
-0.020624779164791107,
0.034420814365148544,
-0.021634245291352272,
0.01802193932235241,
-0.009634464047849178,
0.042555924504995346,
0.0... |
730,254 | mmengine.registry.registry | import_from_location | import modules from the pre-defined locations in self._location. | def import_from_location(self) -> None:
"""import modules from the pre-defined locations in self._location."""
if not self._imported:
# Avoid circular import
from ..logging import print_log
# avoid BC breaking
if len(self._locations) == 0 and self.scope in MODULE2PACKAGE:
... | (self) -> NoneType | [
0.0662558302283287,
-0.06116208806633949,
-0.039374254643917084,
0.03567478805780411,
0.01810695230960846,
0.012251008301973343,
0.00799847673624754,
0.017725851386785507,
-0.03426192328333855,
-0.005163455847650766,
-0.0037622121162712574,
-0.0423487052321434,
0.028182895854115486,
0.0146... |
730,255 | mmengine.registry.registry | infer_scope | Infer the scope of registry.
The name of the package where registry is defined will be returned.
Returns:
str: The inferred scope name.
Examples:
>>> # in mmdet/models/backbone/resnet.py
>>> MODELS = Registry('models')
>>> @MODELS.register_modul... | @staticmethod
def infer_scope() -> str:
"""Infer the scope of registry.
The name of the package where registry is defined will be returned.
Returns:
str: The inferred scope name.
Examples:
>>> # in mmdet/models/backbone/resnet.py
>>> MODELS = Registry('models')
>>> @MODEL... | () -> str | [
0.08910863101482391,
-0.017618540674448013,
0.010836546309292316,
-0.02101411484181881,
0.04902072995901108,
0.013966698199510574,
0.04133263975381851,
-0.019531412050127983,
0.014909404329955578,
-0.027256112545728683,
-0.014058222994208336,
-0.04528651386499405,
-0.025901542976498604,
-0... |
730,256 | mmengine.registry.registry | register_module | Register a module.
A record will be added to ``self._module_dict``, whose key is the class
name or the specified name, and value is the class itself.
It can be used as a decorator or a normal function.
Args:
name (str or list of str, optional): The module name to be
... | def register_module(
self,
name: Optional[Union[str, List[str]]] = None,
force: bool = False,
module: Optional[Type] = None) -> Union[type, Callable]:
"""Register a module.
A record will be added to ``self._module_dict``, whose key is the class
name or the specified name, and... | (self, name: Union[str, List[str], NoneType] = None, force: bool = False, module: Optional[Type] = None) -> Union[type, collections.abc.Callable] | [
0.02238526940345764,
-0.004282211884856224,
0.008550061844289303,
0.02186824381351471,
-0.024529965594410896,
-0.003932741470634937,
-0.07337925583124161,
0.042702436447143555,
0.007688353769481182,
-0.06771112978458405,
0.04036625102162361,
-0.011834128759801388,
0.02479805238544941,
0.04... |
730,257 | mmengine.registry.registry | split_scope_key | Split scope and key.
The first scope will be split from key.
Return:
tuple[str | None, str]: The former element is the first scope of
the key, which can be ``None``. The latter is the remaining key.
Examples:
>>> Registry.split_scope_key('mmdet.ResNet')
... | @staticmethod
def split_scope_key(key: str) -> Tuple[Optional[str], str]:
"""Split scope and key.
The first scope will be split from key.
Return:
tuple[str | None, str]: The former element is the first scope of
the key, which can be ``None``. The latter is the remaining key.
Examples:
... | (key: str) -> Tuple[Optional[str], str] | [
0.022588547319173813,
0.01369541883468628,
-0.03121488355100155,
-0.0007514694007113576,
0.0015018271515145898,
-0.03171289712190628,
0.052931904792785645,
0.0069766598753631115,
0.08551633358001709,
-0.03806259110569954,
0.022819768637418747,
-0.009408930316567421,
-0.018693357706069946,
... |
730,258 | mmengine.registry.registry | switch_scope_and_registry | Temporarily switch default scope to the target scope, and get the
corresponding registry.
If the registry of the corresponding scope exists, yield the
registry, otherwise yield the current itself.
Args:
scope (str, optional): The target scope.
Examples:
... | @contextmanager
def switch_scope_and_registry(self, scope: Optional[str]) -> Generator:
"""Temporarily switch default scope to the target scope, and get the
corresponding registry.
If the registry of the corresponding scope exists, yield the
registry, otherwise yield the current itself.
Args:
... | (self, scope: Optional[str]) -> Generator | [
0.09494201838970184,
-0.02673974819481373,
-0.011121666058897972,
-0.02556590549647808,
-0.015359438955783844,
0.010922709479928017,
0.0033374945633113384,
-0.007878676056861877,
0.05431511253118515,
-0.004317355342209339,
0.019268933683633804,
-0.04345209151506424,
-0.0006170758861117065,
... |
730,259 | mmengine.utils.timer | Timer | A flexible Timer class.
Examples:
>>> import time
>>> import mmcv
>>> with mmcv.Timer():
>>> # simulate a code block that will run for 1s
>>> time.sleep(1)
1.000
>>> with mmcv.Timer(print_tmpl='it takes {:.1f} seconds'):
>>> # simulate a c... | class Timer:
"""A flexible Timer class.
Examples:
>>> import time
>>> import mmcv
>>> with mmcv.Timer():
>>> # simulate a code block that will run for 1s
>>> time.sleep(1)
1.000
>>> with mmcv.Timer(print_tmpl='it takes {:.1f} seconds'):
>>... | (start=True, print_tmpl=None) | [
0.10492081195116043,
-0.009160548448562622,
-0.0021399641409516335,
0.04088708013296127,
0.03367878124117851,
-0.0076187727972865105,
-0.031936775892972946,
0.05454280599951744,
-0.03373885154724121,
-0.048175472766160965,
-0.0004414458235260099,
0.029754262417554855,
0.060749951750040054,
... |
730,261 | mmengine.utils.timer | __exit__ | null | def __exit__(self, type, value, traceback):
print(self.print_tmpl.format(self.since_last_check()))
self._is_running = False
| (self, type, value, traceback) | [
0.06551043689250946,
0.05568386986851692,
-0.031153060495853424,
0.041015226393938065,
-0.002674712799489498,
-0.041086435317993164,
-0.023605117574334145,
0.023373695090413094,
0.016947263851761818,
-0.06590206921100616,
0.008135398849844933,
0.021807141602039337,
0.02739689126610756,
-0.... |
730,262 | mmengine.utils.timer | __init__ | null | def __init__(self, start=True, print_tmpl=None):
self._is_running = False
self.print_tmpl = print_tmpl if print_tmpl else '{:.3f}'
if start:
self.start()
| (self, start=True, print_tmpl=None) | [
0.054289720952510834,
0.0023588447365909815,
0.02122960239648819,
-0.020358644425868988,
0.005906184669584036,
0.022027980536222458,
-0.00788398552685976,
0.04242291674017906,
-0.0923941358923912,
0.00616928655654192,
0.03930198401212692,
0.056938882917165756,
0.005575038958340883,
-0.0142... |
730,263 | mmengine.utils.timer | since_last_check | Time since the last checking.
Either :func:`since_start` or :func:`since_last_check` is a checking
operation.
Returns:
float: Time in seconds.
| def since_last_check(self):
"""Time since the last checking.
Either :func:`since_start` or :func:`since_last_check` is a checking
operation.
Returns:
float: Time in seconds.
"""
if not self._is_running:
raise TimerError('timer is not running')
dur = time() - self._t_last
... | (self) | [
-0.0036103271413594484,
0.013176778331398964,
0.015293492935597897,
0.091412752866745,
0.02151535078883171,
-0.020470738410949707,
-0.009305297397077084,
0.06205364316701889,
-0.024887433275580406,
-0.030825229361653328,
0.0049252561293542385,
-0.010739348828792572,
0.021277105435729027,
-... |
730,264 | mmengine.utils.timer | since_start | Total time since the timer is started.
Returns:
float: Time in seconds.
| def since_start(self):
"""Total time since the timer is started.
Returns:
float: Time in seconds.
"""
if not self._is_running:
raise TimerError('timer is not running')
self._t_last = time()
return self._t_last - self._t_start
| (self) | [
-0.027444113045930862,
-0.017598815262317657,
0.05555759370326996,
0.040050555020570755,
0.056078214198350906,
0.002742551965638995,
0.006461266428232193,
0.06634186208248138,
-0.06094972789287567,
-0.007530396804213524,
-0.01589750498533249,
-0.027090834453701973,
0.021903228014707565,
0.... |
730,265 | mmengine.utils.timer | start | Start the timer. | def start(self):
"""Start the timer."""
if not self._is_running:
self._t_start = time()
self._is_running = True
self._t_last = time()
| (self) | [
0.02834303118288517,
-0.0032234760001301765,
0.014452408999204636,
0.04418178275227547,
0.022761410102248192,
0.01302075944840908,
-0.010057789273560047,
0.06549341976642609,
-0.08357932418584824,
-0.008685036562383175,
-0.023957472294569016,
0.03874514251947403,
0.018457401543855667,
0.02... |
730,266 | mmengine.utils.timer | TimerError | null | class TimerError(Exception):
def __init__(self, message):
self.message = message
super().__init__(message)
| (message) | [
0.006647760979831219,
-0.021858738735318184,
-0.014569603838026524,
0.06607891619205475,
-0.034148864448070526,
-0.0343395434319973,
-0.03577829897403717,
0.068436399102211,
0.016927087679505348,
-0.03775442764163017,
0.059595830738544464,
0.05162198469042778,
0.018651865422725677,
0.00505... |
730,267 | mmengine.utils.timer | __init__ | null | def __init__(self, message):
self.message = message
super().__init__(message)
| (self, message) | [
-0.02704630419611931,
-0.007251610513776541,
0.003266147105023265,
0.007130226120352745,
-0.011760826222598553,
-0.046647682785987854,
0.009207252413034439,
0.07437733560800552,
0.06700434535741806,
-0.031056495383381844,
0.0007367375656031072,
0.03229731693863869,
-0.036109693348407745,
0... |
730,268 | mmengine.fileio.handlers.yaml_handler | YamlHandler | null | class YamlHandler(BaseFileHandler):
def load_from_fileobj(self, file, **kwargs):
kwargs.setdefault('Loader', Loader)
return yaml.load(file, **kwargs)
def dump_to_fileobj(self, obj, file, **kwargs):
kwargs.setdefault('Dumper', Dumper)
yaml.dump(obj, file, **kwargs)
def dump... | () | [
-0.028356919065117836,
-0.03555726259946823,
-0.01544963102787733,
-0.04305984824895859,
0.00828484259545803,
-0.011182759888470173,
0.019183143973350525,
0.0693366676568985,
-0.04526439681649208,
0.004395766649395227,
-0.023912260308861732,
-0.04978017136454582,
-0.01757417805492878,
0.01... |
730,269 | mmengine.fileio.handlers.yaml_handler | dump_to_fileobj | null | def dump_to_fileobj(self, obj, file, **kwargs):
kwargs.setdefault('Dumper', Dumper)
yaml.dump(obj, file, **kwargs)
| (self, obj, file, **kwargs) | [
-0.0307356845587492,
-0.011446155607700348,
-0.0016925743548199534,
-0.01946191117167473,
0.026994997635483742,
-0.04419870674610138,
0.019272292032837868,
0.029063580557703972,
-0.07901984453201294,
-0.010920390486717224,
-0.03449361026287079,
-0.03320074453949928,
-0.024064507335424423,
... |
730,271 | mmengine.fileio.handlers.yaml_handler | dump_to_str | null | def dump_to_str(self, obj, **kwargs):
kwargs.setdefault('Dumper', Dumper)
return yaml.dump(obj, **kwargs)
| (self, obj, **kwargs) | [
-0.02625560387969017,
-0.04168775677680969,
0.008196148090064526,
-0.07778920978307724,
0.036660086363554,
-0.038196317851543427,
0.0601225420832634,
-0.02019796147942543,
-0.006044549867510796,
-0.013843546621501446,
-0.04720422625541687,
-0.021716736257076263,
-0.019918646663427353,
-0.0... |
730,272 | mmengine.fileio.handlers.yaml_handler | load_from_fileobj | null | def load_from_fileobj(self, file, **kwargs):
kwargs.setdefault('Loader', Loader)
return yaml.load(file, **kwargs)
| (self, file, **kwargs) | [
-0.010961693711578846,
-0.02725089341402054,
-0.03785333037376404,
-0.014247573912143707,
-0.018400926142930984,
0.001225633081048727,
0.03809867799282074,
0.07451498508453369,
-0.04416222125291824,
0.008337371982634068,
-0.013967178761959076,
0.010418429039418697,
-0.03911510854959488,
-0... |
730,274 | mmengine.utils.misc | apply_to | Apply function to each element in dict, list or tuple that matches with
the expression.
For examples, if you want to convert each element in a list of dict from
`np.ndarray` to `Tensor`. You can use the following code:
Examples:
>>> from mmengine.utils import apply_to
>>> import numpy ... | def apply_to(data: Any, expr: Callable, apply_func: Callable):
"""Apply function to each element in dict, list or tuple that matches with
the expression.
For examples, if you want to convert each element in a list of dict from
`np.ndarray` to `Tensor`. You can use the following code:
Examples:
... | (data: Any, expr: Callable, apply_func: Callable) | [
0.02661939524114132,
-0.048162978142499924,
0.01550412829965353,
-0.0245585385710001,
0.006817045621573925,
0.022306861355900764,
0.00022525708482135087,
-0.03949974849820137,
0.037114497274160385,
0.016820786520838737,
0.029767924919724464,
0.0019356306875124574,
0.02520732581615448,
-0.0... |
730,275 | mmengine.registry.build_functions | build_from_cfg | Build a module from config dict when it is a class configuration, or
call a function from config dict when it is a function configuration.
If the global variable default scope (:obj:`DefaultScope`) exists,
:meth:`build` will firstly get the responding registry and then call
its own :meth:`build`.
... | def build_from_cfg(
cfg: Union[dict, ConfigDict, Config],
registry: Registry,
default_args: Optional[Union[dict, ConfigDict, Config]] = None) -> Any:
"""Build a module from config dict when it is a class configuration, or
call a function from config dict when it is a function configurati... | (cfg: Union[dict, mmengine.config.config.ConfigDict, mmengine.config.config.Config], registry: mmengine.registry.registry.Registry, default_args: Union[dict, mmengine.config.config.ConfigDict, mmengine.config.config.Config, NoneType] = None) -> Any | [
0.0678105279803276,
-0.026854820549488068,
0.00017741203191690147,
-0.03422095626592636,
0.002092771464958787,
0.011869999580085278,
-0.009765389375388622,
-0.008150101639330387,
-0.01215412188321352,
-0.048448119312524796,
0.014311346225440502,
0.019194040447473526,
-0.023824183270335197,
... |
730,276 | mmengine.registry.build_functions | build_model_from_cfg | Build a PyTorch model from config dict(s). Different from
``build_from_cfg``, if cfg is a list, a ``nn.Sequential`` will be built.
Args:
cfg (dict, list[dict]): The config of modules, which is either a config
dict or a list of config dicts. If cfg is a list, the built
modules wi... | def build_model_from_cfg(
cfg: Union[dict, ConfigDict, Config],
registry: Registry,
default_args: Optional[Union[dict, 'ConfigDict', 'Config']] = None
) -> 'nn.Module':
"""Build a PyTorch model from config dict(s). Different from
``build_from_cfg``, if cfg is a list, a ``nn.Sequential`` will be buil... | (cfg: Union[dict, mmengine.config.config.ConfigDict, mmengine.config.config.Config], registry: mmengine.registry.registry.Registry, default_args: Union[dict, ForwardRef('ConfigDict'), ForwardRef('Config'), NoneType] = None) -> 'nn.Module' | [
-0.007078940514475107,
0.012445765547454357,
-0.034261129796504974,
-0.057572245597839355,
-0.010075143538415432,
0.031871695071458817,
-0.03217272460460663,
0.01859809271991253,
-0.01498571690171957,
-0.05279337242245674,
-0.02212580479681492,
0.028786122798919678,
-0.06799545884132385,
0... |
730,277 | mmengine.registry.build_functions | build_runner_from_cfg | Build a Runner object.
Examples:
>>> from mmengine.registry import Registry, build_runner_from_cfg
>>> RUNNERS = Registry('runners', build_func=build_runner_from_cfg)
>>> @RUNNERS.register_module()
>>> class CustomRunner(Runner):
>>> def setup_env(env_cfg):
>>> ... | def build_runner_from_cfg(cfg: Union[dict, ConfigDict, Config],
registry: Registry) -> 'Runner':
"""Build a Runner object.
Examples:
>>> from mmengine.registry import Registry, build_runner_from_cfg
>>> RUNNERS = Registry('runners', build_func=build_runner_from_cfg)
... | (cfg: Union[dict, mmengine.config.config.ConfigDict, mmengine.config.config.Config], registry: mmengine.registry.registry.Registry) -> 'Runner' | [
0.05293574184179306,
-0.015269925817847252,
-0.02735982835292816,
-0.018614767119288445,
-0.027088362723588943,
0.018537204712629318,
-0.012923689559102058,
0.021775398403406143,
-0.03267279267311096,
0.015172973275184631,
0.01067440491169691,
0.06127360463142395,
-0.03544561564922333,
0.0... |
730,278 | mmengine.registry.build_functions | build_scheduler_from_cfg | Builds a ``ParamScheduler`` instance from config.
``ParamScheduler`` supports building instance by its constructor or
method ``build_iter_from_epoch``. Therefore, its registry needs a build
function to handle both cases.
Args:
cfg (dict or ConfigDict or Config): Config dictionary. If it contai... | def build_scheduler_from_cfg(
cfg: Union[dict, ConfigDict, Config],
registry: Registry,
default_args: Optional[Union[dict, ConfigDict, Config]] = None
) -> '_ParamScheduler':
"""Builds a ``ParamScheduler`` instance from config.
``ParamScheduler`` supports building instance by its constructor or
... | (cfg: Union[dict, mmengine.config.config.ConfigDict, mmengine.config.config.Config], registry: mmengine.registry.registry.Registry, default_args: Union[dict, mmengine.config.config.ConfigDict, mmengine.config.config.Config, NoneType] = None) -> '_ParamScheduler' | [
0.11554045230150223,
0.030341828241944313,
-0.03678203746676445,
-0.05305507034063339,
-0.03446279466152191,
-0.00021982491307426244,
-0.023959118872880936,
-0.0009314107592217624,
-0.026585038751363754,
-0.016311367973685265,
0.0008661221363581717,
0.0030619753524661064,
-0.0318752117455005... |
730,279 | mmengine.utils.package_utils | call_command | null | def call_command(cmd: list) -> None:
try:
subprocess.check_call(cmd)
except Exception as e:
raise e # type: ignore
| (cmd: list) -> NoneType | [
0.020301053300499916,
-0.05812148377299309,
0.022201577201485634,
0.04692566767334938,
-0.03963456675410271,
-0.006764138117432594,
0.02311728522181511,
-0.02087121084332466,
0.05566808208823204,
-0.046096350997686386,
0.03897802159190178,
0.025812573730945587,
0.03445132076740265,
-0.0665... |
730,280 | mmengine.utils.path | check_file_exist | null | def check_file_exist(filename, msg_tmpl='file "{}" does not exist'):
if not osp.isfile(filename):
raise FileNotFoundError(msg_tmpl.format(filename))
| (filename, msg_tmpl='file "{}" does not exist') | [
0.010177021846175194,
-0.04035068303346634,
0.024178244173526764,
0.013545535504817963,
0.03218404948711395,
0.007599259726703167,
0.060115013271570206,
-0.009238841012120247,
0.005593340843915939,
0.011186681687831879,
0.028520679101347923,
0.020532744005322456,
0.066083624958992,
-0.0878... |
730,281 | mmengine.utils.misc | check_prerequisites | A decorator factory to check if prerequisites are satisfied.
Args:
prerequisites (str of list[str]): Prerequisites to be checked.
checker (callable): The checker method that returns True if a
prerequisite is meet, False otherwise.
msg_tmpl (str): The message template with two va... | def check_prerequisites(
prerequisites,
checker,
msg_tmpl='Prerequisites "{}" are required in method "{}" but not '
'found, please install them first.'): # yapf: disable
"""A decorator factory to check if prerequisites are satisfied.
Args:
prerequisites (str of... | (prerequisites, checker, msg_tmpl='Prerequisites "{}" are required in method "{}" but not found, please install them first.') | [
-0.008808652870357037,
0.02805553562939167,
-0.009768540970981121,
-0.049074865877628326,
0.01147401798516512,
0.034216683357954025,
0.01873345486819744,
0.08014847338199615,
0.01203655730932951,
0.02885916456580162,
0.08843476325273514,
0.026341130957007408,
0.039181314408779144,
-0.04964... |
730,282 | mmengine.utils.timer | check_time | Add check points in a single line.
This method is suitable for running a task on a list of items. A timer will
be registered when the method is called for the first time.
Examples:
>>> import time
>>> import mmcv
>>> for i in range(1, 6):
>>> # simulate a code block
... | def check_time(timer_id):
"""Add check points in a single line.
This method is suitable for running a task on a list of items. A timer will
be registered when the method is called for the first time.
Examples:
>>> import time
>>> import mmcv
>>> for i in range(1, 6):
>>... | (timer_id) | [
0.02242746390402317,
0.02741134539246559,
0.004372181836515665,
0.0733497217297554,
0.004708503372967243,
-0.027989186346530914,
0.02004386857151985,
0.07179677486419678,
-0.03853479027748108,
-0.018391603603959084,
-0.02878371812403202,
0.0034986482933163643,
0.02497357688844204,
0.014599... |
730,283 | mmengine.utils.misc | concat_list | Concatenate a list of list into a single list.
Args:
in_list (list): The list of list to be merged.
Returns:
list: The concatenated flat list.
| def concat_list(in_list):
"""Concatenate a list of list into a single list.
Args:
in_list (list): The list of list to be merged.
Returns:
list: The concatenated flat list.
"""
return list(itertools.chain(*in_list))
| (in_list) | [
-0.0912666842341423,
-0.030921151861548424,
0.00038274965481832623,
0.005234144162386656,
0.00033511986839585006,
-0.01154523529112339,
-0.005329974461346865,
-0.06454379856586456,
0.06965473294258118,
0.00705947820097208,
-0.028876779600977898,
-0.07461964339017868,
0.0006759438547305763,
... |
730,285 | mmengine.fileio.io | copy_if_symlink_fails | Create a symbolic link pointing to src named dst.
If failed to create a symbolic link pointing to src, directory copy src to
dst instead.
Args:
src (str or Path): Create a symbolic link pointing to src.
dst (str or Path): Create a symbolic link named dst.
backend_args (dict, option... | def copy_if_symlink_fails(
src: Union[str, Path],
dst: Union[str, Path],
backend_args: Optional[dict] = None,
) -> bool:
"""Create a symbolic link pointing to src named dst.
If failed to create a symbolic link pointing to src, directory copy src to
dst instead.
Args:
src (str or Pa... | (src: Union[str, pathlib.Path], dst: Union[str, pathlib.Path], backend_args: Optional[dict] = None) -> bool | [
-0.004010976292192936,
0.009139802306890488,
0.0050303274765610695,
-0.014632847160100937,
-0.0383734256029129,
0.014183874242007732,
-0.0027946264017373323,
0.016932686790823936,
0.0742545947432518,
-0.03271087259054184,
0.07865269482135773,
0.015182609669864178,
0.05285050719976425,
-0.0... |
730,286 | mmengine.fileio.io | copyfile | Copy a file src to dst and return the destination file.
src and dst should have the same prefix. If dst specifies a directory,
the file will be copied into dst using the base filename from src. If
dst specifies a file that already exists, it will be replaced.
Args:
src (str or Path): A file to... | def copyfile(
src: Union[str, Path],
dst: Union[str, Path],
backend_args: Optional[dict] = None,
) -> Union[str, Path]:
"""Copy a file src to dst and return the destination file.
src and dst should have the same prefix. If dst specifies a directory,
the file will be copied into dst using the ba... | (src: Union[str, pathlib.Path], dst: Union[str, pathlib.Path], backend_args: Optional[dict] = None) -> Union[str, pathlib.Path] | [
-0.050302255898714066,
-0.03413235396146774,
0.004650001879781485,
-0.01323159970343113,
-0.06161194667220116,
-0.027664391323924065,
0.025409845635294914,
0.05795292928814888,
0.06419912725687027,
-0.09727812558412552,
0.01448823232203722,
-0.0033771994058042765,
-0.01811029016971588,
0.0... |
730,287 | mmengine.fileio.io | copyfile_from_local | Copy a local file src to dst and return the destination file.
Note:
If the backend is the instance of LocalBackend, it does the same
thing with :func:`copyfile`.
Args:
src (str or Path): A local file to be copied.
dst (str or Path): Copy file to dst.
backend_args (dict,... | def copyfile_from_local(
src: Union[str, Path],
dst: Union[str, Path],
backend_args: Optional[dict] = None,
) -> Union[str, Path]:
"""Copy a local file src to dst and return the destination file.
Note:
If the backend is the instance of LocalBackend, it does the same
thing with :func... | (src: Union[str, pathlib.Path], dst: Union[str, pathlib.Path], backend_args: Optional[dict] = None) -> Union[str, pathlib.Path] | [
-0.03825429454445839,
-0.0011165192117914557,
-0.03821543604135513,
-0.0020581840071827173,
-0.007237036246806383,
-0.05129067227244377,
0.01748545654118061,
0.04752158373594284,
0.07351662963628769,
-0.054127201437950134,
-0.022556237876415253,
-0.03825429454445839,
-0.03481548652052879,
... |
730,288 | mmengine.fileio.io | copyfile_to_local | Copy the file src to local dst and return the destination file.
If dst specifies a directory, the file will be copied into dst using
the base filename from src. If dst specifies a file that already
exists, it will be replaced.
Note:
If the backend is the instance of LocalBackend, it does the s... | def copyfile_to_local(
src: Union[str, Path],
dst: Union[str, Path],
backend_args: Optional[dict] = None,
) -> Union[str, Path]:
"""Copy the file src to local dst and return the destination file.
If dst specifies a directory, the file will be copied into dst using
the base filename from src. If... | (src: Union[str, pathlib.Path], dst: Union[str, pathlib.Path], backend_args: Optional[dict] = None) -> Union[str, pathlib.Path] | [
-0.048464298248291016,
-0.016639409586787224,
-0.025790609419345856,
0.0061150542460381985,
-0.010481592267751694,
-0.039037518203258514,
0.016819963231682777,
0.04044393077492714,
0.06496116518974304,
-0.07324761152267456,
-0.013997630216181278,
-0.038410332053899765,
-0.041242167353630066,... |
730,289 | mmengine.fileio.io | copytree | Recursively copy an entire directory tree rooted at src to a directory
named dst and return the destination directory.
src and dst should have the same prefix and dst must not already exist.
Args:
src (str or Path): A directory to be copied.
dst (str or Path): Copy directory to dst.
... | def copytree(
src: Union[str, Path],
dst: Union[str, Path],
backend_args: Optional[dict] = None,
) -> Union[str, Path]:
"""Recursively copy an entire directory tree rooted at src to a directory
named dst and return the destination directory.
src and dst should have the same prefix and dst must ... | (src: Union[str, pathlib.Path], dst: Union[str, pathlib.Path], backend_args: Optional[dict] = None) -> Union[str, pathlib.Path] | [
-0.04716005548834801,
-0.008245397359132767,
-0.003663563635200262,
-0.060672417283058167,
-0.03648338466882706,
0.033780910074710846,
0.025521239265799522,
0.0494057722389698,
0.08533724397420883,
-0.08883903920650482,
0.01930745504796505,
-0.014987305738031864,
-0.032886430621147156,
0.0... |
730,290 | mmengine.fileio.io | copytree_from_local | Recursively copy an entire directory tree rooted at src to a directory
named dst and return the destination directory.
Note:
If the backend is the instance of LocalBackend, it does the same
thing with :func:`copytree`.
Args:
src (str or Path): A local directory to be copied.
... | def copytree_from_local(
src: Union[str, Path],
dst: Union[str, Path],
backend_args: Optional[dict] = None,
) -> Union[str, Path]:
"""Recursively copy an entire directory tree rooted at src to a directory
named dst and return the destination directory.
Note:
If the backend is the instan... | (src: Union[str, pathlib.Path], dst: Union[str, pathlib.Path], backend_args: Optional[dict] = None) -> Union[str, pathlib.Path] | [
-0.029071833938360214,
0.002927239518612623,
-0.025538135319948196,
-0.022672973573207855,
-0.02015163190662861,
-0.005138188600540161,
0.02725723199546337,
0.034840356558561325,
0.07273688912391663,
-0.07590766996145248,
-0.0057780747301876545,
-0.0447729155421257,
-0.032510027289390564,
... |
730,291 | mmengine.fileio.io | copytree_to_local | Recursively copy an entire directory tree rooted at src to a local
directory named dst and return the destination directory.
Note:
If the backend is the instance of LocalBackend, it does the same
thing with :func:`copytree`.
Args:
src (str or Path): A directory to be copied.
... | def copytree_to_local(
src: Union[str, Path],
dst: Union[str, Path],
backend_args: Optional[dict] = None,
) -> Union[str, Path]:
"""Recursively copy an entire directory tree rooted at src to a local
directory named dst and return the destination directory.
Note:
If the backend is the in... | (src: Union[str, pathlib.Path], dst: Union[str, pathlib.Path], backend_args: Optional[dict] = None) -> Union[str, pathlib.Path] | [
-0.03889044001698494,
-0.004102903883904219,
-0.0219135582447052,
-0.016015928238630295,
-0.019765539094805717,
0.013707749545574188,
0.031391218304634094,
0.03493356332182884,
0.07506759464740753,
-0.0785345733165741,
0.006561819929629564,
-0.050045061856508255,
-0.046050503849983215,
-0.... |
730,292 | mmengine.registry.utils | count_registered_modules | Scan all modules in MMEngine's root and child registries and dump to
json.
Args:
save_path (str, optional): Path to save the json file.
verbose (bool): Whether to print log. Defaults to True.
Returns:
dict: Statistic results of all registered modules.
| def count_registered_modules(save_path: Optional[str] = None,
verbose: bool = True) -> dict:
"""Scan all modules in MMEngine's root and child registries and dump to
json.
Args:
save_path (str, optional): Path to save the json file.
verbose (bool): Whether to pri... | (save_path: Optional[str] = None, verbose: bool = True) -> dict | [
0.01538863591849804,
-0.03350253030657768,
-0.031940050423145294,
0.04182365909218788,
0.06137285754084587,
0.05276103690266609,
-0.04701982066035271,
-0.01775052770972252,
0.002829728415235877,
0.0050644418224692345,
0.05930165946483612,
-0.018313748762011528,
0.01254528108984232,
-0.0407... |
730,293 | mmengine.utils.misc | deprecated_api_warning | A decorator to check if some arguments are deprecate and try to replace
deprecate src_arg_name to dst_arg_name.
Args:
name_dict(dict):
key (str): Deprecate argument names.
val (str): Expected argument names.
Returns:
func: New function.
| def deprecated_api_warning(name_dict: dict,
cls_name: Optional[str] = None) -> Callable:
"""A decorator to check if some arguments are deprecate and try to replace
deprecate src_arg_name to dst_arg_name.
Args:
name_dict(dict):
key (str): Deprecate argument nam... | (name_dict: dict, cls_name: Optional[str] = None) -> Callable | [
-0.02806941047310829,
-0.05718645825982094,
0.014675931073725224,
-0.004822736606001854,
-0.0200315173715353,
-0.020284393802285194,
-0.007550201844424009,
0.032512832432985306,
0.05866759642958641,
-0.021115276962518692,
-0.03796776011586189,
-0.028737729415297508,
0.04555409029126167,
-0... |
730,294 | mmengine.utils.misc | deprecated_function | Marks functions as deprecated.
Throw a warning when a deprecated function is called, and add a note in the
docstring. Modified from https://github.com/pytorch/pytorch/blob/master/torch/onnx/_deprecation.py
Args:
since (str): The version when the function was first deprecated.
removed_in (s... | def deprecated_function(since: str, removed_in: str,
instructions: str) -> Callable:
"""Marks functions as deprecated.
Throw a warning when a deprecated function is called, and add a note in the
docstring. Modified from https://github.com/pytorch/pytorch/blob/master/torch/onnx/_depr... | (since: str, removed_in: str, instructions: str) -> Callable | [
-0.028736479580402374,
-0.010696771554648876,
0.024439087137579918,
-0.006903855130076408,
0.04600078985095024,
-0.00951031781733036,
-0.046112895011901855,
0.044431306421756744,
0.000944141938816756,
-0.014031922444701195,
-0.03550020232796669,
-0.014966138638556004,
0.026008570566773415,
... |
730,295 | mmengine.fileio.parse | dict_from_file | Load a text file and parse the content as a dict.
Each line of the text file will be two or more columns split by
whitespaces or tabs. The first column will be parsed as dict keys, and
the following columns will be parsed as dict values.
``dict_from_file`` supports loading a text file which can be sto... | def dict_from_file(filename,
key_type=str,
encoding='utf-8',
file_client_args=None,
backend_args=None):
"""Load a text file and parse the content as a dict.
Each line of the text file will be two or more columns split by
whitespace... | (filename, key_type=<class 'str'>, encoding='utf-8', file_client_args=None, backend_args=None) | [
0.02222765050828457,
0.02220744453370571,
-0.05601368099451065,
-0.006713761016726494,
0.002139411401003599,
0.028148289769887924,
-0.0022038209717720747,
0.020570680499076843,
0.04397033527493477,
-0.04946662858128548,
0.009093130007386208,
0.011992827989161015,
-0.021520407870411873,
0.0... |
730,296 | mmengine.utils.version_utils | digit_version | Convert a version string into a tuple of integers.
This method is usually used for comparing two versions. For pre-release
versions: alpha < beta < rc.
Args:
version_str (str): The version string.
length (int): The maximum number of version levels. Defaults to 4.
Returns:
tupl... | def digit_version(version_str: str, length: int = 4):
"""Convert a version string into a tuple of integers.
This method is usually used for comparing two versions. For pre-release
versions: alpha < beta < rc.
Args:
version_str (str): The version string.
length (int): The maximum number... | (version_str: str, length: int = 4) | [
-0.000987748964689672,
0.09741954505443573,
-0.09366413950920105,
-0.0026876896154135466,
0.045543450862169266,
-0.012149829417467117,
-0.00562850059941411,
0.01931086555123329,
0.05563149228692055,
-0.04189850389957428,
0.010695531964302063,
0.06851767748594284,
0.03017207607626915,
0.021... |
730,297 | mmengine.fileio.io | dump | Dump data to json/yaml/pickle strings or files.
This method provides a unified api for dumping data as strings or to files,
and also supports custom arguments for each file format.
``dump`` supports dumping data as strings or to files which is saved to
different backends.
Args:
obj (any):... | def dump(obj,
file=None,
file_format=None,
file_client_args=None,
backend_args=None,
**kwargs):
"""Dump data to json/yaml/pickle strings or files.
This method provides a unified api for dumping data as strings or to files,
and also supports custom arguments for ... | (obj, file=None, file_format=None, file_client_args=None, backend_args=None, **kwargs) | [
-0.01113194227218628,
-0.015443542040884495,
-0.05112871527671814,
-0.02136722393333912,
0.0357901006937027,
-0.05715732276439667,
0.023561179637908936,
0.0584164634346962,
-0.03010489232838154,
-0.06948163360357285,
-0.00978695135563612,
0.007578687276691198,
-0.04197133332490921,
-0.0138... |
730,298 | mmengine.fileio.io | exists | Check whether a file path exists.
Args:
filepath (str or Path): Path to be checked whether exists.
backend_args (dict, optional): Arguments to instantiate the
corresponding backend. Defaults to None.
Returns:
bool: Return ``True`` if ``filepath`` exists, ``False`` otherwise... | def exists(
filepath: Union[str, Path],
backend_args: Optional[dict] = None,
) -> bool:
"""Check whether a file path exists.
Args:
filepath (str or Path): Path to be checked whether exists.
backend_args (dict, optional): Arguments to instantiate the
corresponding backend. De... | (filepath: Union[str, pathlib.Path], backend_args: Optional[dict] = None) -> bool | [
-0.008589010685682297,
-0.07514362037181854,
-0.03640904650092125,
-0.005146138835698366,
0.035882167518138885,
0.042150191962718964,
0.03166715055704117,
-0.011273359879851341,
-0.011554966680705547,
-0.04135079309344292,
0.055340297520160675,
0.043748993426561356,
0.025816993787884712,
-... |
730,300 | mmengine.utils.path | fopen | null | def fopen(filepath, *args, **kwargs):
if is_str(filepath):
return open(filepath, *args, **kwargs)
elif isinstance(filepath, Path):
return filepath.open(*args, **kwargs)
raise ValueError('`filepath` should be a string or a Path')
| (filepath, *args, **kwargs) | [
0.010292649269104004,
-0.05164291709661484,
-0.0008491649641655385,
0.017624985426664352,
-0.002810586243867874,
-0.03266611322760582,
0.005304607097059488,
0.08254653215408325,
0.0324607752263546,
-0.007999690249562263,
0.028028860688209534,
0.017967218533158302,
-0.007541953586041927,
0.... |
730,301 | mmengine.fileio.io | generate_presigned_url | Generate the presigned url of video stream which can be passed to
mmcv.VideoReader. Now only work on Petrel backend.
Note:
Now only work on Petrel backend.
Args:
url (str): Url of video stream.
client_method (str): Method of client, 'get_object' or
'put_object'. Default... | def generate_presigned_url(
url: str,
client_method: str = 'get_object',
expires_in: int = 3600,
backend_args: Optional[dict] = None,
) -> str:
"""Generate the presigned url of video stream which can be passed to
mmcv.VideoReader. Now only work on Petrel backend.
Note:
Now only work... | (url: str, client_method: str = 'get_object', expires_in: int = 3600, backend_args: Optional[dict] = None) -> str | [
-0.03448725491762161,
-0.04452597349882126,
-0.07045623660087585,
0.03169048950076103,
-0.02407810464501381,
0.03031989000737667,
0.028060251846909523,
0.0353948138654232,
0.041192080825567245,
0.014372776262462139,
0.033746387809515,
0.034820642322301865,
-0.006848368793725967,
0.02302237... |
730,302 | mmengine.fileio.io | get | Read bytes from a given ``filepath`` with 'rb' mode.
Args:
filepath (str or Path): Path to read data.
backend_args (dict, optional): Arguments to instantiate the
corresponding backend. Defaults to None.
Returns:
bytes: Expected bytes object.
Examples:
>>> filep... | def get(
filepath: Union[str, Path],
backend_args: Optional[dict] = None,
) -> bytes:
"""Read bytes from a given ``filepath`` with 'rb' mode.
Args:
filepath (str or Path): Path to read data.
backend_args (dict, optional): Arguments to instantiate the
corresponding backend. D... | (filepath: Union[str, pathlib.Path], backend_args: Optional[dict] = None) -> bytes | [
0.02663027122616768,
-0.08098520338535309,
-0.04924776032567024,
0.029731055721640587,
-0.021760214120149612,
-0.013388094492256641,
0.011874182149767876,
0.03837677463889122,
0.09258578717708588,
-0.09732816368341446,
0.08426839113235474,
0.06464224308729172,
-0.046767134219408035,
-0.003... |
730,303 | mmengine.fileio.io | get_file_backend | Return a file backend based on the prefix of uri or backend_args.
Args:
uri (str or Path): Uri to be parsed that contains the file prefix.
backend_args (dict, optional): Arguments to instantiate the
corresponding backend. Defaults to None.
enable_singleton (bool): Whether to ena... | def get_file_backend(
uri: Union[str, Path, None] = None,
*,
backend_args: Optional[dict] = None,
enable_singleton: bool = False,
):
"""Return a file backend based on the prefix of uri or backend_args.
Args:
uri (str or Path): Uri to be parsed that contains the file prefix.
back... | (uri: Union[str, pathlib.Path, NoneType] = None, *, backend_args: Optional[dict] = None, enable_singleton: bool = False) | [
0.010759115219116211,
-0.057544395327568054,
-0.04292399436235428,
0.014067448675632477,
-0.006438599433749914,
0.04393617808818817,
-0.005285836756229401,
0.05297083407640457,
0.024367334321141243,
-0.08359869569540024,
0.056082356721162796,
0.0460355170071125,
-0.06717886030673981,
-0.00... |
730,304 | mmengine.utils.version_utils | get_git_hash | Get the git hash of the current repo.
Args:
fallback (str, optional): The fallback string when git hash is
unavailable. Defaults to 'unknown'.
digits (int, optional): kept digits of the hash. Defaults to None,
meaning all digits are kept.
Returns:
str: Git commi... | def get_git_hash(fallback='unknown', digits=None):
"""Get the git hash of the current repo.
Args:
fallback (str, optional): The fallback string when git hash is
unavailable. Defaults to 'unknown'.
digits (int, optional): kept digits of the hash. Defaults to None,
meaning... | (fallback='unknown', digits=None) | [
0.010053140111267567,
-0.046097323298454285,
-0.011918400414288044,
0.04529167339205742,
0.03233117610216141,
-0.03509841859340668,
0.008853418752551079,
0.055905263870954514,
0.04087809845805168,
-0.04644760861992836,
0.06417195498943329,
0.009974326007068157,
-0.0046368795447051525,
-0.0... |
730,305 | mmengine.utils.package_utils | get_installed_path | Get installed path of package.
Args:
package (str): Name of package.
Example:
>>> get_installed_path('mmcls')
>>> '.../lib/python3.7/site-packages/mmcls'
| def get_installed_path(package: str) -> str:
"""Get installed path of package.
Args:
package (str): Name of package.
Example:
>>> get_installed_path('mmcls')
>>> '.../lib/python3.7/site-packages/mmcls'
"""
import importlib.util
from pkg_resources import DistributionNot... | (package: str) -> str | [
0.03245150297880173,
0.07276668399572372,
-0.0050809308886528015,
-0.0054824212566018105,
0.06427539139986038,
-0.02774437516927719,
0.0516861267387867,
0.03560804948210716,
0.055747177451848984,
-0.024753963574767113,
0.02144974283874035,
-0.06778266280889511,
-0.03335601091384888,
0.0011... |
730,306 | mmengine.fileio.io | get_local_path | Download data from ``filepath`` and write the data to local path.
``get_local_path`` is decorated by :meth:`contxtlib.contextmanager`. It
can be called with ``with`` statement, and when exists from the
``with`` statement, the temporary path will be released.
Note:
If the ``filepath`` is a loca... | def exists(
filepath: Union[str, Path],
backend_args: Optional[dict] = None,
) -> bool:
"""Check whether a file path exists.
Args:
filepath (str or Path): Path to be checked whether exists.
backend_args (dict, optional): Arguments to instantiate the
corresponding backend. De... | (filepath: Union[str, pathlib.Path], backend_args: Optional[dict] = None) -> Generator[Union[str, pathlib.Path], NoneType, NoneType] | [
-0.00855205487459898,
-0.07521084696054459,
-0.03637007623910904,
-0.005095807369798422,
0.035897739231586456,
0.04218347743153572,
0.031664855778217316,
-0.011299794539809227,
-0.01160863135010004,
-0.04134780168533325,
0.05529995635151863,
0.04381849616765976,
0.025869624689221382,
-0.07... |
730,307 | mmengine.utils.misc | get_object_from_string | Get object from name.
Args:
obj_name (str): The name of the object.
Examples:
>>> get_object_from_string('torch.optim.sgd.SGD')
>>> torch.optim.sgd.SGD
| def get_object_from_string(obj_name: str):
"""Get object from name.
Args:
obj_name (str): The name of the object.
Examples:
>>> get_object_from_string('torch.optim.sgd.SGD')
>>> torch.optim.sgd.SGD
"""
parts = iter(obj_name.split('.'))
module_name = next(parts)
# im... | (obj_name: str) | [
0.05336123704910278,
0.03225456550717354,
-0.07900138944387436,
-0.037698451429605484,
0.0076455953530967236,
-0.04184174910187721,
0.051428936421871185,
0.042101867496967316,
0.004997971002012491,
-0.004001628141850233,
-0.0019323010928928852,
0.06792781502008438,
-0.04626374691724777,
0.... |
730,308 | mmengine.fileio.io | get_text | Read text from a given ``filepath`` with 'r' mode.
Args:
filepath (str or Path): Path to read data.
encoding (str): The encoding format used to open the ``filepath``.
Defaults to 'utf-8'.
backend_args (dict, optional): Arguments to instantiate the
corresponding backe... | def get_text(
filepath: Union[str, Path],
encoding='utf-8',
backend_args: Optional[dict] = None,
) -> str:
"""Read text from a given ``filepath`` with 'r' mode.
Args:
filepath (str or Path): Path to read data.
encoding (str): The encoding format used to open the ``filepath``.
... | (filepath: Union[str, pathlib.Path], encoding='utf-8', backend_args: Optional[dict] = None) -> str | [
-0.006012364290654659,
-0.07986904680728912,
-0.00226406566798687,
0.05754121020436287,
0.021777627989649773,
0.020464224740862846,
-0.01587619259953499,
-0.009264810010790825,
0.13517393171787262,
-0.05111619085073471,
0.06921984255313873,
0.016062552109360695,
-0.05022875592112541,
-0.00... |
730,309 | mmengine.utils.misc | has_method | Check whether the object has a method.
Args:
method (str): The method name to check.
obj (object): The object to check.
Returns:
bool: True if the object has the method else False.
| def has_method(obj: object, method: str) -> bool:
"""Check whether the object has a method.
Args:
method (str): The method name to check.
obj (object): The object to check.
Returns:
bool: True if the object has the method else False.
"""
return hasattr(obj, method) and call... | (obj: object, method: str) -> bool | [
0.02853395603597164,
-0.02284185402095318,
0.006545917131006718,
-0.04212155193090439,
0.014992261305451393,
-0.05236733704805374,
0.041460536420345306,
0.050971854478120804,
-0.0070921750739216805,
0.0419379360973835,
-0.010181517340242863,
-0.00040625082328915596,
0.06466962397098541,
-0... |
730,310 | mmengine.utils.misc | import_modules_from_strings | Import modules from the given list of strings.
Args:
imports (list | str | None): The given module names to be imported.
allow_failed_imports (bool): If True, the failed imports will return
None. Otherwise, an ImportError is raise. Defaults to False.
Returns:
list[module] |... | def import_modules_from_strings(imports, allow_failed_imports=False):
"""Import modules from the given list of strings.
Args:
imports (list | str | None): The given module names to be imported.
allow_failed_imports (bool): If True, the failed imports will return
None. Otherwise, an ... | (imports, allow_failed_imports=False) | [
-0.010771770030260086,
0.011941597796976566,
-0.0065744295716285706,
-0.0014026230201125145,
-0.008960877545177937,
0.04106561839580536,
0.021768147125840187,
0.05907160043716431,
0.03994258493185043,
0.04072871059179306,
-0.04129022732377052,
0.01255926676094532,
-0.03971797972917557,
-0.... |
730,311 | mmengine.registry.utils | init_default_scope | Initialize the given default scope.
Args:
scope (str): The name of the default scope.
| def init_default_scope(scope: str) -> None:
"""Initialize the given default scope.
Args:
scope (str): The name of the default scope.
"""
never_created = DefaultScope.get_current_instance(
) is None or not DefaultScope.check_instance_created(scope)
if never_created:
DefaultScope.... | (scope: str) -> NoneType | [
0.02679608017206192,
0.02366987057030201,
-0.04205198213458061,
-0.03410247713327408,
-0.03261976316571236,
-0.022740939632058144,
0.050555270165205,
0.05409235507249832,
0.05162711441516876,
0.009110667742788792,
-0.008753386326134205,
0.011316877789795399,
-0.07284960895776749,
-0.030940... |
730,312 | mmengine.utils.package_utils | install_package | null | def install_package(package: str):
if not is_installed(package):
call_command(['python', '-m', 'pip', 'install', package])
| (package: str) | [
0.017810598015785217,
0.03294786810874939,
0.04926557093858719,
-0.000191494298633188,
0.06794413179159164,
-0.02272326685488224,
0.04686999320983887,
0.07277000695466995,
0.024511270225048065,
-0.013635695911943913,
0.04398835822939873,
-0.017428694292902946,
-0.013166996650397778,
-0.019... |
730,313 | mmengine.utils.path | is_abs | Check if path is an absolute path in different backends.
Args:
path (str): path of directory or file.
Returns:
bool: whether path is an absolute path.
| def is_abs(path: str) -> bool:
"""Check if path is an absolute path in different backends.
Args:
path (str): path of directory or file.
Returns:
bool: whether path is an absolute path.
"""
if osp.isabs(path) or path.startswith(('http://', 'https://', 's3://')):
return True
... | (path: str) -> bool | [
0.050016336143016815,
0.013242797926068306,
-0.035476282238960266,
0.01573820970952511,
0.01700843684375286,
-0.01717960275709629,
0.0535837821662426,
0.014305825345218182,
0.020179500803351402,
-0.009477159008383751,
0.02834138832986355,
0.018485864624381065,
0.005643954034894705,
-0.0290... |
730,314 | mmengine.utils.path | is_filepath | null | def is_filepath(x):
return is_str(x) or isinstance(x, Path)
| (x) | [
0.003417340572923422,
-0.009368115104734898,
0.01504576113075018,
0.024276236072182655,
0.013720977120101452,
-0.03427233174443245,
0.07976231724023819,
0.0826527550816536,
0.005836791824549437,
-0.00998749490827322,
0.0957285463809967,
-0.01163917314261198,
0.01724799908697605,
0.00055324... |
730,315 | mmengine.utils.package_utils | is_installed | Check package whether installed.
Args:
package (str): Name of package to be checked.
| def is_installed(package: str) -> bool:
"""Check package whether installed.
Args:
package (str): Name of package to be checked.
"""
# When executing `import mmengine.runner`,
# pkg_resources will be imported and it takes too much time.
# Therefore, import it in function scope to save ti... | (package: str) -> bool | [
0.08996634185314178,
0.02213372476398945,
0.007385363802313805,
0.017409954220056534,
0.10385136306285858,
-0.02471032552421093,
0.04655776172876358,
0.010628482326865196,
0.0009930653031915426,
0.025265011936426163,
0.031617049127817154,
-0.006535443011671305,
-0.011326312087476254,
-0.02... |
730,316 | mmengine.utils.misc | is_list_of | Check whether it is a list of some type.
A partial method of :func:`is_seq_of`.
| def is_list_of(seq, expected_type):
"""Check whether it is a list of some type.
A partial method of :func:`is_seq_of`.
"""
return is_seq_of(seq, expected_type, seq_type=list)
| (seq, expected_type) | [
0.024475455284118652,
0.017972184345126152,
-0.008922778069972992,
-0.006715826224535704,
-0.004540531430393457,
0.024529723450541496,
-0.005236987490206957,
0.013974345289170742,
-0.0376267172396183,
0.020441437140107155,
-0.00399331608787179,
-0.061649926006793976,
0.025036238133907318,
... |
730,317 | mmengine.utils.misc | is_method_overridden | Check if a method of base class is overridden in derived class.
Args:
method (str): the method name to check.
base_class (type): the class of the base class.
derived_class (type | Any): the class or instance of the derived class.
| def is_method_overridden(method: str, base_class: type,
derived_class: Union[type, Any]) -> bool:
"""Check if a method of base class is overridden in derived class.
Args:
method (str): the method name to check.
base_class (type): the class of the base class.
der... | (method: str, base_class: type, derived_class: Union[type, Any]) -> bool | [
-0.02493184059858322,
-0.040804363787174225,
0.008656889200210571,
0.06057014688849449,
-0.053457457572221756,
-0.0807102769613266,
0.0063593038357794285,
0.03870799019932747,
0.008900217711925507,
0.007655497174710035,
0.000848726078402251,
-0.01850234530866146,
-0.001988744828850031,
-0.... |
730,318 | mmengine.utils.misc | is_seq_of | Check whether it is a sequence of some type.
Args:
seq (Sequence): The sequence to be checked.
expected_type (type or tuple): Expected type of sequence items.
seq_type (type, optional): Expected sequence type. Defaults to None.
Returns:
bool: Return True if ``seq`` is valid els... | def is_seq_of(seq: Any,
expected_type: Union[Type, tuple],
seq_type: Type = None) -> bool:
"""Check whether it is a sequence of some type.
Args:
seq (Sequence): The sequence to be checked.
expected_type (type or tuple): Expected type of sequence items.
seq_ty... | (seq: Any, expected_type: Union[Type, tuple], seq_type: Optional[Type] = None) -> bool | [
0.012758200988173485,
0.06429096311330795,
-0.028442084789276123,
-0.0016827307408675551,
0.002203520853072405,
0.02540529891848564,
-0.016794903203845024,
0.01348036341369152,
-0.026590386405587196,
0.006490202154964209,
-0.013406295329332352,
0.007906751707196236,
0.06806842982769012,
0.... |
730,319 | mmengine.utils.misc | is_str | Whether the input is an string instance.
Note: This method is deprecated since python 2 is no longer supported.
| def is_str(x):
"""Whether the input is an string instance.
Note: This method is deprecated since python 2 is no longer supported.
"""
return isinstance(x, str)
| (x) | [
0.015812557190656662,
-0.009393597953021526,
-0.007597506977617741,
-0.03684377670288086,
0.012516099028289318,
-0.01266396138817072,
0.0525345653295517,
0.043071385473012924,
0.042827848345041275,
-0.027102269232273102,
0.015499436296522617,
-0.01266396138817072,
0.011080966331064701,
-0.... |
730,320 | mmengine.utils.misc | is_tuple_of | Check whether it is a tuple of some type.
A partial method of :func:`is_seq_of`.
| def is_tuple_of(seq, expected_type):
"""Check whether it is a tuple of some type.
A partial method of :func:`is_seq_of`.
"""
return is_seq_of(seq, expected_type, seq_type=tuple)
| (seq, expected_type) | [
0.010459773242473602,
0.037453897297382355,
-0.0009025373146869242,
0.010289037600159645,
0.0027834319043904543,
-0.0060700830072164536,
-0.009170273318886757,
0.05244264379143715,
-0.03781333938241005,
0.008527770638465881,
0.013191535137593746,
0.010369912721216679,
0.026652652770280838,
... |
730,321 | mmengine.fileio.io | isdir | Check whether a file path is a directory.
Args:
filepath (str or Path): Path to be checked whether it is a
directory.
backend_args (dict, optional): Arguments to instantiate the
corresponding backend. Defaults to None.
Returns:
bool: Return ``True`` if ``filepat... | def isdir(
filepath: Union[str, Path],
backend_args: Optional[dict] = None,
) -> bool:
"""Check whether a file path is a directory.
Args:
filepath (str or Path): Path to be checked whether it is a
directory.
backend_args (dict, optional): Arguments to instantiate the
... | (filepath: Union[str, pathlib.Path], backend_args: Optional[dict] = None) -> bool | [
-0.015214022248983383,
0.015400697477161884,
0.006584964692592621,
-0.029326660558581352,
0.042039234191179276,
0.036980342119932175,
0.026787878945469856,
-0.012357892468571663,
-0.0399484746158123,
-0.03152942657470703,
0.04050850123167038,
0.027403907850384712,
-0.007569675799459219,
-0... |
730,322 | mmengine.fileio.io | isfile | Check whether a file path is a file.
Args:
filepath (str or Path): Path to be checked whether it is a file.
backend_args (dict, optional): Arguments to instantiate the
corresponding backend. Defaults to None.
Returns:
bool: Return ``True`` if ``filepath`` points to a file, ... | def isfile(
filepath: Union[str, Path],
backend_args: Optional[dict] = None,
) -> bool:
"""Check whether a file path is a file.
Args:
filepath (str or Path): Path to be checked whether it is a file.
backend_args (dict, optional): Arguments to instantiate the
corresponding ba... | (filepath: Union[str, pathlib.Path], backend_args: Optional[dict] = None) -> bool | [
0.002296412130817771,
-0.06799062341451645,
-0.007363470271229744,
-0.005419813096523285,
0.013035585172474384,
0.012063756585121155,
0.07228909432888031,
-0.00997058767825365,
0.004742336459457874,
-0.05255350098013878,
0.07655019313097,
0.039284300059080124,
0.01083962619304657,
-0.03478... |
730,323 | mmengine.utils.misc | iter_cast | Cast elements of an iterable object into some type.
Args:
inputs (Iterable): The input object.
dst_type (type): Destination type.
return_type (type, optional): If specified, the output object will be
converted to this type, otherwise an iterator.
Returns:
iterator o... | def iter_cast(inputs, dst_type, return_type=None):
"""Cast elements of an iterable object into some type.
Args:
inputs (Iterable): The input object.
dst_type (type): Destination type.
return_type (type, optional): If specified, the output object will be
converted to this typ... | (inputs, dst_type, return_type=None) | [
-0.042251620441675186,
0.012109996750950813,
-0.07290893793106079,
-0.06362638622522354,
-0.05939410999417305,
0.018920758739113808,
-0.008268940262496471,
0.059607502073049545,
0.060567766427993774,
0.022139422595500946,
-0.012812412343919277,
0.0037121318746358156,
-0.004596819635480642,
... |
730,324 | mmengine.fileio.io | join_path | Concatenate all file paths.
Join one or more filepath components intelligently. The return value
is the concatenation of filepath and any members of \*filepaths.
Args:
filepath (str or Path): Path to be concatenated.
*filepaths (str or Path): Other paths to be concatenated.
backend... | def join_path(
filepath: Union[str, Path],
*filepaths: Union[str, Path],
backend_args: Optional[dict] = None,
) -> Union[str, Path]:
r"""Concatenate all file paths.
Join one or more filepath components intelligently. The return value
is the concatenation of filepath and any members of \*filepat... | (filepath: Union[str, pathlib.Path], *filepaths: Union[str, pathlib.Path], backend_args: Optional[dict] = None) -> Union[str, pathlib.Path] | [
-0.11200112849473953,
-0.027523525059223175,
-0.03491325303912163,
0.0658290833234787,
-0.047932375222444534,
-0.021600741893053055,
-0.014742781408131123,
0.016833174973726273,
0.026698369532823563,
-0.04056098684668541,
0.024644648656249046,
0.0030278628692030907,
-0.027908599004149437,
... |
730,325 | mmengine.utils.misc | list_cast | Cast elements of an iterable object into a list of some type.
A partial method of :func:`iter_cast`.
| def list_cast(inputs, dst_type):
"""Cast elements of an iterable object into a list of some type.
A partial method of :func:`iter_cast`.
"""
return iter_cast(inputs, dst_type, return_type=list)
| (inputs, dst_type) | [
-0.061329856514930725,
-0.009233021177351475,
-0.034107450395822525,
-0.056810442358255386,
-0.05246756970882416,
0.0428285077214241,
0.021149443462491035,
0.04007449001073837,
0.0356609970331192,
0.019048621878027916,
-0.011898769065737724,
-0.05472727492451668,
0.007807463873177767,
-0.0... |
730,326 | mmengine.fileio.io | list_dir_or_file | Scan a directory to find the interested directories or files in
arbitrary order.
Note:
:meth:`list_dir_or_file` returns the path relative to ``dir_path``.
Args:
dir_path (str or Path): Path of the directory.
list_dir (bool): List the directories. Defaults to True.
list_file... | def list_dir_or_file(
dir_path: Union[str, Path],
list_dir: bool = True,
list_file: bool = True,
suffix: Optional[Union[str, Tuple[str]]] = None,
recursive: bool = False,
backend_args: Optional[dict] = None,
) -> Iterator[str]:
"""Scan a directory to find the interested directories or files ... | (dir_path: Union[str, pathlib.Path], list_dir: bool = True, list_file: bool = True, suffix: Union[str, Tuple[str], NoneType] = None, recursive: bool = False, backend_args: Optional[dict] = None) -> Iterator[str] | [
0.013908403925597668,
-0.02903035655617714,
-0.031267836689949036,
0.004460738971829414,
0.04558391869068146,
0.06185305118560791,
0.011139996349811554,
-0.01679058186709881,
0.035856567323207855,
-0.08661703020334244,
0.05806071311235428,
0.039971254765987396,
-0.023000536486506462,
-0.00... |
730,327 | mmengine.fileio.parse | list_from_file | Load a text file and parse the content as a list of strings.
``list_from_file`` supports loading a text file which can be storaged in
different backends and parsing the content as a list for strings.
Args:
filename (str): Filename.
prefix (str): The prefix to be inserted to the beginning o... | def list_from_file(filename,
prefix='',
offset=0,
max_num=0,
encoding='utf-8',
file_client_args=None,
backend_args=None):
"""Load a text file and parse the content as a list of strings.
``list_from... | (filename, prefix='', offset=0, max_num=0, encoding='utf-8', file_client_args=None, backend_args=None) | [
-0.03145477920770645,
-0.006281537935137749,
-0.055789850652217865,
-0.029194554314017296,
0.031096909195184708,
0.11383992433547974,
-0.026689473539590836,
0.029627762734889984,
0.08408031612634659,
-0.035202980041503906,
0.00454870006069541,
0.01488922256976366,
-0.010029741562902927,
-0... |
730,328 | mmengine.fileio.io | load | Load data from json/yaml/pickle files.
This method provides a unified api for loading data from serialized files.
``load`` supports loading data from serialized files those can be storaged
in different backends.
Args:
file (str or :obj:`Path` or file-like object): Filename or a file-like
... | def load(file,
file_format=None,
file_client_args=None,
backend_args=None,
**kwargs):
"""Load data from json/yaml/pickle files.
This method provides a unified api for loading data from serialized files.
``load`` supports loading data from serialized files those can be s... | (file, file_format=None, file_client_args=None, backend_args=None, **kwargs) | [
0.010310088284313679,
-0.05584551393985748,
-0.05446186661720276,
0.013125425204634666,
-0.011857082135975361,
0.0241177286952734,
0.011463127098977566,
0.08040524274110794,
0.020312700420618057,
-0.03507159650325775,
0.027692148461937904,
0.04181687533855438,
-0.04446886479854584,
-0.0142... |
730,330 | mmengine.utils.path | mkdir_or_exist | null | def mkdir_or_exist(dir_name, mode=0o777):
if dir_name == '':
return
dir_name = osp.expanduser(dir_name)
os.makedirs(dir_name, mode=mode, exist_ok=True)
| (dir_name, mode=511) | [
-0.038513682782649994,
0.07197465747594833,
0.0382310152053833,
-0.030422277748584747,
0.052187807857990265,
0.013479789718985558,
-0.015520308166742325,
0.018850505352020264,
0.022277869284152985,
0.0027582335751503706,
0.08508343994617462,
0.07116198539733887,
0.052682481706142426,
-0.00... |
730,331 | mmengine.logging.logger | print_log | Print a log message.
Args:
msg (str): The message to be logged.
logger (Logger or str, optional): If the type of logger is
``logging.Logger``, we directly use logger to log messages.
Some special loggers are:
- "silent": No message will be printed.
- "cu... | def print_log(msg,
logger: Optional[Union[Logger, str]] = None,
level=logging.INFO) -> None:
"""Print a log message.
Args:
msg (str): The message to be logged.
logger (Logger or str, optional): If the type of logger is
``logging.Logger``, we directly use logg... | (msg, logger: Union[logging.Logger, str, NoneType] = None, level=20) -> NoneType | [
0.07022841274738312,
-0.010127616114914417,
-0.02002396434545517,
0.03438185900449753,
0.032030634582042694,
-0.05357711389660835,
0.01689220778644085,
0.02181629091501236,
-0.027328182011842728,
0.002770399209111929,
0.028831424191594124,
0.01589968241751194,
0.030816474929451942,
0.01712... |
730,332 | mmengine.fileio.io | put | Write bytes to a given ``filepath`` with 'wb' mode.
Note:
``put`` should create a directory if the directory of
``filepath`` does not exist.
Args:
obj (bytes): Data to be written.
filepath (str or Path): Path to write data.
backend_args (dict, optional): Arguments to in... | def put(
obj: bytes,
filepath: Union[str, Path],
backend_args: Optional[dict] = None,
) -> None:
"""Write bytes to a given ``filepath`` with 'wb' mode.
Note:
``put`` should create a directory if the directory of
``filepath`` does not exist.
Args:
obj (bytes): Data to be... | (obj: bytes, filepath: Union[str, pathlib.Path], backend_args: Optional[dict] = None) -> NoneType | [
-0.023772571235895157,
-0.019299620762467384,
-0.07669951021671295,
0.004998655524104834,
-0.008139521814882755,
-0.06700515002012253,
-0.008861253038048744,
0.09566054493188858,
-0.026695135980844498,
-0.07584412395954132,
0.044408731162548065,
-0.021295519545674324,
-0.022632058709859848,
... |
730,333 | mmengine.fileio.io | put_text | Write text to a given ``filepath`` with 'w' mode.
Note:
``put_text`` should create a directory if the directory of
``filepath`` does not exist.
Args:
obj (str): Data to be written.
filepath (str or Path): Path to write data.
encoding (str, optional): The encoding format... | def put_text(
obj: str,
filepath: Union[str, Path],
backend_args: Optional[dict] = None,
) -> None:
"""Write text to a given ``filepath`` with 'w' mode.
Note:
``put_text`` should create a directory if the directory of
``filepath`` does not exist.
Args:
obj (str): Data t... | (obj: str, filepath: Union[str, pathlib.Path], backend_args: Optional[dict] = None) -> NoneType | [
-0.020292242988944054,
-0.036044053733348846,
-0.04837307333946228,
0.023959515616297722,
0.026090025901794434,
-0.041806910187006,
-0.00028705139993689954,
0.07271678000688553,
0.0301065631210804,
-0.01490484457463026,
0.03127659857273102,
-0.044356536120176315,
-0.0004611377080436796,
-0... |
730,334 | mmengine.config.config | read_base | Context manager to mark the base config.
The pure Python-style configuration file allows you to use the import
syntax. However, it is important to note that you need to import the base
configuration file within the context of ``read_base``, and import other
dependencies outside of it.
You can see ... | def __reduce_ex__(self, proto):
# Override __reduce_ex__ to avoid `self.items` will be
# called by CPython interpreter during pickling. See more details in
# https://github.com/python/cpython/blob/8d61a71f9c81619e34d4a30b625922ebc83c561b/Objects/typeobject.c#L6196 # noqa: E501
if digit_version(platform... | () | [
0.013625187799334526,
-0.03309747576713562,
-0.05269609019160271,
0.0440337173640728,
0.002959643257781863,
-0.05013347044587135,
0.011441548354923725,
-0.030372437089681625,
0.0492672324180603,
-0.049195047467947006,
0.0476069450378418,
0.0563054084777832,
-0.0002253005950478837,
0.005224... |
730,335 | mmengine.fileio.backends.registry_utils | register_backend | Register a backend.
Args:
name (str): The name of the registered backend.
backend (class, optional): The backend class to be registered,
which must be a subclass of :class:`BaseStorageBackend`.
When this method is used as a decorator, backend is None.
Defaults to... | def register_backend(name: str,
backend: Optional[Type[BaseStorageBackend]] = None,
force: bool = False,
prefixes: Union[str, list, tuple, None] = None):
"""Register a backend.
Args:
name (str): The name of the registered backend.
b... | (name: str, backend: Optional[Type[mmengine.fileio.backends.base.BaseStorageBackend]] = None, force: bool = False, prefixes: Union[str, list, tuple, NoneType] = None) | [
-0.01766057312488556,
-0.028717707842588425,
-0.004816520027816296,
0.005841504316776991,
-0.015220566652715206,
0.023057615384459496,
-0.07379887998104095,
0.039693206548690796,
0.04586125165224075,
-0.09331893920898438,
0.051194801926612854,
0.018975818529725075,
0.0026622384320944548,
-... |
730,336 | mmengine.fileio.handlers.registry_utils | register_handler | null | def register_handler(file_formats, **kwargs):
def wrap(cls):
_register_handler(cls(**kwargs), file_formats)
return cls
return wrap
| (file_formats, **kwargs) | [
-0.0037200141232460737,
-0.07878688722848892,
0.046893682330846786,
0.008988242596387863,
-0.0007601300603710115,
0.06622914969921112,
-0.016952943056821823,
0.06973844021558762,
-0.01410594955086708,
0.018458150327205658,
0.03736356273293495,
0.024547792971134186,
0.02243190072476864,
-0.... |
730,338 | mmengine.fileio.io | remove | Remove a file.
Args:
filepath (str, Path): Path to be removed.
backend_args (dict, optional): Arguments to instantiate the
corresponding backend. Defaults to None.
Raises:
FileNotFoundError: If filepath does not exist, an FileNotFoundError
will be raised.
... | def remove(
filepath: Union[str, Path],
backend_args: Optional[dict] = None,
) -> None:
"""Remove a file.
Args:
filepath (str, Path): Path to be removed.
backend_args (dict, optional): Arguments to instantiate the
corresponding backend. Defaults to None.
Raises:
... | (filepath: Union[str, pathlib.Path], backend_args: Optional[dict] = None) -> NoneType | [
-0.01512602623552084,
0.011671483516693115,
-0.02000568062067032,
-0.003298952942714095,
-0.016298586502671242,
-0.0005315982270985842,
-0.019572734832763672,
0.06032371148467064,
0.015865640714764595,
-0.03286776319146156,
0.04816516488790512,
0.025507694110274315,
-0.03117206133902073,
-... |
730,339 | mmengine.utils.misc | requires_executable | A decorator to check if some executable files are installed.
Example:
>>> @requires_executable('ffmpeg')
>>> func(arg1, args):
>>> print(1)
1
| def requires_executable(prerequisites):
"""A decorator to check if some executable files are installed.
Example:
>>> @requires_executable('ffmpeg')
>>> func(arg1, args):
>>> print(1)
1
"""
return check_prerequisites(prerequisites, checker=_check_executable)
| (prerequisites) | [
0.04549675062298775,
-0.01599467545747757,
-0.00875856727361679,
-0.04351401329040527,
0.04698380455374718,
-0.012436368502676487,
0.023562714457511902,
0.059234291315078735,
-0.01862357184290886,
0.019331693649291992,
0.10026988387107849,
0.051161713898181915,
0.08709883689880371,
-0.0338... |
730,340 | mmengine.utils.misc | requires_package | A decorator to check if some python packages are installed.
Example:
>>> @requires_package('numpy')
>>> func(arg1, args):
>>> return numpy.zeros(1)
array([0.])
>>> @requires_package(['numpy', 'non_package'])
>>> func(arg1, args):
>>> return numpy.zero... | def requires_package(prerequisites):
"""A decorator to check if some python packages are installed.
Example:
>>> @requires_package('numpy')
>>> func(arg1, args):
>>> return numpy.zeros(1)
array([0.])
>>> @requires_package(['numpy', 'non_package'])
>>> func(ar... | (prerequisites) | [
0.04869740456342697,
0.03925570100545883,
0.016359567642211914,
-0.01267367135733366,
0.07734934240579605,
0.01726742461323738,
0.016414038836956024,
0.05708599463105202,
0.05661391094326973,
0.013626920990645885,
0.05069468542933464,
0.024130815640091896,
0.04423075169324875,
-0.040962468... |
730,341 | mmengine.fileio.io | rmtree | Recursively delete a directory tree.
Args:
dir_path (str or Path): A directory to be removed.
backend_args (dict, optional): Arguments to instantiate the
corresponding backend. Defaults to None.
Examples:
>>> dir_path = '/path/of/dir'
>>> rmtree(dir_path)
| def rmtree(
dir_path: Union[str, Path],
backend_args: Optional[dict] = None,
) -> None:
"""Recursively delete a directory tree.
Args:
dir_path (str or Path): A directory to be removed.
backend_args (dict, optional): Arguments to instantiate the
corresponding backend. Default... | (dir_path: Union[str, pathlib.Path], backend_args: Optional[dict] = None) -> NoneType | [
0.03092442825436592,
0.014305909164249897,
0.03395412489771843,
-0.07407520711421967,
0.029830869287252426,
0.04098159074783325,
-0.02524150349199772,
0.026532262563705444,
0.016788827255368233,
-0.046754151582717896,
0.054534558206796646,
0.038471780717372894,
-0.005942868534475565,
-0.00... |
730,342 | mmengine.utils.path | scandir | Scan a directory to find the interested files.
Args:
dir_path (str | :obj:`Path`): Path of the directory.
suffix (str | tuple(str), optional): File suffix that we are
interested in. Defaults to None.
recursive (bool, optional): If set to True, recursively scan the
di... | def scandir(dir_path, suffix=None, recursive=False, case_sensitive=True):
"""Scan a directory to find the interested files.
Args:
dir_path (str | :obj:`Path`): Path of the directory.
suffix (str | tuple(str), optional): File suffix that we are
interested in. Defaults to None.
... | (dir_path, suffix=None, recursive=False, case_sensitive=True) | [
0.0029400279745459557,
-0.031551070511341095,
-0.014926295727491379,
-0.02538485638797283,
0.033858783543109894,
0.04072653874754906,
0.036997273564338684,
-0.045415814965963364,
0.07680072635412216,
-0.04596966877579689,
0.004419272765517235,
0.02822796069085598,
0.026141786947846413,
0.0... |
730,343 | mmengine.utils.misc | slice_list | Slice a list into several sub lists by a list of given length.
Args:
in_list (list): The list to be sliced.
lens(int or list): The expected length of each out list.
Returns:
list: A list of sliced list.
| def slice_list(in_list, lens):
"""Slice a list into several sub lists by a list of given length.
Args:
in_list (list): The list to be sliced.
lens(int or list): The expected length of each out list.
Returns:
list: A list of sliced list.
"""
if isinstance(lens, int):
... | (in_list, lens) | [
-0.04854680225253105,
-0.010781287215650082,
-0.08873079717159271,
-0.018656853586435318,
-0.006591025274246931,
0.033415790647268295,
0.02117278426885605,
0.02120821923017502,
-0.027551194652915,
0.00779583677649498,
-0.0410698838531971,
-0.008982929401099682,
-0.03061637654900551,
-0.024... |
730,344 | mmengine.utils.path | symlink | null | def symlink(src, dst, overwrite=True, **kwargs):
if os.path.lexists(dst) and overwrite:
os.remove(dst)
os.symlink(src, dst, **kwargs)
| (src, dst, overwrite=True, **kwargs) | [
-0.015615354292094707,
-0.010123294778168201,
-0.009434635750949383,
0.001841088174842298,
-0.025514835491776466,
0.022295352071523666,
-0.0227429810911417,
0.054369669407606125,
0.03038710169494152,
0.04830946400761604,
0.022295352071523666,
-0.0071061053313314915,
0.06449296325445175,
-0... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.