instruction
stringclasses
100 values
code
stringlengths
78
193k
response
stringlengths
259
170k
file
stringlengths
59
203
Help me write clear docstrings
import torch import torch.nn.functional as F from annotator.mmpkg.mmcv.cnn import ConvModule, Scale from torch import nn from annotator.mmpkg.mmseg.core import add_prefix from ..builder import HEADS from ..utils import SelfAttentionBlock as _SelfAttentionBlock from .decode_head import BaseDecodeHead class PAM(_SelfA...
--- +++ @@ -10,6 +10,12 @@ class PAM(_SelfAttentionBlock): + """Position Attention Module (PAM) + + Args: + in_channels (int): Input channels of key/query feature. + channels (int): Output channels of key/query transform. + """ def __init__(self, in_channels, channels): super(...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/mmpkg/mmseg/models/decode_heads/da_head.py
Add return value explanations in docstrings
# Copyright (c) OpenMMLab. All rights reserved. import warnings import torch from torch.nn import GroupNorm, LayerNorm from annotator.mmpkg.mmcv.utils import _BatchNorm, _InstanceNorm, build_from_cfg, is_list_of from annotator.mmpkg.mmcv.utils.ext_loader import check_ops_exist from .builder import OPTIMIZER_BUILDERS,...
--- +++ @@ -11,6 +11,86 @@ @OPTIMIZER_BUILDERS.register_module() class DefaultOptimizerConstructor: + """Default constructor for optimizers. + + By default each parameter share the same optimizer settings, and we + provide an argument ``paramwise_cfg`` to specify parameter-wise settings. + It is a dict a...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/mmpkg/mmcv/runner/optimizer/default_constructor.py
Improve documentation using docstrings
# Copyright (c) OpenMMLab. All rights reserved. import copy from collections import defaultdict from itertools import chain from torch.nn.utils import clip_grad from annotator.mmpkg.mmcv.utils import TORCH_VERSION, _BatchNorm, digit_version from ..dist_utils import allreduce_grads from ..fp16_utils import LossScaler,...
--- +++ @@ -44,6 +44,22 @@ @HOOKS.register_module() class GradientCumulativeOptimizerHook(OptimizerHook): + """Optimizer Hook implements multi-iters gradient cumulating. + + Args: + cumulative_iters (int, optional): Num of gradient cumulative iters. + The optimizer will step every `cumulative...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/mmpkg/mmcv/runner/hooks/optimizer.py
Add missing documentation to my Python functions
# Modified from https://github.com/facebookresearch/detectron2/tree/master/projects/PointRend/point_head/point_head.py # noqa import torch import torch.nn as nn try: from mmcv.cnn import ConvModule, normal_init from mmcv.ops import point_sample except ImportError: from annotator.mmpkg.mmcv.cnn import Co...
--- +++ @@ -17,12 +17,50 @@ def calculate_uncertainty(seg_logits): + """Estimate uncertainty based on seg logits. + + For each location of the prediction ``seg_logits`` we estimate + uncertainty as the difference between top first and top second + predicted logits. + + Args: + seg_logits (Tens...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/mmpkg/mmseg/models/decode_heads/point_head.py
Generate docstrings for script automation
from abc import ABCMeta, abstractmethod from .decode_head import BaseDecodeHead class BaseCascadeDecodeHead(BaseDecodeHead, metaclass=ABCMeta): def __init__(self, *args, **kwargs): super(BaseCascadeDecodeHead, self).__init__(*args, **kwargs) @abstractmethod def forward(self, inputs, prev_output...
--- +++ @@ -4,20 +4,54 @@ class BaseCascadeDecodeHead(BaseDecodeHead, metaclass=ABCMeta): + """Base class for cascade decode head used in + :class:`CascadeEncoderDecoder.""" def __init__(self, *args, **kwargs): super(BaseCascadeDecodeHead, self).__init__(*args, **kwargs) @abstractmethod...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/mmpkg/mmseg/models/decode_heads/cascade_decode_head.py
Add docstrings that explain inputs and outputs
import torch import torch.nn as nn from annotator.mmpkg.mmcv.cnn import ConvModule from annotator.mmpkg.mmseg.ops import resize from ..builder import HEADS from .decode_head import BaseDecodeHead class ASPPModule(nn.ModuleList): def __init__(self, dilations, in_channels, channels, conv_cfg, norm_cfg, ...
--- +++ @@ -8,6 +8,16 @@ class ASPPModule(nn.ModuleList): + """Atrous Spatial Pyramid Pooling (ASPP) Module. + + Args: + dilations (tuple[int]): Dilation rate of each layer. + in_channels (int): Input channels. + channels (int): Channels after modules, before conv_seg. + conv_cfg (...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/mmpkg/mmseg/models/decode_heads/aspp_head.py
Add docstrings to my Python code
import torch import torch.nn as nn import torch.nn.functional as F from annotator.mmpkg.mmcv.cnn import ConvModule, build_norm_layer from annotator.mmpkg.mmseg.ops import Encoding, resize from ..builder import HEADS, build_loss from .decode_head import BaseDecodeHead class EncModule(nn.Module): def __init__(sel...
--- +++ @@ -9,6 +9,15 @@ class EncModule(nn.Module): + """Encoding Module used in EncNet. + + Args: + in_channels (int): Input channels. + num_codes (int): Number of code words. + conv_cfg (dict|None): Config of conv layers. + norm_cfg (dict|None): Config of norm layers. + a...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/mmpkg/mmseg/models/decode_heads/enc_head.py
Add clean documentation to messy code
import torch import torch.nn as nn import torch.nn.functional as F from annotator.mmpkg.mmcv.cnn import ConvModule from annotator.mmpkg.mmseg.ops import resize from ..builder import HEADS from ..utils import SelfAttentionBlock as _SelfAttentionBlock from .cascade_decode_head import BaseCascadeDecodeHead class Spatia...
--- +++ @@ -10,12 +10,18 @@ class SpatialGatherModule(nn.Module): + """Aggregate the context features according to the initial predicted + probability distribution. + + Employ the soft-weighted method to aggregate the context. + """ def __init__(self, scale): super(SpatialGatherModule, s...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/mmpkg/mmseg/models/decode_heads/ocr_head.py
Add documentation for all methods
import torch.nn as nn import torch.utils.checkpoint as cp from annotator.mmpkg.mmcv.cnn import (UPSAMPLE_LAYERS, ConvModule, build_activation_layer, build_norm_layer, constant_init, kaiming_init) from annotator.mmpkg.mmcv.runner import load_checkpoint from annotator.mmpkg.mmcv.utils.parrots_wrappe...
--- +++ @@ -11,6 +11,34 @@ class BasicConvBlock(nn.Module): + """Basic convolutional block for UNet. + + This module consists of several plain convolutional layers. + + Args: + in_channels (int): Number of input channels. + out_channels (int): Number of output channels. + num_convs (in...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/mmpkg/mmseg/models/backbones/unet.py
Generate docstrings for this script
import annotator.mmpkg.mmcv as mmcv import torch import torch.nn as nn import torch.nn.functional as F from ..builder import LOSSES from .utils import get_class_weight, weight_reduce_loss def lovasz_grad(gt_sorted): p = len(gt_sorted) gts = gt_sorted.sum() intersection = gts - gt_sorted.float().cumsum(0...
--- +++ @@ -1,3 +1,6 @@+"""Modified from https://github.com/bermanmaxim/LovaszSoftmax/blob/master/pytor +ch/lovasz_losses.py Lovasz-Softmax and Jaccard hinge loss in PyTorch Maxim +Berman 2018 ESAT-PSI KU Leuven (MIT License)""" import annotator.mmpkg.mmcv as mmcv import torch @@ -9,6 +12,10 @@ def lovasz_grad(...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/mmpkg/mmseg/models/losses/lovasz_loss.py
Document this module using docstrings
import torch import torch.nn as nn from annotator.mmpkg.mmcv.cnn import ConvModule, DepthwiseSeparableConvModule from annotator.mmpkg.mmseg.ops import resize from ..builder import HEADS from .aspp_head import ASPPHead, ASPPModule class DepthwiseSeparableASPPModule(ASPPModule): def __init__(self, **kwargs): ...
--- +++ @@ -8,6 +8,8 @@ class DepthwiseSeparableASPPModule(ASPPModule): + """Atrous Spatial Pyramid Pooling (ASPP) Module with depthwise separable + conv.""" def __init__(self, **kwargs): super(DepthwiseSeparableASPPModule, self).__init__(**kwargs) @@ -25,6 +27,17 @@ @HEADS.register_module()...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/mmpkg/mmseg/models/decode_heads/sep_aspp_head.py
Generate consistent docstrings
import torch import torch.nn as nn from annotator.mmpkg.mmcv.cnn import ConvModule from annotator.mmpkg.mmseg.ops import resize from ..builder import HEADS from .decode_head import BaseDecodeHead from .psp_head import PPM @HEADS.register_module() class UPerHead(BaseDecodeHead): def __init__(self, pool_scales=(1...
--- +++ @@ -10,6 +10,15 @@ @HEADS.register_module() class UPerHead(BaseDecodeHead): + """Unified Perceptual Parsing for Scene Understanding. + + This head is the implementation of `UPerNet + <https://arxiv.org/abs/1807.10221>`_. + + Args: + pool_scales (tuple[int]): Pooling scales used in Pooling ...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/mmpkg/mmseg/models/decode_heads/uper_head.py
Write reusable docstrings
import torch import torch.nn as nn import torch.nn.functional as F from ..builder import LOSSES from .utils import get_class_weight, weight_reduce_loss def cross_entropy(pred, label, weight=None, class_weight=None, reduction='mean', ...
--- +++ @@ -13,6 +13,7 @@ reduction='mean', avg_factor=None, ignore_index=-100): + """The wrapper function for :func:`F.cross_entropy`""" # class_weight is a manual rescaling weight given to each class. # If given, has to be a Tensor of size C element...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/mmpkg/mmseg/models/losses/cross_entropy_loss.py
Write beginner-friendly docstrings
import functools import annotator.mmpkg.mmcv as mmcv import numpy as np import torch.nn.functional as F def get_class_weight(class_weight): if isinstance(class_weight, str): # take it as a file path if class_weight.endswith('.npy'): class_weight = np.load(class_weight) else: ...
--- +++ @@ -6,6 +6,12 @@ def get_class_weight(class_weight): + """Get class weight for loss function. + + Args: + class_weight (list[float] | str | None): If class_weight is a str, + take it as a file name and read from it. + """ if isinstance(class_weight, str): # take it a...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/mmpkg/mmseg/models/losses/utils.py
Create documentation for each function signature
import torch import torch.nn as nn import torch.nn.functional as F from ..builder import LOSSES from .utils import get_class_weight, weighted_loss @weighted_loss def dice_loss(pred, target, valid_mask, smooth=1, exponent=2, class_weight=None, ...
--- +++ @@ -1,3 +1,5 @@+"""Modified from https://github.com/LikeLy-Journey/SegmenTron/blob/master/ +segmentron/solver/loss.py (Apache-2.0 License)""" import torch import torch.nn as nn import torch.nn.functional as F @@ -46,6 +48,26 @@ @LOSSES.register_module() class DiceLoss(nn.Module): + """DiceLoss. + + ...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/mmpkg/mmseg/models/losses/dice_loss.py
Write docstrings for algorithm functions
# Copyright (c) OpenMMLab. All rights reserved. from ..dist_utils import allreduce_params from .hook import HOOKS, Hook @HOOKS.register_module() class SyncBuffersHook(Hook): def __init__(self, distributed=True): self.distributed = distributed def after_epoch(self, runner): if self.distribute...
--- +++ @@ -5,10 +5,18 @@ @HOOKS.register_module() class SyncBuffersHook(Hook): + """Synchronize model buffers such as running_mean and running_var in BN at + the end of each epoch. + + Args: + distributed (bool): Whether distributed training is used. It is + effective only for distributed t...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/mmpkg/mmcv/runner/hooks/sync_buffer.py
Help me comply with documentation standards
import torch import torch.nn as nn from annotator.mmpkg.mmcv.cnn import ConvModule from annotator.mmpkg.mmseg.ops import resize from ..builder import HEADS from .decode_head import BaseDecodeHead class PPM(nn.ModuleList): def __init__(self, pool_scales, in_channels, channels, conv_cfg, norm_cfg, ...
--- +++ @@ -8,6 +8,18 @@ class PPM(nn.ModuleList): + """Pooling Pyramid Module used in PSPNet. + + Args: + pool_scales (tuple[int]): Pooling scales used in Pooling Pyramid + Module. + in_channels (int): Input channels. + channels (int): Channels after modules, before conv_seg. ...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/mmpkg/mmseg/models/decode_heads/psp_head.py
Document this module using docstrings
import logging import warnings from abc import ABCMeta, abstractmethod from collections import OrderedDict import annotator.mmpkg.mmcv as mmcv import numpy as np import torch import torch.distributed as dist import torch.nn as nn from annotator.mmpkg.mmcv.runner import auto_fp16 class BaseSegmentor(nn.Module): ...
--- +++ @@ -12,6 +12,7 @@ class BaseSegmentor(nn.Module): + """Base class for segmentors.""" __metaclass__ = ABCMeta @@ -21,43 +22,67 @@ @property def with_neck(self): + """bool: whether the segmentor has neck""" return hasattr(self, 'neck') and self.neck is not None @p...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/mmpkg/mmseg/models/segmentors/base.py
Add docstrings to existing functions
from torch import nn from annotator.mmpkg.mmseg.core import add_prefix from annotator.mmpkg.mmseg.ops import resize from .. import builder from ..builder import SEGMENTORS from .encoder_decoder import EncoderDecoder @SEGMENTORS.register_module() class CascadeEncoderDecoder(EncoderDecoder): def __init__(self, ...
--- +++ @@ -9,6 +9,12 @@ @SEGMENTORS.register_module() class CascadeEncoderDecoder(EncoderDecoder): + """Cascade Encoder Decoder segmentors. + + CascadeEncoderDecoder almost the same as EncoderDecoder, while decoders of + CascadeEncoderDecoder are cascaded. The output of previous decoder_head + will be t...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/mmpkg/mmseg/models/segmentors/cascade_encoder_decoder.py
Write documentation strings for class attributes
from annotator.mmpkg.mmcv.cnn import ConvModule from torch import nn from torch.utils import checkpoint as cp from .se_layer import SELayer class InvertedResidual(nn.Module): def __init__(self, in_channels, out_channels, stride, expand_ratio, ...
--- +++ @@ -6,6 +6,27 @@ class InvertedResidual(nn.Module): + """InvertedResidual block for MobileNetV2. + + Args: + in_channels (int): The input channels of the InvertedResidual block. + out_channels (int): The output channels of the InvertedResidual block. + stride (int): Stride of the ...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/mmpkg/mmseg/models/utils/inverted_residual.py
Generate descriptive docstrings automatically
import torch from torch import nn class DropPath(nn.Module): def __init__(self, drop_prob=0.): super(DropPath, self).__init__() self.drop_prob = drop_prob self.keep_prob = 1 - drop_prob def forward(self, x): if self.drop_prob == 0. or not self.training: return x ...
--- +++ @@ -1,9 +1,18 @@+"""Modified from https://github.com/rwightman/pytorch-image- +models/blob/master/timm/models/layers/drop.py.""" import torch from torch import nn class DropPath(nn.Module): + """Drop paths (Stochastic Depth) per sample (when applied in main path of + residual blocks). + + Arg...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/mmpkg/mmseg/models/utils/drop.py
Generate missing documentation strings
# Copyright (c) OpenMMLab. All rights reserved. import collections.abc import functools import itertools import subprocess import warnings from collections import abc from importlib import import_module from inspect import getfullargspec from itertools import repeat # From PyTorch internals def _ntuple(n): def p...
--- +++ @@ -29,10 +29,32 @@ 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) def import_modules_from_strings(imports, allow_failed_imports=False): + """Import modules from the...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/mmpkg/mmcv/utils/misc.py
Help me add docstrings to my project
import torch import torch.nn as nn import torch.nn.functional as F from annotator.mmpkg.mmseg.core import add_prefix from annotator.mmpkg.mmseg.ops import resize from .. import builder from ..builder import SEGMENTORS from .base import BaseSegmentor @SEGMENTORS.register_module() class EncoderDecoder(BaseSegmentor): ...
--- +++ @@ -11,6 +11,12 @@ @SEGMENTORS.register_module() class EncoderDecoder(BaseSegmentor): + """Encoder Decoder segmentors. + + EncoderDecoder typically consists of backbone, decode_head, auxiliary_head. + Note that auxiliary_head is only used for deep supervision during training, + which could be dum...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/mmpkg/mmseg/models/segmentors/encoder_decoder.py
Write docstrings for backend logic
# Copyright (c) OpenMMLab. All rights reserved. import sys from collections.abc import Iterable from multiprocessing import Pool from shutil import get_terminal_size from .timer import Timer class ProgressBar: def __init__(self, task_num=0, bar_width=50, start=True, file=sys.stdout): self.task_num = tas...
--- +++ @@ -8,6 +8,7 @@ class ProgressBar: + """A progress bar which can print the progress.""" def __init__(self, task_num=0, bar_width=50, start=True, file=sys.stdout): self.task_num = task_num @@ -61,6 +62,19 @@ def track_progress(func, tasks, bar_width=50, file=sys.stdout, **kwargs): + ...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/mmpkg/mmcv/utils/progressbar.py
Generate helpful docstrings for debugging
import torch from annotator.mmpkg.mmcv.cnn import ConvModule, constant_init from torch import nn as nn from torch.nn import functional as F class SelfAttentionBlock(nn.Module): def __init__(self, key_in_channels, query_in_channels, channels, out_channels, share_key_query, query_downsample, ...
--- +++ @@ -5,6 +5,29 @@ class SelfAttentionBlock(nn.Module): + """General self-attention block/non-local block. + + Please refer to https://arxiv.org/abs/1706.03762 for details about key, + query and value. + + Args: + key_in_channels (int): Input channels of key feature. + query_in_chann...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/mmpkg/mmseg/models/utils/self_attention_block.py
Generate NumPy-style docstrings
# Copyright (c) OpenMMLab. All rights reserved. import logging import torch.distributed as dist logger_initialized = {} def get_logger(name, log_file=None, log_level=logging.INFO, file_mode='w'): logger = logging.getLogger(name) if name in logger_initialized: return logger # handle hierarchical ...
--- +++ @@ -7,6 +7,27 @@ def get_logger(name, log_file=None, log_level=logging.INFO, file_mode='w'): + """Initialize and get a logger by name. + + If the logger has not been initialized, this method will initialize the + logger by adding one or two handlers, otherwise the initialized logger will + be di...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/mmpkg/mmcv/utils/logging.py
Generate documentation strings for clarity
import math import warnings import torch def _no_grad_trunc_normal_(tensor, mean, std, a, b): def norm_cdf(x): # Computes standard normal cumulative distribution function return (1. + math.erf(x / math.sqrt(2.))) / 2. if (mean < a - 2 * std) or (mean > b + 2 * std): warnings.warn( ...
--- +++ @@ -1,3 +1,5 @@+"""Modified from https://github.com/rwightman/pytorch-image- +models/blob/master/timm/models/layers/drop.py.""" import math import warnings @@ -6,6 +8,8 @@ def _no_grad_trunc_normal_(tensor, mean, std, a, b): + """Reference: https://people.sc.fsu.edu/~jburkardt/presentations + /tru...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/mmpkg/mmseg/models/utils/weight_init.py
Add docstrings including usage examples
# Copyright (c) OpenMMLab. All rights reserved. import warnings import cv2 import numpy as np from annotator.mmpkg.mmcv.arraymisc import dequantize, quantize from annotator.mmpkg.mmcv.image import imread, imwrite from annotator.mmpkg.mmcv.utils import is_str def flowread(flow_or_path, quantize=False, concat_axis=0,...
--- +++ @@ -10,6 +10,18 @@ def flowread(flow_or_path, quantize=False, concat_axis=0, *args, **kwargs): + """Read an optical flow map. + + Args: + flow_or_path (ndarray or str): A flow map or filepath. + quantize (bool): whether to read quantized pair, if set to True, + remaining args ...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/mmpkg/mmcv/video/optflow.py
Auto-generate documentation strings for this file
from torch import nn as nn from torch.nn import functional as F def swish(x, inplace: bool = False): return x.mul_(x.sigmoid()) if inplace else x.mul(x.sigmoid()) class Swish(nn.Module): def __init__(self, inplace: bool = False): super(Swish, self).__init__() self.inplace = inplace def ...
--- +++ @@ -1,87 +1,102 @@-from torch import nn as nn -from torch.nn import functional as F - - -def swish(x, inplace: bool = False): - return x.mul_(x.sigmoid()) if inplace else x.mul(x.sigmoid()) - - -class Swish(nn.Module): - def __init__(self, inplace: bool = False): - super(Swish, self).__init__() - ...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/normalbae/models/submodules/efficientnet_repo/geffnet/activations/activations.py
Improve my code by adding docstrings
import torch from torch import nn as nn from torch.nn import functional as F __all__ = ['swish_jit', 'SwishJit', 'mish_jit', 'MishJit', 'hard_sigmoid_jit', 'HardSigmoidJit', 'hard_swish_jit', 'HardSwishJit'] @torch.jit.script def swish_jit(x, inplace: bool = False): return x.mul(x.sigmoid()) @torch...
--- +++ @@ -1,61 +1,79 @@- -import torch -from torch import nn as nn -from torch.nn import functional as F - -__all__ = ['swish_jit', 'SwishJit', 'mish_jit', 'MishJit', - 'hard_sigmoid_jit', 'HardSigmoidJit', 'hard_swish_jit', 'HardSwishJit'] - - -@torch.jit.script -def swish_jit(x, inplace: bool = False): - ...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/normalbae/models/submodules/efficientnet_repo/geffnet/activations/activations_jit.py
Write docstrings for data processing functions
from geffnet import config from geffnet.activations.activations_me import * from geffnet.activations.activations_jit import * from geffnet.activations.activations import * import torch _has_silu = 'silu' in dir(torch.nn.functional) _ACT_FN_DEFAULT = dict( silu=F.silu if _has_silu else swish, swish=F.silu if _...
--- +++ @@ -1,128 +1,137 @@-from geffnet import config -from geffnet.activations.activations_me import * -from geffnet.activations.activations_jit import * -from geffnet.activations.activations import * -import torch - -_has_silu = 'silu' in dir(torch.nn.functional) - -_ACT_FN_DEFAULT = dict( - silu=F.silu if _has_s...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/normalbae/models/submodules/efficientnet_repo/geffnet/activations/__init__.py
Document functions with detailed explanations
import torch.nn as nn import torch.utils.checkpoint as cp from annotator.mmpkg.mmcv.cnn import (build_conv_layer, build_norm_layer, build_plugin_layer, constant_init, kaiming_init) from annotator.mmpkg.mmcv.runner import load_checkpoint from annotator.mmpkg.mmcv.utils.parrots_wrapper import _Batch...
--- +++ @@ -11,6 +11,7 @@ class BasicBlock(nn.Module): + """Basic block for ResNet.""" expansion = 1 @@ -55,13 +56,16 @@ @property def norm1(self): + """nn.Module: normalization layer after the first convolution layer""" return getattr(self, self.norm1_name) @property ...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/mmpkg/mmseg/models/backbones/resnet.py
Add docstrings to improve collaboration
import torch.nn as nn from annotator.mmpkg.mmcv.cnn import (build_conv_layer, build_norm_layer, constant_init, kaiming_init) from annotator.mmpkg.mmcv.runner import load_checkpoint from annotator.mmpkg.mmcv.utils.parrots_wrapper import _BatchNorm from annotator.mmpkg.mmseg.ops import Upsample, re...
--- +++ @@ -11,6 +11,11 @@ class HRModule(nn.Module): + """High-Resolution Module for HRNet. + + In this module, every branch has 4 BasicBlocks/Bottlenecks. Fusion/Exchange + is in this module. + """ def __init__(self, num_branches, @@ -40,6 +45,7 @@ def _check_branches(se...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/mmpkg/mmseg/models/backbones/hrnet.py
Write reusable docstrings
from typing import Any, Optional __all__ = [ 'is_exportable', 'is_scriptable', 'is_no_jit', 'layer_config_kwargs', 'set_exportable', 'set_scriptable', 'set_no_jit', 'set_layer_config' ] # Set to True if prefer to have layers with no jit optimization (includes activations) _NO_JIT = False # Set to True if pre...
--- +++ @@ -1,117 +1,123 @@-from typing import Any, Optional - -__all__ = [ - 'is_exportable', 'is_scriptable', 'is_no_jit', 'layer_config_kwargs', - 'set_exportable', 'set_scriptable', 'set_no_jit', 'set_layer_config' -] - -# Set to True if prefer to have layers with no jit optimization (includes activations) -_...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/normalbae/models/submodules/efficientnet_repo/geffnet/config.py
Write docstrings for this repository
import os class AverageMeter: def __init__(self): self.reset() def reset(self): self.val = 0 self.avg = 0 self.sum = 0 self.count = 0 def update(self, val, n=1): self.val = val self.sum += val * n self.count += n self.avg = self.sum...
--- +++ @@ -1,49 +1,52 @@-import os - - -class AverageMeter: - def __init__(self): - self.reset() - - def reset(self): - self.val = 0 - self.avg = 0 - self.sum = 0 - self.count = 0 - - def update(self, val, n=1): - self.val = val - self.sum += val * n - s...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/normalbae/models/submodules/efficientnet_repo/utils.py
Write docstrings describing functionality
import copy import platform import random from functools import partial import numpy as np from annotator.mmpkg.mmcv.parallel import collate from annotator.mmpkg.mmcv.runner import get_dist_info from annotator.mmpkg.mmcv.utils import Registry, build_from_cfg from annotator.mmpkg.mmcv.utils.parrots_wrapper import DataL...
--- +++ @@ -23,6 +23,7 @@ def _concat_dataset(cfg, default_args=None): + """Build :obj:`ConcatDataset by.""" from .dataset_wrappers import ConcatDataset img_dir = cfg['img_dir'] ann_dir = cfg.get('ann_dir', None) @@ -58,6 +59,7 @@ def build_dataset(cfg, default_args=None): + """Build datase...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/mmpkg/mmseg/datasets/builder.py
Please document this code using docstrings
# Copyright (c) OpenMMLab. All rights reserved. import os import subprocess import warnings from packaging.version import parse def digit_version(version_str: str, length: int = 4): assert 'parrots' not in version_str version = parse(version_str) assert version.release, f'failed to parse version {version...
--- +++ @@ -7,6 +7,18 @@ 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. + ...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/mmpkg/mmcv/utils/version_utils.py
Generate NumPy-style docstrings
import torch from annotator.mmpkg.mmcv.cnn import NonLocal2d from torch import nn from ..builder import HEADS from .fcn_head import FCNHead class DisentangledNonLocal2d(NonLocal2d): def __init__(self, *arg, temperature, **kwargs): super().__init__(*arg, **kwargs) self.temperature = temperature ...
--- +++ @@ -7,6 +7,11 @@ class DisentangledNonLocal2d(NonLocal2d): + """Disentangled Non-Local Blocks. + + Args: + temperature (float): Temperature to adjust attention. Default: 0.05 + """ def __init__(self, *arg, temperature, **kwargs): super().__init__(*arg, **kwargs) @@ -14,6 +19,...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/mmpkg/mmseg/models/decode_heads/dnl_head.py
Generate descriptive docstrings automatically
import torch from torch import nn as nn from torch.nn import functional as F __all__ = ['swish_me', 'SwishMe', 'mish_me', 'MishMe', 'hard_sigmoid_me', 'HardSigmoidMe', 'hard_swish_me', 'HardSwishMe'] @torch.jit.script def swish_jit_fwd(x): return x.mul(torch.sigmoid(x)) @torch.jit.script def swish...
--- +++ @@ -1,151 +1,174 @@- -import torch -from torch import nn as nn -from torch.nn import functional as F - - -__all__ = ['swish_me', 'SwishMe', 'mish_me', 'MishMe', - 'hard_sigmoid_me', 'HardSigmoidMe', 'hard_swish_me', 'HardSwishMe'] - - -@torch.jit.script -def swish_jit_fwd(x): - return x.mul(torch.s...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/normalbae/models/submodules/efficientnet_repo/geffnet/activations/activations_me.py
Write docstrings describing functionality
# Copyright (c) Facebook, Inc. and its affiliates. import copy import logging import re from typing import Dict, List import torch from tabulate import tabulate def convert_basic_c2_names(original_keys): layer_keys = copy.deepcopy(original_keys) layer_keys = [ {"pred_b": "linear_b", "pred_w": "linear_...
--- +++ @@ -1,348 +1,412 @@-# Copyright (c) Facebook, Inc. and its affiliates. -import copy -import logging -import re -from typing import Dict, List -import torch -from tabulate import tabulate - - -def convert_basic_c2_names(original_keys): - layer_keys = copy.deepcopy(original_keys) - layer_keys = [ - {...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/checkpoint/c2_model_loading.py
Generate documentation strings for clarity
# -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. import functools import inspect import logging from fvcore.common.config import CfgNode as _CfgNode from annotator.oneformer.detectron2.utils.file_io import PathManager class CfgNode(_CfgNode): @classmethod def _open_cfg(cls, filena...
--- +++ @@ -1,168 +1,265 @@-# -*- coding: utf-8 -*- -# Copyright (c) Facebook, Inc. and its affiliates. - -import functools -import inspect -import logging -from fvcore.common.config import CfgNode as _CfgNode - -from annotator.oneformer.detectron2.utils.file_io import PathManager - - -class CfgNode(_CfgNode): - - @...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/config/config.py
Document my Python code with docstrings
# Copyright (c) Facebook, Inc. and its affiliates. import ast import builtins import collections.abc as abc import importlib import inspect import logging import os import uuid from contextlib import contextmanager from copy import deepcopy from dataclasses import is_dataclass from typing import List, Tuple, Union imp...
--- +++ @@ -1,368 +1,435 @@-# Copyright (c) Facebook, Inc. and its affiliates. - -import ast -import builtins -import collections.abc as abc -import importlib -import inspect -import logging -import os -import uuid -from contextlib import contextmanager -from copy import deepcopy -from dataclasses import is_dataclass -...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/config/lazy.py
Add return value explanations in docstrings
# Copyright (c) Facebook, Inc. and its affiliates. import itertools import logging import numpy as np import operator import pickle from typing import Any, Callable, Dict, List, Optional, Union import torch import torch.utils.data as torchdata from tabulate import tabulate from termcolor import colored from annotator....
--- +++ @@ -1,407 +1,556 @@-# Copyright (c) Facebook, Inc. and its affiliates. -import itertools -import logging -import numpy as np -import operator -import pickle -from typing import Any, Callable, Dict, List, Optional, Union -import torch -import torch.utils.data as torchdata -from tabulate import tabulate -from ter...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/data/build.py
Add detailed docstrings explaining each function
# Copyright (c) Facebook, Inc. and its affiliates. import copy import logging import types from collections import UserDict from typing import List from annotator.oneformer.detectron2.utils.logger import log_first_n __all__ = ["DatasetCatalog", "MetadataCatalog", "Metadata"] class _DatasetCatalog(UserDict): de...
--- +++ @@ -1,147 +1,236 @@-# Copyright (c) Facebook, Inc. and its affiliates. -import copy -import logging -import types -from collections import UserDict -from typing import List - -from annotator.oneformer.detectron2.utils.logger import log_first_n - -__all__ = ["DatasetCatalog", "MetadataCatalog", "Metadata"] - - -...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/data/catalog.py
Add professional docstrings to my codebase
from abc import ABCMeta, abstractmethod import torch import torch.nn as nn from annotator.mmpkg.mmcv.cnn import normal_init from annotator.mmpkg.mmcv.runner import auto_fp16, force_fp32 from annotator.mmpkg.mmseg.core import build_pixel_sampler from annotator.mmpkg.mmseg.ops import resize from ..builder import build_...
--- +++ @@ -12,6 +12,36 @@ class BaseDecodeHead(nn.Module, metaclass=ABCMeta): + """Base class for BaseDecodeHead. + + Args: + in_channels (int|Sequence[int]): Input channels. + channels (int): Channels after modules, before conv_seg. + num_classes (int): Number of classes. + dropo...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/mmpkg/mmseg/models/decode_heads/decode_head.py
Create docstrings for each class method
# Copyright (c) Facebook, Inc. and its affiliates. import contextlib import copy import itertools import logging import numpy as np import pickle import random from typing import Callable, Union import torch import torch.utils.data as data from torch.utils.data.sampler import Sampler from annotator.oneformer.detectron...
--- +++ @@ -1,216 +1,301 @@-# Copyright (c) Facebook, Inc. and its affiliates. -import contextlib -import copy -import itertools -import logging -import numpy as np -import pickle -import random -from typing import Callable, Union -import torch -import torch.utils.data as data -from torch.utils.data.sampler import Samp...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/data/common.py
Write reusable docstrings
# Copyright (c) Facebook, Inc. and its affiliates. import collections.abc as abc import dataclasses import logging from typing import Any from annotator.oneformer.detectron2.utils.registry import _convert_target_to_string, locate __all__ = ["dump_dataclass", "instantiate"] def dump_dataclass(obj: Any): assert ...
--- +++ @@ -1,68 +1,88 @@-# Copyright (c) Facebook, Inc. and its affiliates. - -import collections.abc as abc -import dataclasses -import logging -from typing import Any - -from annotator.oneformer.detectron2.utils.registry import _convert_target_to_string, locate - -__all__ = ["dump_dataclass", "instantiate"] - - -def...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/config/instantiate.py
Write docstrings that follow conventions
# Copyright (c) Facebook, Inc. and its affiliates. import logging import numpy as np from itertools import count from typing import List, Tuple import torch import tqdm from fvcore.common.timer import Timer from annotator.oneformer.detectron2.utils import comm from .build import build_batch_data_loader from .common i...
--- +++ @@ -1,180 +1,225 @@-# Copyright (c) Facebook, Inc. and its affiliates. -import logging -import numpy as np -from itertools import count -from typing import List, Tuple -import torch -import tqdm -from fvcore.common.timer import Timer - -from annotator.oneformer.detectron2.utils import comm - -from .build import...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/data/benchmark.py
Write clean docstrings for readability
import torch import torch.nn as nn import torch.nn.functional as F from annotator.mmpkg.mmcv.cnn import ConvModule from annotator.mmpkg.mmseg.ops import resize from ..builder import HEADS from .decode_head import BaseDecodeHead class ACM(nn.Module): def __init__(self, pool_scale, fusion, in_channels, channels, ...
--- +++ @@ -9,6 +9,18 @@ class ACM(nn.Module): + """Adaptive Context Module used in APCNet. + + Args: + pool_scale (int): Pooling scale used in Adaptive Context + Module to extract region features. + fusion (bool): Add one conv to fuse residual feature. + in_channels (int): Inp...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/mmpkg/mmseg/models/decode_heads/apc_head.py
Generate consistent docstrings
# Copyright (c) Facebook, Inc. and its affiliates. import copy import logging import numpy as np from typing import List, Optional, Union import torch from annotator.oneformer.detectron2.config import configurable from . import detection_utils as utils from . import transforms as T """ This file contains the default...
--- +++ @@ -1,152 +1,191 @@-# Copyright (c) Facebook, Inc. and its affiliates. -import copy -import logging -import numpy as np -from typing import List, Optional, Union -import torch - -from annotator.oneformer.detectron2.config import configurable - -from . import detection_utils as utils -from . import transforms as...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/data/dataset_mapper.py
Annotate my code with docstrings
# Copyright (c) Facebook, Inc. and its affiliates. import functools import json import logging import multiprocessing as mp import numpy as np import os from itertools import chain import annotator.oneformer.pycocotools.mask as mask_util from PIL import Image from annotator.oneformer.detectron2.structures import BoxMo...
--- +++ @@ -1,296 +1,329 @@-# Copyright (c) Facebook, Inc. and its affiliates. -import functools -import json -import logging -import multiprocessing as mp -import numpy as np -import os -from itertools import chain -import annotator.oneformer.pycocotools.mask as mask_util -from PIL import Image - -from annotator.onefo...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/data/datasets/cityscapes.py
Add minimal docstrings for each function
# -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. import logging import numpy as np from typing import List, Union import annotator.oneformer.pycocotools.mask as mask_util import torch from PIL import Image from annotator.oneformer.detectron2.structures import ( BitMasks, Boxes, B...
--- +++ @@ -1,451 +1,659 @@-# -*- coding: utf-8 -*- -# Copyright (c) Facebook, Inc. and its affiliates. - -import logging -import numpy as np -from typing import List, Union -import annotator.oneformer.pycocotools.mask as mask_util -import torch -from PIL import Image - -from annotator.oneformer.detectron2.structures i...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/data/detection_utils.py
Add docstrings for internal functions
import torch import torch.nn as nn from annotator.mmpkg.mmcv.cnn import ConvModule from ..builder import HEADS from ..utils import SelfAttentionBlock as _SelfAttentionBlock from .decode_head import BaseDecodeHead class PPMConcat(nn.ModuleList): def __init__(self, pool_scales=(1, 3, 6, 8)): super(PPMConc...
--- +++ @@ -8,12 +8,19 @@ class PPMConcat(nn.ModuleList): + """Pyramid Pooling Module that only concat the features of each layer. + + Args: + pool_scales (tuple[int]): Pooling scales used in Pooling Pyramid + Module. + """ def __init__(self, pool_scales=(1, 3, 6, 8)): sup...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/mmpkg/mmseg/models/decode_heads/ann_head.py
Generate missing documentation strings
# -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. import numpy as np import torch import torch.nn.functional as F from fvcore.transforms.transform import ( CropTransform, HFlipTransform, NoOpTransform, Transform, TransformList, ) from PIL import Image try: import cv2 ...
--- +++ @@ -1,258 +1,351 @@-# -*- coding: utf-8 -*- -# Copyright (c) Facebook, Inc. and its affiliates. - - -import numpy as np -import torch -import torch.nn.functional as F -from fvcore.transforms.transform import ( - CropTransform, - HFlipTransform, - NoOpTransform, - Transform, - TransformList, -) -f...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/data/transforms/transform.py
Write documentation strings for class attributes
# -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. import datetime import itertools import logging import math import operator import os import tempfile import time import warnings from collections import Counter import torch from fvcore.common.checkpoint import Checkpointer from fvcore.common....
--- +++ @@ -1,517 +1,690 @@-# -*- coding: utf-8 -*- -# Copyright (c) Facebook, Inc. and its affiliates. - -import datetime -import itertools -import logging -import math -import operator -import os -import tempfile -import time -import warnings -from collections import Counter -import torch -from fvcore.common.checkpoi...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/engine/hooks.py
Add docstrings for internal functions
# Copyright (c) Facebook, Inc. and its affiliates. import datetime import logging import time from collections import OrderedDict, abc from contextlib import ExitStack, contextmanager from typing import List, Union import torch from torch import nn from annotator.oneformer.detectron2.utils.comm import get_world_size, ...
--- +++ @@ -1,148 +1,224 @@-# Copyright (c) Facebook, Inc. and its affiliates. -import datetime -import logging -import time -from collections import OrderedDict, abc -from contextlib import ExitStack, contextmanager -from typing import List, Union -import torch -from torch import nn - -from annotator.oneformer.detectr...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/evaluation/evaluator.py
Help me comply with documentation standards
# Copyright (c) Facebook, Inc. and its affiliates. import logging import os from fvcore.common.timer import Timer from annotator.oneformer.detectron2.data import DatasetCatalog, MetadataCatalog from annotator.oneformer.detectron2.structures import BoxMode from annotator.oneformer.detectron2.utils.file_io import PathMa...
--- +++ @@ -1,202 +1,241 @@-# Copyright (c) Facebook, Inc. and its affiliates. -import logging -import os -from fvcore.common.timer import Timer - -from annotator.oneformer.detectron2.data import DatasetCatalog, MetadataCatalog -from annotator.oneformer.detectron2.structures import BoxMode -from annotator.oneformer.det...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/data/datasets/lvis.py
Provide docstrings following PEP 257
# -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. import numpy as np import sys from numpy import random from typing import Tuple import torch from fvcore.transforms.transform import ( BlendTransform, CropTransform, HFlipTransform, NoOpTransform, PadTransform, Transform,...
--- +++ @@ -1,507 +1,736 @@-# -*- coding: utf-8 -*- -# Copyright (c) Facebook, Inc. and its affiliates. -import numpy as np -import sys -from numpy import random -from typing import Tuple -import torch -from fvcore.transforms.transform import ( - BlendTransform, - CropTransform, - HFlipTransform, - NoOpTran...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/data/transforms/augmentation_impl.py
Add docstrings to improve code quality
# Copyright (c) Facebook, Inc. and its affiliates. import contextlib import io import itertools import json import logging import numpy as np import os import tempfile from collections import OrderedDict from typing import Optional from PIL import Image from tabulate import tabulate from annotator.oneformer.detectron2...
--- +++ @@ -1,188 +1,199 @@-# Copyright (c) Facebook, Inc. and its affiliates. -import contextlib -import io -import itertools -import json -import logging -import numpy as np -import os -import tempfile -from collections import OrderedDict -from typing import Optional -from PIL import Image -from tabulate import tabul...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/evaluation/panoptic_evaluation.py
Add detailed documentation for each class
# Copyright (c) Facebook, Inc. and its affiliates. import glob import logging import numpy as np import os import tempfile from collections import OrderedDict import torch from PIL import Image from annotator.oneformer.detectron2.data import MetadataCatalog from annotator.oneformer.detectron2.utils import comm from an...
--- +++ @@ -1,168 +1,197 @@-# Copyright (c) Facebook, Inc. and its affiliates. -import glob -import logging -import numpy as np -import os -import tempfile -from collections import OrderedDict -import torch -from PIL import Image - -from annotator.oneformer.detectron2.data import MetadataCatalog -from annotator.oneform...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/evaluation/cityscapes_evaluation.py
Generate docstrings for each module
# Copyright (c) Facebook, Inc. and its affiliates. import itertools import logging import math from collections import defaultdict from typing import Optional import torch from torch.utils.data.sampler import Sampler from annotator.oneformer.detectron2.utils import comm logger = logging.getLogger(__name__) class Tr...
--- +++ @@ -1,182 +1,278 @@-# Copyright (c) Facebook, Inc. and its affiliates. -import itertools -import logging -import math -from collections import defaultdict -from typing import Optional -import torch -from torch.utils.data.sampler import Sampler - -from annotator.oneformer.detectron2.utils import comm - -logger =...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/data/samplers/distributed_sampler.py
Add docstrings with type hints explained
# Copyright (c) Facebook, Inc. and its affiliates. import copy import itertools import json import logging import os import pickle from collections import OrderedDict import torch import annotator.oneformer.detectron2.utils.comm as comm from annotator.oneformer.detectron2.config import CfgNode from annotator.oneformer...
--- +++ @@ -1,328 +1,380 @@-# Copyright (c) Facebook, Inc. and its affiliates. -import copy -import itertools -import json -import logging -import os -import pickle -from collections import OrderedDict -import torch - -import annotator.oneformer.detectron2.utils.comm as comm -from annotator.oneformer.detectron2.config ...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/evaluation/lvis_evaluation.py
Add docstrings to improve code quality
# Copyright (c) Facebook, Inc. and its affiliates. import copy import logging import numpy as np import time from annotator.oneformer.pycocotools.cocoeval import COCOeval from annotator.oneformer.detectron2 import _C logger = logging.getLogger(__name__) class COCOeval_opt(COCOeval): def evaluate(self): ...
--- +++ @@ -1,106 +1,121 @@-# Copyright (c) Facebook, Inc. and its affiliates. -import copy -import logging -import numpy as np -import time -from annotator.oneformer.pycocotools.cocoeval import COCOeval - -from annotator.oneformer.detectron2 import _C - -logger = logging.getLogger(__name__) - - -class COCOeval_opt(COC...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/evaluation/fast_eval_api.py
Add standardized docstrings across the file
# -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. import logging import numpy as np import time import weakref from typing import List, Mapping, Optional import torch from torch.nn.parallel import DataParallel, DistributedDataParallel import annotator.oneformer.detectron2.utils.comm as comm f...
--- +++ @@ -1,340 +1,469 @@-# -*- coding: utf-8 -*- -# Copyright (c) Facebook, Inc. and its affiliates. - -import logging -import numpy as np -import time -import weakref -from typing import List, Mapping, Optional -import torch -from torch.nn.parallel import DataParallel, DistributedDataParallel - -import annotator.on...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/engine/train_loop.py
Create structured documentation for my script
import torch import torch.nn as nn import torch.nn.functional as F from annotator.mmpkg.mmcv.cnn import ConvModule, build_activation_layer, build_norm_layer from ..builder import HEADS from .decode_head import BaseDecodeHead class DCM(nn.Module): def __init__(self, filter_size, fusion, in_channels, channels, co...
--- +++ @@ -8,6 +8,18 @@ class DCM(nn.Module): + """Dynamic Convolutional Module used in DMNet. + + Args: + filter_size (int): The filter size of generated convolution kernel + used in Dynamic Convolutional Module. + fusion (bool): Add one conv to fuse DCM output feature. + in_...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/mmpkg/mmseg/models/decode_heads/dm_head.py
Generate consistent documentation across files
# Copyright (c) Facebook, Inc. and its affiliates. import contextlib import copy import io import itertools import json import logging import numpy as np import os import pickle from collections import OrderedDict import annotator.oneformer.pycocotools.mask as mask_util import torch from annotator.oneformer.pycocotools...
--- +++ @@ -1,613 +1,722 @@-# Copyright (c) Facebook, Inc. and its affiliates. -import contextlib -import copy -import io -import itertools -import json -import logging -import numpy as np -import os -import pickle -from collections import OrderedDict -import annotator.oneformer.pycocotools.mask as mask_util -import to...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/evaluation/coco_evaluation.py
Fully document this Python code with docstrings
# -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. import logging import numpy as np import os import tempfile import xml.etree.ElementTree as ET from collections import OrderedDict, defaultdict from functools import lru_cache import torch from annotator.oneformer.detectron2.data import Metada...
--- +++ @@ -1,260 +1,300 @@-# -*- coding: utf-8 -*- -# Copyright (c) Facebook, Inc. and its affiliates. - -import logging -import numpy as np -import os -import tempfile -import xml.etree.ElementTree as ET -from collections import OrderedDict, defaultdict -from functools import lru_cache -import torch - -from annotator...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/evaluation/pascal_voc_evaluation.py
Create simple docstrings for beginners
# Copyright (c) Facebook, Inc. and its affiliates. import itertools import json import numpy as np import os import torch from annotator.oneformer.pycocotools.cocoeval import COCOeval, maskUtils from annotator.oneformer.detectron2.structures import BoxMode, RotatedBoxes, pairwise_iou_rotated from annotator.oneformer.d...
--- +++ @@ -1,187 +1,207 @@-# Copyright (c) Facebook, Inc. and its affiliates. -import itertools -import json -import numpy as np -import os -import torch -from annotator.oneformer.pycocotools.cocoeval import COCOeval, maskUtils - -from annotator.oneformer.detectron2.structures import BoxMode, RotatedBoxes, pairwise_io...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/evaluation/rotated_coco_evaluation.py
Provide docstrings following PEP 257
# Copyright (c) Facebook, Inc. and its affiliates. import collections import copy import functools import logging import numpy as np import os from typing import Any, Callable, Dict, List, Optional, Tuple, Union from unittest import mock import caffe2.python.utils as putils import torch import torch.nn.functional as F...
--- +++ @@ -1,937 +1,1039 @@-# Copyright (c) Facebook, Inc. and its affiliates. - -import collections -import copy -import functools -import logging -import numpy as np -import os -from typing import Any, Callable, Dict, List, Optional, Tuple, Union -from unittest import mock -import caffe2.python.utils as putils -impo...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/export/shared.py
Auto-generate documentation strings for this file
# Copyright (c) Facebook, Inc. and its affiliates. import math from typing import Dict import torch import torch.nn.functional as F from annotator.oneformer.detectron2.layers import ShapeSpec, cat from annotator.oneformer.detectron2.layers.roi_align_rotated import ROIAlignRotated from annotator.oneformer.detectron2.m...
--- +++ @@ -1,533 +1,557 @@-# Copyright (c) Facebook, Inc. and its affiliates. - -import math -from typing import Dict -import torch -import torch.nn.functional as F - -from annotator.oneformer.detectron2.layers import ShapeSpec, cat -from annotator.oneformer.detectron2.layers.roi_align_rotated import ROIAlignRotated -...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/export/c10.py
Improve documentation using docstrings
# Copyright (c) Facebook, Inc. and its affiliates. import copy import logging import os import torch from caffe2.proto import caffe2_pb2 from torch import nn from annotator.oneformer.detectron2.config import CfgNode from annotator.oneformer.detectron2.utils.file_io import PathManager from .caffe2_inference import Pro...
--- +++ @@ -1,113 +1,230 @@-# Copyright (c) Facebook, Inc. and its affiliates. -import copy -import logging -import os -import torch -from caffe2.proto import caffe2_pb2 -from torch import nn - -from annotator.oneformer.detectron2.config import CfgNode -from annotator.oneformer.detectron2.utils.file_io import PathManag...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/export/api.py
Create Google-style docstrings for my code
# Copyright (c) Facebook, Inc. and its affiliates. import os import torch from annotator.oneformer.detectron2.utils.file_io import PathManager from .torchscript_patch import freeze_training_mode, patch_instances __all__ = ["scripting_with_instances", "dump_torchscript_IR"] def scripting_with_instances(model, fiel...
--- +++ @@ -1,88 +1,132 @@-# Copyright (c) Facebook, Inc. and its affiliates. - -import os -import torch - -from annotator.oneformer.detectron2.utils.file_io import PathManager - -from .torchscript_patch import freeze_training_mode, patch_instances - -__all__ = ["scripting_with_instances", "dump_torchscript_IR"] - - -d...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/export/torchscript.py
Add docstrings that explain purpose and usage
# Copyright (c) Facebook, Inc. and its affiliates. import itertools import json import logging import numpy as np import os from collections import OrderedDict from typing import Optional, Union import annotator.oneformer.pycocotools.mask as mask_util import torch from PIL import Image from annotator.oneformer.detectr...
--- +++ @@ -1,231 +1,265 @@-# Copyright (c) Facebook, Inc. and its affiliates. -import itertools -import json -import logging -import numpy as np -import os -from collections import OrderedDict -from typing import Optional, Union -import annotator.oneformer.pycocotools.mask as mask_util -import torch -from PIL import I...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/evaluation/sem_seg_evaluation.py
Can you add docstrings to this Python file?
# Copyright (c) Facebook, Inc. and its affiliates. import functools import io import struct import types import torch from annotator.oneformer.detectron2.modeling import meta_arch from annotator.oneformer.detectron2.modeling.box_regression import Box2BoxTransform from annotator.oneformer.detectron2.modeling.roi_heads...
--- +++ @@ -1,332 +1,419 @@-# Copyright (c) Facebook, Inc. and its affiliates. - -import functools -import io -import struct -import types -import torch - -from annotator.oneformer.detectron2.modeling import meta_arch -from annotator.oneformer.detectron2.modeling.box_regression import Box2BoxTransform -from annotator.o...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/export/caffe2_modeling.py
Add structured docstrings to improve clarity
# Copyright (c) Facebook, Inc. and its affiliates. import os import sys import tempfile from contextlib import ExitStack, contextmanager from copy import deepcopy from unittest import mock import torch from torch import nn # need some explicit imports due to https://github.com/pytorch/pytorch/issues/38964 import anno...
--- +++ @@ -1,373 +1,406 @@-# Copyright (c) Facebook, Inc. and its affiliates. - -import os -import sys -import tempfile -from contextlib import ExitStack, contextmanager -from copy import deepcopy -from unittest import mock -import torch -from torch import nn - -# need some explicit imports due to https://github.com/p...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/export/torchscript_patch.py
Generate descriptive docstrings automatically
# Copyright (c) Facebook, Inc. and its affiliates. import collections from dataclasses import dataclass from typing import Callable, List, Optional, Tuple import torch from torch import nn from annotator.oneformer.detectron2.structures import Boxes, Instances, ROIMasks from annotator.oneformer.detectron2.utils.registr...
--- +++ @@ -1,257 +1,330 @@-# Copyright (c) Facebook, Inc. and its affiliates. -import collections -from dataclasses import dataclass -from typing import Callable, List, Optional, Tuple -import torch -from torch import nn - -from annotator.oneformer.detectron2.structures import Boxes, Instances, ROIMasks -from annotato...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/export/flatten.py
Add docstrings to make code maintainable
# Copyright (c) Facebook, Inc. and its affiliates. import contextlib from unittest import mock import torch from annotator.oneformer.detectron2.modeling import poolers from annotator.oneformer.detectron2.modeling.proposal_generator import rpn from annotator.oneformer.detectron2.modeling.roi_heads import keypoint_head...
--- +++ @@ -1,136 +1,152 @@-# Copyright (c) Facebook, Inc. and its affiliates. - -import contextlib -from unittest import mock -import torch - -from annotator.oneformer.detectron2.modeling import poolers -from annotator.oneformer.detectron2.modeling.proposal_generator import rpn -from annotator.oneformer.detectron2.mod...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/export/caffe2_patch.py
Write docstrings that follow conventions
# Copyright (c) Facebook, Inc. and its affiliates. import torch import torch.distributed as dist from fvcore.nn.distributed import differentiable_all_reduce from torch import nn from torch.nn import functional as F from annotator.oneformer.detectron2.utils import comm, env from .wrappers import BatchNorm2d class Fr...
--- +++ @@ -1,208 +1,300 @@-# Copyright (c) Facebook, Inc. and its affiliates. -import torch -import torch.distributed as dist -from fvcore.nn.distributed import differentiable_all_reduce -from torch import nn -from torch.nn import functional as F - -from annotator.oneformer.detectron2.utils import comm, env - -from .w...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/layers/batch_norm.py
Can you add docstrings to this Python file?
# Copyright (c) Facebook, Inc. and its affiliates. import numpy as np from typing import Tuple import torch from PIL import Image from torch.nn import functional as F __all__ = ["paste_masks_in_image"] BYTES_PER_FLOAT = 4 # TODO: This memory limit may be too much or too little. It would be better to # determine it b...
--- +++ @@ -1,195 +1,275 @@-# Copyright (c) Facebook, Inc. and its affiliates. -import numpy as np -from typing import Tuple -import torch -from PIL import Image -from torch.nn import functional as F - -__all__ = ["paste_masks_in_image"] - - -BYTES_PER_FLOAT = 4 -# TODO: This memory limit may be too much or too little....
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/layers/mask_ops.py
Create Google-style docstrings for my code
# Copyright (c) Facebook, Inc. and its affiliates. import math from functools import lru_cache import torch from torch import nn from torch.autograd import Function from torch.autograd.function import once_differentiable from torch.nn.modules.utils import _pair from torchvision.ops import deform_conv2d from annotator....
--- +++ @@ -1,485 +1,514 @@-# Copyright (c) Facebook, Inc. and its affiliates. -import math -from functools import lru_cache -import torch -from torch import nn -from torch.autograd import Function -from torch.autograd.function import once_differentiable -from torch.nn.modules.utils import _pair -from torchvision.ops i...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/layers/deform_conv.py
Add docstrings to make code maintainable
# -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. import torch from torchvision.ops import boxes as box_ops from torchvision.ops import nms # noqa . for compatibility def batched_nms( boxes: torch.Tensor, scores: torch.Tensor, idxs: torch.Tensor, iou_threshold: float ): assert boxes...
--- +++ @@ -1,58 +1,144 @@-# -*- coding: utf-8 -*- -# Copyright (c) Facebook, Inc. and its affiliates. - -import torch -from torchvision.ops import boxes as box_ops -from torchvision.ops import nms # noqa . for compatibility - - -def batched_nms( - boxes: torch.Tensor, scores: torch.Tensor, idxs: torch.Tensor, iou_...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/layers/nms.py
Add docstrings to improve code quality
# Copyright (c) Facebook, Inc. and its affiliates. import torch from torch import nn from torch.autograd import Function from torch.autograd.function import once_differentiable from torch.nn.modules.utils import _pair class _ROIAlignRotated(Function): @staticmethod def forward(ctx, input, roi, output_size, sp...
--- +++ @@ -1,80 +1,100 @@-# Copyright (c) Facebook, Inc. and its affiliates. -import torch -from torch import nn -from torch.autograd import Function -from torch.autograd.function import once_differentiable -from torch.nn.modules.utils import _pair - - -class _ROIAlignRotated(Function): - @staticmethod - def for...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/layers/roi_align_rotated.py
Document helper functions with docstrings
# Copyright (c) Facebook, Inc. and its affiliates. from abc import ABCMeta, abstractmethod from typing import Dict import torch.nn as nn from annotator.oneformer.detectron2.layers import ShapeSpec __all__ = ["Backbone"] class Backbone(nn.Module, metaclass=ABCMeta): def __init__(self): super().__init__(...
--- +++ @@ -1,35 +1,74 @@-# Copyright (c) Facebook, Inc. and its affiliates. -from abc import ABCMeta, abstractmethod -from typing import Dict -import torch.nn as nn - -from annotator.oneformer.detectron2.layers import ShapeSpec - -__all__ = ["Backbone"] - - -class Backbone(nn.Module, metaclass=ABCMeta): - - def __i...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/modeling/backbone/backbone.py
Create docstrings for each class method
import torch.nn as nn def accuracy(pred, target, topk=1, thresh=None): assert isinstance(topk, (int, tuple)) if isinstance(topk, int): topk = (topk, ) return_single = True else: return_single = False maxk = max(topk) if pred.size(0) == 0: accu = [pred.new_tensor(0....
--- +++ @@ -2,6 +2,24 @@ def accuracy(pred, target, topk=1, thresh=None): + """Calculate accuracy according to the prediction and target. + + Args: + pred (torch.Tensor): The model prediction, shape (N, num_class, ...) + target (torch.Tensor): The target of each prediction, shape (N, , ...) + ...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/mmpkg/mmseg/models/losses/accuracy.py
Add docstrings to incomplete code
# Copyright (c) Facebook, Inc. and its affiliates. import os from typing import Optional import pkg_resources import torch from annotator.oneformer.detectron2.checkpoint import DetectionCheckpointer from annotator.oneformer.detectron2.config import CfgNode, LazyConfig, get_cfg, instantiate from annotator.oneformer.det...
--- +++ @@ -1,155 +1,213 @@-# Copyright (c) Facebook, Inc. and its affiliates. -import os -from typing import Optional -import pkg_resources -import torch - -from annotator.oneformer.detectron2.checkpoint import DetectionCheckpointer -from annotator.oneformer.detectron2.config import CfgNode, LazyConfig, get_cfg, insta...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/model_zoo/model_zoo.py
Generate missing documentation strings
# Copyright (c) Facebook, Inc. and its affiliates. import collections import math from typing import List import torch from torch import nn from annotator.oneformer.detectron2.config import configurable from annotator.oneformer.detectron2.layers import ShapeSpec, move_device_like from annotator.oneformer.detectron2.st...
--- +++ @@ -1,245 +1,386 @@-# Copyright (c) Facebook, Inc. and its affiliates. -import collections -import math -from typing import List -import torch -from torch import nn - -from annotator.oneformer.detectron2.config import configurable -from annotator.oneformer.detectron2.layers import ShapeSpec, move_device_like -f...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/modeling/anchor_generator.py
Write docstrings that follow conventions
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import numpy as np import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.checkpoint as checkpoint from annotator.oneformer.detectron2.modeling.backbone.backbone import Backbone _to_2tuple = nn.modules.utils._ntuple...
--- +++ @@ -1,561 +1,695 @@-# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved - -import numpy as np -import torch -import torch.nn as nn -import torch.nn.functional as F -import torch.utils.checkpoint as checkpoint - -from annotator.oneformer.detectron2.modeling.backbone.backbone import Backbone - ...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/modeling/backbone/swin.py
Document classes and their methods
# Copyright (c) Facebook, Inc. and its affiliates. import logging from typing import List, Optional, Tuple import torch from fvcore.nn import sigmoid_focal_loss_jit from torch import nn from torch.nn import functional as F from annotator.oneformer.detectron2.layers import ShapeSpec, batched_nms from annotator.oneform...
--- +++ @@ -1,288 +1,328 @@-# Copyright (c) Facebook, Inc. and its affiliates. - -import logging -from typing import List, Optional, Tuple -import torch -from fvcore.nn import sigmoid_focal_loss_jit -from torch import nn -from torch.nn import functional as F - -from annotator.oneformer.detectron2.layers import ShapeSpe...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/modeling/meta_arch/fcos.py
Document my Python code with docstrings
# Copyright (c) Facebook, Inc. and its affiliates. import numpy as np import fvcore.nn.weight_init as weight_init import torch import torch.nn.functional as F from torch import nn from annotator.oneformer.detectron2.layers import ( CNNBlockBase, Conv2d, DeformConv, ModulatedDeformConv, ShapeSpec, ...
--- +++ @@ -1,555 +1,694 @@-# Copyright (c) Facebook, Inc. and its affiliates. -import numpy as np -import fvcore.nn.weight_init as weight_init -import torch -import torch.nn.functional as F -from torch import nn - -from annotator.oneformer.detectron2.layers import ( - CNNBlockBase, - Conv2d, - DeformConv, - ...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/modeling/backbone/resnet.py
Add missing documentation to my Python functions
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import numpy as np from torch import nn from annotator.oneformer.detectron2.layers import CNNBlockBase, ShapeSpec, get_norm from .backbone import Backbone __all__ = [ "AnyNet", "RegNet", "ResStem", "SimpleStem", "VanillaBlock...
--- +++ @@ -1,359 +1,452 @@-# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved - -import numpy as np -from torch import nn - -from annotator.oneformer.detectron2.layers import CNNBlockBase, ShapeSpec, get_norm - -from .backbone import Backbone - -__all__ = [ - "AnyNet", - "RegNet", - "ResSt...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/modeling/backbone/regnet.py
Document all endpoints with docstrings
import collections.abc import math from functools import partial from itertools import repeat from typing import Tuple, Optional import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from .config import * # From PyTorch internals def _ntuple(n): def parse(x): if isinstanc...
--- +++ @@ -1,280 +1,304 @@-import collections.abc -import math -from functools import partial -from itertools import repeat -from typing import Tuple, Optional - -import numpy as np -import torch -import torch.nn as nn -import torch.nn.functional as F - -from .config import * - - -# From PyTorch internals -def _ntuple...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/normalbae/models/submodules/efficientnet_repo/geffnet/conv2d_layers.py
Generate docstrings with examples
# Copyright (c) Facebook, Inc. and its affiliates. import logging import math from typing import List, Tuple import torch from fvcore.nn import sigmoid_focal_loss_jit from torch import Tensor, nn from torch.nn import functional as F from annotator.oneformer.detectron2.config import configurable from annotator.oneforme...
--- +++ @@ -1,324 +1,439 @@-# Copyright (c) Facebook, Inc. and its affiliates. -import logging -import math -from typing import List, Tuple -import torch -from fvcore.nn import sigmoid_focal_loss_jit -from torch import Tensor, nn -from torch.nn import functional as F - -from annotator.oneformer.detectron2.config import...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/modeling/meta_arch/retinanet.py
Generate docstrings for exported functions
# Copyright (c) Facebook, Inc. and its affiliates. import math from typing import List, Optional import torch from torch import nn from torchvision.ops import RoIPool from annotator.oneformer.detectron2.layers import ROIAlign, ROIAlignRotated, cat, nonzero_tuple, shapes_to_tensor from annotator.oneformer.detectron2.st...
--- +++ @@ -1,176 +1,263 @@-# Copyright (c) Facebook, Inc. and its affiliates. -import math -from typing import List, Optional -import torch -from torch import nn -from torchvision.ops import RoIPool - -from annotator.oneformer.detectron2.layers import ROIAlign, ROIAlignRotated, cat, nonzero_tuple, shapes_to_tensor -fr...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/modeling/poolers.py
Add structured docstrings to improve clarity
# Copyright (c) Facebook, Inc. and its affiliates. import numpy as np from typing import Callable, Dict, Optional, Tuple, Union import fvcore.nn.weight_init as weight_init import torch from torch import nn from torch.nn import functional as F from annotator.oneformer.detectron2.config import configurable from annotato...
--- +++ @@ -1,207 +1,267 @@-# Copyright (c) Facebook, Inc. and its affiliates. -import numpy as np -from typing import Callable, Dict, Optional, Tuple, Union -import fvcore.nn.weight_init as weight_init -import torch -from torch import nn -from torch.nn import functional as F - -from annotator.oneformer.detectron2.conf...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/modeling/meta_arch/semantic_seg.py
Add documentation for all methods
# Copyright (c) Facebook, Inc. and its affiliates. import itertools import logging import numpy as np from collections import OrderedDict from collections.abc import Mapping from typing import Dict, List, Optional, Tuple, Union import torch from omegaconf import DictConfig, OmegaConf from torch import Tensor, nn from ...
--- +++ @@ -1,236 +1,273 @@-# Copyright (c) Facebook, Inc. and its affiliates. -import itertools -import logging -import numpy as np -from collections import OrderedDict -from collections.abc import Mapping -from typing import Dict, List, Optional, Tuple, Union -import torch -from omegaconf import DictConfig, OmegaConf...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/modeling/mmdet_wrapper.py
Document all public functions with docstrings
import re from copy import deepcopy from .conv2d_layers import * from geffnet.activations import * __all__ = ['get_bn_args_tf', 'resolve_bn_args', 'resolve_se_args', 'resolve_act_layer', 'make_divisible', 'round_channels', 'drop_connect', 'SqueezeExcite', 'ConvBnAct', 'DepthwiseSeparableConv', '...
--- +++ @@ -1,625 +1,683 @@-import re -from copy import deepcopy - -from .conv2d_layers import * -from geffnet.activations import * - -__all__ = ['get_bn_args_tf', 'resolve_bn_args', 'resolve_se_args', 'resolve_act_layer', 'make_divisible', - 'round_channels', 'drop_connect', 'SqueezeExcite', 'ConvBnAct', 'De...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/normalbae/models/submodules/efficientnet_repo/geffnet/efficientnet_builder.py
Generate helpful docstrings for debugging
import numpy as np from typing import Dict, List, Optional, Tuple import torch from torch import Tensor, nn from annotator.oneformer.detectron2.data.detection_utils import convert_image_to_rgb from annotator.oneformer.detectron2.layers import move_device_like from annotator.oneformer.detectron2.modeling import Backbon...
--- +++ @@ -1,193 +1,294 @@-import numpy as np -from typing import Dict, List, Optional, Tuple -import torch -from torch import Tensor, nn - -from annotator.oneformer.detectron2.data.detection_utils import convert_image_to_rgb -from annotator.oneformer.detectron2.layers import move_device_like -from annotator.oneformer...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/modeling/meta_arch/dense_detector.py
Generate consistent docstrings
# Copyright (c) Facebook, Inc. and its affiliates. from typing import Dict, List, Optional, Tuple, Union import torch import torch.nn.functional as F from torch import nn from annotator.oneformer.detectron2.config import configurable from annotator.oneformer.detectron2.layers import Conv2d, ShapeSpec, cat from annotat...
--- +++ @@ -1,388 +1,533 @@-# Copyright (c) Facebook, Inc. and its affiliates. -from typing import Dict, List, Optional, Tuple, Union -import torch -import torch.nn.functional as F -from torch import nn - -from annotator.oneformer.detectron2.config import configurable -from annotator.oneformer.detectron2.layers import ...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/modeling/proposal_generator/rpn.py
Add well-formatted docstrings
# Copyright (c) Facebook, Inc. and its affiliates. import itertools import logging from typing import Dict, List import torch from annotator.oneformer.detectron2.config import configurable from annotator.oneformer.detectron2.layers import ShapeSpec, batched_nms_rotated, cat from annotator.oneformer.detectron2.structur...
--- +++ @@ -1,162 +1,209 @@-# Copyright (c) Facebook, Inc. and its affiliates. -import itertools -import logging -from typing import Dict, List -import torch - -from annotator.oneformer.detectron2.config import configurable -from annotator.oneformer.detectron2.layers import ShapeSpec, batched_nms_rotated, cat -from ann...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/modeling/proposal_generator/rrpn.py
Add docstrings to clarify complex logic
# Copyright (c) Facebook, Inc. and its affiliates. import torch from torch.nn import functional as F from annotator.oneformer.detectron2.structures import Instances, ROIMasks # perhaps should rename to "resize_instance" def detector_postprocess( results: Instances, output_height: int, output_width: int, mask_thr...
--- +++ @@ -1,65 +1,100 @@-# Copyright (c) Facebook, Inc. and its affiliates. -import torch -from torch.nn import functional as F - -from annotator.oneformer.detectron2.structures import Instances, ROIMasks - - -# perhaps should rename to "resize_instance" -def detector_postprocess( - results: Instances, output_heig...
https://raw.githubusercontent.com/Mikubill/sd-webui-controlnet/HEAD/annotator/oneformer/detectron2/modeling/postprocessing.py