repo
stringclasses
454 values
file_path
stringlengths
5
201
extension
stringclasses
1 value
content
stringlengths
8
509k
num_lines
int64
3
16.9k
size_bytes
int64
8
511k
changedetection.io
changedetectionio/tests/restock/test_restock.py
.py
#!/usr/bin/env python3 import os import time from flask import url_for from ..util import live_server_setup, wait_for_all_checks, extract_UUID_from_client, wait_for_notification_endpoint_output from changedetectionio.notification import ( default_notification_body, default_notification_format, default_notif...
258
12,340
changedetection.io
changedetectionio/api/Spec.py
.py
import functools from flask import make_response from flask_restful import Resource @functools.cache def _get_spec_yaml(): """Build and cache the merged spec as a YAML string (only serialized once per process).""" import yaml from changedetectionio.api import build_merged_spec_dict return yaml.dump(bu...
22
661
changedetection.io
changedetectionio/api/SystemInfo.py
.py
from flask_restful import Resource from . import auth, validate_openapi_request class SystemInfo(Resource): def __init__(self, **kwargs): # datastore is a black box dependency self.datastore = kwargs['datastore'] self.update_q = kwargs['update_q'] @auth.check_token @validate_opena...
40
1,617
changedetection.io
changedetectionio/api/Watch.py
.py
import os import re import threading from changedetectionio.validate_url import is_safe_valid_url from changedetectionio.favicon_utils import get_favicon_mime_type from . import auth from changedetectionio import queuedWatchMetaData, strtobool from changedetectionio import worker_pool from flask import request, make_...
620
28,493
changedetection.io
changedetectionio/api/Search.py
.py
from flask_restful import Resource, abort from flask import request from . import auth, validate_openapi_request class Search(Resource): def __init__(self, **kwargs): # datastore is a black box dependency self.datastore = kwargs['datastore'] @auth.check_token @validate_openapi_request('sea...
39
1,491
changedetection.io
changedetectionio/api/Notifications.py
.py
from flask_restful import Resource, abort from flask import request from . import auth, validate_openapi_request class Notifications(Resource): def __init__(self, **kwargs): # datastore is a black box dependency self.datastore = kwargs['datastore'] @auth.check_token @validate_openapi_reque...
103
3,558
changedetection.io
changedetectionio/api/__init__.py
.py
import functools from flask import request, abort from loguru import logger @functools.cache def build_merged_spec_dict(): """ Load the base OpenAPI spec and merge in any per-processor api.yaml extensions. Each processor can provide an api.yaml file alongside its __init__.py that defines additional sc...
234
10,305
changedetection.io
changedetectionio/api/auth.py
.py
from flask import request, make_response, jsonify from functools import wraps # Simple API auth key comparison # @todo - Maybe short lived token in the future? def check_token(f): @wraps(f) def decorated(*args, **kwargs): datastore = args[0].datastore config_api_token_enabled = datastore.dat...
26
862
changedetection.io
changedetectionio/api/Tags.py
.py
from changedetectionio import queuedWatchMetaData from changedetectionio import worker_pool from flask_restful import abort, Resource from loguru import logger import threading from flask import request from . import auth from . import validate_openapi_request, strip_internal_api_fields class Tag(Resource): def...
212
9,407
changedetection.io
changedetectionio/api/Import.py
.py
from changedetectionio.strtobool import strtobool from flask_restful import abort, Resource from flask import request from functools import wraps from . import auth, validate_openapi_request from ..validate_url import is_safe_valid_url import json # Number of URLs above which import switches to background processing I...
229
8,921
changedetection.io
changedetectionio/realtime/__init__.py
.py
""" Socket.IO realtime updates module for changedetection.io """
3
64
changedetection.io
changedetectionio/realtime/socket_server.py
.py
from flask_socketio import SocketIO from flask_babel import gettext import time import os from loguru import logger from blinker import signal from changedetectionio import strtobool class SignalHandler: """A standalone class to receive signals""" def __init__(self, socketio_instance, datastore): s...
394
17,856
changedetection.io
changedetectionio/realtime/events.py
.py
from flask_socketio import emit from loguru import logger from blinker import signal def register_watch_operation_handlers(socketio, datastore): """Register Socket.IO event handlers for watch operations""" @socketio.on('watch_operation') def handle_watch_operation(data): """Handle watch operation...
61
2,584
changedetection.io
changedetectionio/blueprint/browser_steps/__init__.py
.py
# HORRIBLE HACK BUT WORKS :-) PR anyone? # # Why? # `browsersteps_playwright_browser_interface.chromium.connect_over_cdp()` will only run once without async() # - this flask app is not async() # - A single timeout/keepalive which applies to the session made at .connect_over_cdp() # # So it means that we must unfortuna...
436
18,340
changedetection.io
changedetectionio/blueprint/settings/__init__.py
.py
import os from copy import deepcopy from datetime import datetime, timedelta from zoneinfo import ZoneInfo, available_timezones import secrets import time import flask_login from flask import Blueprint, render_template, request, redirect, url_for, flash from flask_babel import gettext from changedetectionio.store impo...
324
17,096
changedetection.io
changedetectionio/blueprint/settings/llm.py
.py
import json import logging import os import re from flask import Blueprint, jsonify, redirect, url_for, flash from flask_babel import gettext from loguru import logger from changedetectionio.store import ChangeDetectionStore from changedetectionio.auth_decorator import login_optionally_required class _LiteLLMWarnin...
272
13,727
changedetection.io
changedetectionio/blueprint/settings/notifications/__init__.py
.py
""" Notification settings — child blueprint of /settings. Registered by the parent settings blueprint at url_prefix='/notifications', so the URLs land at /settings/notifications/<backend>. Today the only backend is apprise; future backends (simple_email, raw webhooks, etc.) slot in as sibling routes here without re-sh...
77
3,356
changedetection.io
changedetectionio/blueprint/watchlist/filters.py
.py
"""Watch-list filtering — the single source of truth for "which watches match the current view". Shared by the watch list (the rendered table + the /uuids endpoint) and by the bulk actions in the ui blueprint (mark-all-viewed, recheck-all) so a filtered view and any action taken on it always operate on the SAME set. K...
105
4,370
changedetection.io
changedetectionio/blueprint/watchlist/__init__.py
.py
import os import time from flask import Blueprint, request, make_response, render_template, redirect, url_for, flash, session from flask_paginate import Pagination, get_page_parameter from flask_babel import gettext as _ from changedetectionio import forms from changedetectionio import processors from changedetection...
185
8,956
changedetection.io
changedetectionio/blueprint/rss/_util.py
.py
""" Utility functions for RSS feed generation. """ from changedetectionio.notification.handler import process_notification from changedetectionio.notification_service import NotificationContextData, _check_cascading_vars from loguru import logger import datetime import pytz import re BAD_CHARS_REGEX = r'[\x00-\x08\x...
157
5,094
changedetection.io
changedetectionio/blueprint/rss/__init__.py
.py
from copy import deepcopy from loguru import logger from changedetectionio.model import USE_SYSTEM_DEFAULT_NOTIFICATION_FORMAT_FOR_WATCH from changedetectionio.notification import valid_notification_formats RSS_CONTENT_FORMAT_DEFAULT = 'text' # Some stuff not related RSS_FORMAT_TYPES = deepcopy(valid_notification_fo...
28
1,284
changedetection.io
changedetectionio/blueprint/rss/single_watch.py
.py
def construct_single_watch_routes(rss_blueprint, datastore): """ Construct RSS feed routes for single watches. Args: rss_blueprint: The Flask blueprint to add routes to datastore: The ChangeDetectionStore instance """ @rss_blueprint.route("/watch/<uuid_str:uuid>", methods=['GET']...
116
5,149
changedetection.io
changedetectionio/blueprint/rss/main_feed.py
.py
from flask import make_response, request, url_for, redirect def construct_main_feed_routes(rss_blueprint, datastore): """ Construct the main RSS feed routes. Args: rss_blueprint: The Flask blueprint to add routes to datastore: The ChangeDetectionStore instance """ # Some RSS rea...
106
4,853
changedetection.io
changedetectionio/blueprint/rss/tag.py
.py
def construct_tag_routes(rss_blueprint, datastore): """ Construct RSS feed routes for tags. Args: rss_blueprint: The Flask blueprint to add routes to datastore: The ChangeDetectionStore instance """ @rss_blueprint.route("/tag/<uuid_str:tag_uuid>", methods=['GET']) def rss_tag_f...
96
4,310
changedetection.io
changedetectionio/blueprint/rss/blueprint.py
.py
from changedetectionio.store import ChangeDetectionStore from flask import Blueprint from . import tag as tag_routes from . import main_feed from . import single_watch def construct_blueprint(datastore: ChangeDetectionStore): """ Construct and configure the RSS blueprint with all routes. Args: d...
26
733
changedetection.io
changedetectionio/blueprint/tags/__init__.py
.py
import threading from flask import Blueprint, request, render_template, flash, url_for, redirect from flask_babel import gettext from loguru import logger from changedetectionio.store import ChangeDetectionStore from changedetectionio.flask_app import login_optionally_required from changedetectionio.llm.evaluator impo...
268
12,230
changedetection.io
changedetectionio/blueprint/tags/form.py
.py
from wtforms import ( Form, StringField, SubmitField, TextAreaField, validators, ) from wtforms.fields.simple import BooleanField from flask_babel import lazy_gettext as _l from changedetectionio.processors.restock_diff.forms import processor_settings_form as restock_settings_form from changedetect...
33
1,651
changedetection.io
changedetectionio/blueprint/price_data_follower/__init__.py
.py
from changedetectionio.strtobool import strtobool from flask import Blueprint, flash, redirect, url_for from flask_login import login_required from changedetectionio.store import ChangeDetectionStore from changedetectionio import queuedWatchMetaData from changedetectionio import worker_pool from queue import PriorityQ...
38
1,505
changedetection.io
changedetectionio/blueprint/add_watch_ui/__init__.py
.py
from flask import Blueprint, render_template, request, jsonify, make_response from loguru import logger from changedetectionio import forms from changedetectionio.auth_decorator import login_optionally_required from changedetectionio.store import ChangeDetectionStore def construct_blueprint(datastore: ChangeDetectio...
123
6,275
changedetection.io
changedetectionio/blueprint/check_proxies/__init__.py
.py
import importlib from concurrent.futures import ThreadPoolExecutor from changedetectionio.processors.text_json_diff.processor import FilterNotFoundInResponse from changedetectionio.store import ChangeDetectionStore from functools import wraps from flask import Blueprint from flask_login import login_required STATUS...
126
5,124
changedetection.io
changedetectionio/blueprint/backups/restore.py
.py
import io import json import os import re import shutil import tempfile import threading import zipfile from flask import Blueprint, render_template, flash, url_for, redirect, request from flask_babel import gettext, lazy_gettext as _l from wtforms import Form, BooleanField, SubmitField from flask_wtf.file import File...
249
11,330
changedetection.io
changedetectionio/blueprint/backups/__init__.py
.py
import datetime import glob import threading from flask import Blueprint, render_template, send_from_directory, flash, url_for, redirect, abort from flask_babel import gettext import os from changedetectionio.store import ChangeDetectionStore from changedetectionio.flask_app import login_optionally_required from logu...
193
7,955
changedetection.io
changedetectionio/blueprint/ui/diff.py
.py
from flask import Blueprint, request, redirect, url_for, flash, render_template, make_response, send_from_directory from flask_babel import gettext import re import importlib from loguru import logger from markupsafe import Markup from changedetectionio.diff import ( REMOVED_STYLE, ADDED_STYLE, REMOVED_INNER_STYL...
612
26,684
changedetection.io
changedetectionio/blueprint/ui/edit.py
.py
from copy import deepcopy import os import importlib.resources from flask import Blueprint, request, redirect, url_for, flash, render_template, abort from flask_babel import gettext from loguru import logger from jinja2 import Environment, FileSystemLoader from changedetectionio.store import ChangeDetectionStore from ...
487
24,998
changedetection.io
changedetectionio/blueprint/ui/preview.py
.py
from flask import Blueprint, request, url_for, flash, render_template, redirect from flask_babel import gettext import time from loguru import logger from changedetectionio.store import ChangeDetectionStore from changedetectionio.auth_decorator import login_optionally_required from changedetectionio import html_tools ...
189
8,903
changedetection.io
changedetectionio/blueprint/ui/__init__.py
.py
import time import threading from flask import Blueprint, request, redirect, url_for, flash, render_template, session, current_app from flask_babel import gettext from loguru import logger from changedetectionio.store import ChangeDetectionStore from changedetectionio.blueprint.ui.edit import construct_blueprint as co...
475
22,439
changedetection.io
changedetectionio/blueprint/ui/views.py
.py
import time from flask import Blueprint, request, redirect, url_for, flash from flask_babel import gettext from loguru import logger from changedetectionio.store import ChangeDetectionStore from changedetectionio.auth_decorator import login_optionally_required from changedetectionio import worker_pool def run_preload...
131
6,334
changedetection.io
changedetectionio/blueprint/ui/notification.py
.py
from flask import Blueprint, request, make_response import random from loguru import logger from changedetectionio.store import ChangeDetectionStore from changedetectionio.auth_decorator import login_optionally_required def construct_blueprint(datastore: ChangeDetectionStore): notification_blueprint = Blueprint('...
132
7,439
changedetection.io
changedetectionio/blueprint/ui/queue.py
.py
""" Queue inspection UI. Surfaces what's currently being processed and what's waiting so users can make sense of the "Queued size: N" indicator (see issue #4077). Priority conventions (see uses of PrioritizedItem across the codebase): 1 - immediate / manual recheck 5 - clone follow-up >100 - scheduler-...
173
6,193
changedetection.io
changedetectionio/blueprint/imports/__init__.py
.py
from flask import Blueprint, request, redirect, url_for, flash, render_template from loguru import logger from changedetectionio.store import ChangeDetectionStore from changedetectionio.auth_decorator import login_optionally_required def construct_blueprint(datastore: ChangeDetectionStore, update_q, queuedWatchMetaDa...
86
4,424
changedetection.io
changedetectionio/blueprint/imports/importer.py
.py
from abc import abstractmethod import time from wtforms import ValidationError from loguru import logger from flask_babel import gettext from changedetectionio.forms import validate_url class Importer(): remaining_data = [] new_uuids = [] good = 0 def __init__(self): self.new_uuids = [] ...
296
11,594
linux-insides
scripts/check_code_snippets.py
.py
#!/usr/bin/env python3 """ A script that takes the lines of the Linux kernel source code from the comments in the markdown files that are attached to the code and checks their validity. """ import os import re import sys from typing import Optional, Tuple import requests exclude_dirs = ["./.github"] def __split_url_...
99
2,515
linux-insides
scripts/latex.py
.py
#!/usr/bin/env python3 """ A script for converting markdown files in each of the subdirectories into a unified PDF typeset in LaTeX. Requires TeX Live, pandoc templates and pdfunite. Not necessary if you just want to read the PDF, only if you're compiling it yourself. """ import shutil import subprocess from pathlib im...
37
1,248
CheatSheetSeries
scripts/Generate_CheatSheets_TOC.py
.py
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Python3 script to generate the summary markdown page that is used by GitBook to generate the offline website. The summary markdown page is named "TOC.md" and is generated in the same location that the script in order to be moved later by the caller script. """ import o...
36
1,554
CheatSheetSeries
scripts/Update_CheatSheets_Index.py
.py
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Python3 script to generate the index markdown page that reference all cheat sheets grouped by the first letter. The index markdown page is located on the root folder and is named "Index.md". """ import os from collections import OrderedDict # Define utility functions ...
90
3,212
CheatSheetSeries
scripts/Generate_RSS_Feed.py
.py
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Python3 script to generate an RSS feed XML file based on merged pull requests: See https://github.com/OWASP/CheatSheetSeries/issues/186 Do not require to have a local copy of the GitHub repository. Dependencies: pip install requests feedgen """ import sys import json fr...
66
2,992
CheatSheetSeries
scripts/Generate_Technologies_JSON.py
.py
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Python3 script to generate a JSON structure with the list of all cheatsheets classified by the technology used in the samples of code provided using the alphabetical index as source: https://raw.githubusercontent.com/OWASP/CheatSheetSeries/master/Index.md Do not requir...
46
1,694
CheatSheetSeries
scripts/Identify_Old_Issue_And_PR.py
.py
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Python3 script to identify any Issue or PR meeting the following criteria: - For Issue (Comments of the issue do not contain the info when a PR is referenced): - Has assignees - Has not the label HELP_WANTED or INTERNAL - Has not been updated since more than...
98
4,131
mmdetection
setup.py
.py
#!/usr/bin/env python # Copyright (c) OpenMMLab. All rights reserved. import os import os.path as osp import platform import shutil import sys import warnings from setuptools import find_packages, setup import torch from torch.utils.cpp_extension import (BuildExtension, CppExtension, ...
225
8,072
mmdetection
demo/video_gpuaccel_demo.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import argparse from typing import Tuple import cv2 import mmcv import numpy as np import torch import torch.nn as nn from mmcv.transforms import Compose from mmengine.utils import track_iter_progress from mmdet.apis import init_detector from mmdet.registry import VISUA...
145
4,834
mmdetection
demo/image_demo.py
.py
# Copyright (c) OpenMMLab. All rights reserved. """Image Demo. This script adopts a new infenence class, currently supports image path, np.array and folder input formats, and will support video and webcam in the future. Example: Save visualizations and predictions results:: python demo/image_demo.py demo...
193
6,753
mmdetection
demo/demo_multi_model.py
.py
# Copyright (c) OpenMMLab. All rights reserved. """Support for multi-model fusion, and currently only the Weighted Box Fusion (WBF) fusion method is supported. References: https://github.com/ZFTurbo/Weighted-Boxes-Fusion Example: python demo/demo_multi_model.py demo/demo.jpg \ ./configs/faster_rcnn/fas...
213
6,959
mmdetection
demo/webcam_demo.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import argparse import cv2 import mmcv import torch from mmdet.apis import inference_detector, init_detector from mmdet.registry import VISUALIZERS def parse_args(): parser = argparse.ArgumentParser(description='MMDetection webcam demo') parser.add_argument('c...
66
1,930
mmdetection
demo/large_image_demo.py
.py
# Copyright (c) OpenMMLab. All rights reserved. """Perform MMDET inference on large images (as satellite imagery) as: ```shell wget -P checkpoint https://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r101_fpn_2x_coco/faster_rcnn_r101_fpn_2x_coco_bbox_mAP-0.398_20200504_210455-1d2dac9c.pth # noqa: E50...
283
10,196
mmdetection
demo/mot_demo.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import os import os.path as osp import tempfile from argparse import ArgumentParser import mmcv import mmengine from mmengine.registry import init_default_scope from mmdet.apis import inference_mot, init_track_model from mmdet.registry import VISUALIZERS IMG_EXTENSIONS...
131
4,014
mmdetection
demo/video_demo.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import argparse import cv2 import mmcv from mmcv.transforms import Compose from mmengine.utils import track_iter_progress from mmdet.apis import inference_detector, init_detector from mmdet.registry import VISUALIZERS def parse_args(): parser = argparse.ArgumentPa...
85
2,807
mmdetection
demo/create_result_gif.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import argparse import os import os.path as osp import matplotlib.patches as mpatches import matplotlib.pyplot as plt import mmcv import numpy as np from mmengine.utils import scandir try: import imageio except ImportError: imageio = None # TODO verify after r...
166
5,019
mmdetection
mmdet/__init__.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import mmcv import mmengine from mmengine.utils import digit_version from .version import __version__, version_info mmcv_minimum_version = '2.0.0rc4' mmcv_maximum_version = '2.2.0' mmcv_version = digit_version(mmcv.__version__) mmengine_minimum_version = '0.7.1' mmengi...
28
1,042
mmdetection
mmdet/registry.py
.py
# Copyright (c) OpenMMLab. All rights reserved. """MMDetection provides 17 registry nodes to support using modules across projects. Each node is a child of the root registry in MMEngine. More details can be found at https://mmengine.readthedocs.io/en/latest/tutorials/registry.html. """ from mmengine.registry import D...
122
4,875
mmdetection
mmdet/version.py
.py
# Copyright (c) OpenMMLab. All rights reserved. __version__ = '3.3.0' short_version = __version__ def parse_version_info(version_str): """Parse a version string into a tuple. Args: version_str (str): The version string. Returns: tuple[int | str]: The version info, e.g., "1.3.0" is parsed...
28
795
mmdetection
mmdet/testing/_fast_stop_training_hook.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from mmengine.hooks import Hook from mmdet.registry import HOOKS @HOOKS.register_module() class FastStopTrainingHook(Hook): """Set runner's epoch information to the model.""" def __init__(self, by_epoch, save_ckpt=False, stop_iter_or_epoch=5): self.by_...
28
964
mmdetection
mmdet/testing/_utils.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import copy from os.path import dirname, exists, join import numpy as np import torch from mmengine.config import Config from mmengine.dataset import pseudo_collate from mmengine.structures import InstanceData, PixelData from mmdet.utils.util_random import ensure_rng fr...
470
16,628
mmdetection
mmdet/testing/__init__.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from ._fast_stop_training_hook import FastStopTrainingHook # noqa: F401,F403 from ._utils import (demo_mm_inputs, demo_mm_proposals, demo_mm_sampling_results, demo_track_inputs, get_detector_cfg, get_roi_head_cfg, random_boxes, ...
13
571
mmdetection
mmdet/apis/inference.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import copy import warnings from pathlib import Path from typing import Optional, Sequence, Union import numpy as np import torch import torch.nn as nn from mmcv.ops import RoIPool from mmcv.transforms import Compose from mmengine.config import Config from mmengine.datas...
373
13,260
mmdetection
mmdet/apis/det_inferencer.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import copy import os.path as osp import warnings from typing import Dict, Iterable, List, Optional, Sequence, Tuple, Union import mmcv import mmengine import numpy as np import torch.nn as nn from mmcv.transforms import LoadImageFromFile from mmengine.dataset import Com...
653
26,833
mmdetection
mmdet/apis/__init__.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from .det_inferencer import DetInferencer from .inference import (async_inference_detector, inference_detector, inference_mot, init_detector, init_track_model) __all__ = [ 'init_detector', 'async_inference_detector', 'inference_detector', ...
10
375
mmdetection
mmdet/engine/hooks/visualization_hook.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import os.path as osp import warnings from typing import Optional, Sequence import mmcv import numpy as np from mmengine.fileio import get from mmengine.hooks import Hook from mmengine.runner import Runner from mmengine.utils import mkdir_or_exist from mmengine.visualiza...
516
21,995
mmdetection
mmdet/engine/hooks/num_class_check_hook.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from mmcv.cnn import VGG from mmengine.hooks import Hook from mmengine.runner import Runner from mmdet.registry import HOOKS @HOOKS.register_module() class NumClassCheckHook(Hook): """Check whether the `num_classes` in head matches the length of `classes` in `d...
69
2,813
mmdetection
mmdet/engine/hooks/utils.py
.py
# Copyright (c) OpenMMLab. All rights reserved. def trigger_visualization_hook(cfg, args): default_hooks = cfg.default_hooks if 'visualization' in default_hooks: visualization_hook = default_hooks['visualization'] # Turn on visualization visualization_hook['draw'] = True if args....
20
737
mmdetection
mmdet/engine/hooks/memory_profiler_hook.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from typing import Optional, Sequence from mmengine.hooks import Hook from mmengine.runner import Runner from mmdet.registry import HOOKS from mmdet.structures import DetDataSample @HOOKS.register_module() class MemoryProfilerHook(Hook): """Memory profiler hook re...
122
4,650
mmdetection
mmdet/engine/hooks/pipeline_switch_hook.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from mmcv.transforms import Compose from mmengine.hooks import Hook from mmdet.registry import HOOKS @HOOKS.register_module() class PipelineSwitchHook(Hook): """Switch data pipeline at switch_epoch. Args: switch_epoch (int): switch pipeline at this epo...
44
1,707
mmdetection
mmdet/engine/hooks/sync_norm_hook.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from collections import OrderedDict from mmengine.dist import get_dist_info from mmengine.hooks import Hook from torch import nn from mmdet.registry import HOOKS from mmdet.utils import all_reduce_dict def get_norm_states(module: nn.Module) -> OrderedDict: """Get ...
38
1,247
mmdetection
mmdet/engine/hooks/__init__.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from .checkloss_hook import CheckInvalidLossHook from .mean_teacher_hook import MeanTeacherHook from .memory_profiler_hook import MemoryProfilerHook from .num_class_check_hook import NumClassCheckHook from .pipeline_switch_hook import PipelineSwitchHook from .set_epoch_in...
22
979
mmdetection
mmdet/engine/hooks/set_epoch_info_hook.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from mmengine.hooks import Hook from mmengine.model.wrappers import is_model_wrapper from mmdet.registry import HOOKS @HOOKS.register_module() class SetEpochInfoHook(Hook): """Set runner's epoch information to the model.""" def before_train_epoch(self, runner)...
18
480
mmdetection
mmdet/engine/hooks/checkloss_hook.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from typing import Optional import torch from mmengine.hooks import Hook from mmengine.runner import Runner from mmdet.registry import HOOKS @HOOKS.register_module() class CheckInvalidLossHook(Hook): """Check invalid loss hook. This hook will regularly check ...
43
1,406
mmdetection
mmdet/engine/hooks/yolox_mode_switch_hook.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from typing import Sequence from mmengine.hooks import Hook from mmengine.model import is_model_wrapper from mmdet.registry import HOOKS @HOOKS.register_module() class YOLOXModeSwitchHook(Hook): """Switch the mode of YOLOX during training. This hook turns off...
67
2,740
mmdetection
mmdet/engine/hooks/mean_teacher_hook.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from typing import Optional import torch.nn as nn from mmengine.hooks import Hook from mmengine.model import is_model_wrapper from mmengine.runner import Runner from mmdet.registry import HOOKS @HOOKS.register_module() class MeanTeacherHook(Hook): """Mean Teacher ...
88
3,537
mmdetection
mmdet/engine/optimizers/layer_decay_optimizer_constructor.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import json from typing import List import torch.nn as nn from mmengine.dist import get_dist_info from mmengine.logging import MMLogger from mmengine.optim import DefaultOptimWrapperConstructor from mmdet.registry import OPTIM_WRAPPER_CONSTRUCTORS def get_layer_id_for...
159
6,020
mmdetection
mmdet/engine/optimizers/__init__.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from .layer_decay_optimizer_constructor import \ LearningRateDecayOptimizerConstructor __all__ = ['LearningRateDecayOptimizerConstructor']
6
192
mmdetection
mmdet/engine/schedulers/quadratic_warmup.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from mmengine.optim.scheduler.lr_scheduler import LRSchedulerMixin from mmengine.optim.scheduler.momentum_scheduler import MomentumSchedulerMixin from mmengine.optim.scheduler.param_scheduler import INF, _ParamScheduler from torch.optim import Optimizer from mmdet.regist...
132
5,176
mmdetection
mmdet/engine/schedulers/__init__.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from .quadratic_warmup import (QuadraticWarmupLR, QuadraticWarmupMomentum, QuadraticWarmupParamScheduler) __all__ = [ 'QuadraticWarmupParamScheduler', 'QuadraticWarmupMomentum', 'QuadraticWarmupLR' ]
9
288
mmdetection
mmdet/engine/runner/__init__.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from .loops import TeacherStudentValLoop __all__ = ['TeacherStudentValLoop']
5
126
mmdetection
mmdet/engine/runner/loops.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from mmengine.model import is_model_wrapper from mmengine.runner import ValLoop from mmdet.registry import LOOPS @LOOPS.register_module() class TeacherStudentValLoop(ValLoop): """Loop for validation of model teacher and student.""" def run(self): """La...
39
1,406
mmdetection
mmdet/visualization/palette.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from typing import List, Tuple, Union import mmcv import numpy as np from mmengine.utils import is_str def palette_val(palette: List[tuple]) -> List[tuple]: """Convert palette to matplotlib palette. Args: palette (List[tuple]): A list of color tuples. ...
109
3,609
mmdetection
mmdet/visualization/__init__.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from .local_visualizer import DetLocalVisualizer, TrackLocalVisualizer from .palette import get_palette, jitter_color, palette_val __all__ = [ 'palette_val', 'get_palette', 'DetLocalVisualizer', 'jitter_color', 'TrackLocalVisualizer' ]
9
293
mmdetection
mmdet/visualization/local_visualizer.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from typing import Dict, List, Optional, Tuple, Union import cv2 import mmcv import numpy as np try: import seaborn as sns except ImportError: sns = None import torch from mmengine.dist import master_only from mmengine.structures import InstanceData, PixelData f...
700
29,077
mmdetection
mmdet/datasets/coco_caption.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from pathlib import Path from typing import List import mmengine from mmengine.dataset import BaseDataset from mmengine.fileio import get_file_backend from mmdet.registry import DATASETS @DATASETS.register_module() class CocoCaptionDataset(BaseDataset): """COCO201...
33
923
mmdetection
mmdet/datasets/objects365.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import copy import os.path as osp from typing import List from mmengine.fileio import get_local_path from mmdet.registry import DATASETS from .api_wrappers import COCO from .coco import CocoDataset # images exist in annotations but not in image folder. objv2_ignore_lis...
285
14,792
mmdetection
mmdet/datasets/isaid.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from mmdet.registry import DATASETS from .coco import CocoDataset @DATASETS.register_module() class iSAIDDataset(CocoDataset): """Dataset for iSAID instance segmentation. iSAID: A Large-scale Dataset for Instance Segmentation in Aerial Images. For more...
26
1,018
mmdetection
mmdet/datasets/base_det_dataset.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import os.path as osp from typing import List, Optional from mmengine.dataset import BaseDataset from mmengine.fileio import load from mmengine.utils import is_abs from ..registry import DATASETS @DATASETS.register_module() class BaseDetDataset(BaseDataset): """Ba...
132
5,377
mmdetection
mmdet/datasets/utils.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from mmcv.transforms import LoadImageFromFile from mmdet.datasets.transforms import LoadAnnotations, LoadPanopticAnnotations from mmdet.registry import TRANSFORMS def get_loading_pipeline(pipeline): """Only keep loading image and annotations related configuration....
49
1,925
mmdetection
mmdet/datasets/reid_dataset.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import copy import os.path as osp from collections import defaultdict from typing import Any, Dict, List import numpy as np from mmengine.dataset import BaseDataset from mmengine.utils import check_file_exist from mmdet.registry import DATASETS @DATASETS.register_modu...
128
5,002
mmdetection
mmdet/datasets/deepfashion.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from mmdet.registry import DATASETS from .coco import CocoDataset @DATASETS.register_module() class DeepFashionDataset(CocoDataset): """Dataset for DeepFashion.""" METAINFO = { 'classes': ('top', 'skirt', 'leggings', 'dress', 'outer', 'pants', ...
20
819
mmdetection
mmdet/datasets/dataset_wrappers.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import collections import copy from typing import List, Sequence, Union from mmengine.dataset import BaseDataset from mmengine.dataset import ConcatDataset as MMENGINE_ConcatDataset from mmengine.dataset import force_full_init from mmdet.registry import DATASETS, TRANSF...
261
10,190
mmdetection
mmdet/datasets/refcoco.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import collections import os.path as osp import random from typing import Dict, List import mmengine from mmengine.dataset import BaseDataset from mmdet.registry import DATASETS @DATASETS.register_module() class RefCocoDataset(BaseDataset): """RefCOCO dataset. ...
164
5,585
mmdetection
mmdet/datasets/odvg.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import json import os.path as osp from typing import List, Optional from mmengine.fileio import get_local_path from mmdet.registry import DATASETS from .base_det_dataset import BaseDetDataset @DATASETS.register_module() class ODVGDataset(BaseDetDataset): """object...
107
4,378
mmdetection
mmdet/datasets/voc.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from mmdet.registry import DATASETS from .xml_style import XMLDataset @DATASETS.register_module() class VOCDataset(XMLDataset): """Dataset for PASCAL VOC.""" METAINFO = { 'classes': ('aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car'...
32
1,305
mmdetection
mmdet/datasets/__init__.py
.py
# Copyright (c) OpenMMLab. All rights reserved. from .ade20k import (ADE20KInstanceDataset, ADE20KPanopticDataset, ADE20KSegDataset) from .base_det_dataset import BaseDetDataset from .base_semseg_dataset import BaseSegDataset from .base_video_dataset import BaseVideoDataset from .cityscapes import ...
54
2,656
mmdetection
mmdet/datasets/dod.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import os.path as osp from typing import List, Optional import numpy as np from mmdet.registry import DATASETS from .base_det_dataset import BaseDetDataset try: from d_cube import D3 except ImportError: D3 = None from .api_wrappers import COCO @DATASETS.regis...
79
2,715
mmdetection
mmdet/datasets/flickr30k.py
.py
# Copyright (c) OpenMMLab. All rights reserved. import os.path as osp from typing import List from pycocotools.coco import COCO from mmdet.registry import DATASETS from .base_det_dataset import BaseDetDataset def convert_phrase_ids(phrase_ids: list) -> list: unique_elements = sorted(set(phrase_ids)) element...
82
2,612