repo
stringlengths
7
90
file_url
stringlengths
81
315
file_path
stringlengths
4
228
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 14:38:15
2026-01-05 02:33:18
truncated
bool
2 classes
agno-agi/agno
https://github.com/agno-agi/agno/blob/26b9daa0fb760c3ad8384e1ba9218b1bce854535/libs/agno/agno/cloud/aws/s3/__init__.py
libs/agno/agno/cloud/aws/s3/__init__.py
from agno.cloud.aws.s3.bucket import S3Bucket from agno.cloud.aws.s3.object import S3Object
python
Apache-2.0
26b9daa0fb760c3ad8384e1ba9218b1bce854535
2026-01-04T14:41:49.609528Z
false
agno-agi/agno
https://github.com/agno-agi/agno/blob/26b9daa0fb760c3ad8384e1ba9218b1bce854535/libs/agno/agno/agent/__init__.py
libs/agno/agno/agent/__init__.py
from agno.agent.agent import ( Agent, AgentSession, Function, Message, Toolkit, ) from agno.agent.remote import RemoteAgent from agno.run.agent import ( MemoryUpdateCompletedEvent, MemoryUpdateStartedEvent, ReasoningCompletedEvent, ReasoningStartedEvent, ReasoningStepEvent, R...
python
Apache-2.0
26b9daa0fb760c3ad8384e1ba9218b1bce854535
2026-01-04T14:41:49.609528Z
false
agno-agi/agno
https://github.com/agno-agi/agno/blob/26b9daa0fb760c3ad8384e1ba9218b1bce854535/libs/agno/agno/agent/remote.py
libs/agno/agno/agent/remote.py
import json import time from dataclasses import dataclass, field from typing import TYPE_CHECKING, Any, AsyncIterator, Dict, List, Literal, Optional, Sequence, Tuple, Union, overload from pydantic import BaseModel from agno.media import Audio, File, Image, Video from agno.models.base import Model from agno.models.mes...
python
Apache-2.0
26b9daa0fb760c3ad8384e1ba9218b1bce854535
2026-01-04T14:41:49.609528Z
false
agno-agi/agno
https://github.com/agno-agi/agno/blob/26b9daa0fb760c3ad8384e1ba9218b1bce854535/libs/agno/agno/agent/agent.py
libs/agno/agno/agent/agent.py
from __future__ import annotations import asyncio import time import warnings from asyncio import CancelledError, Task, create_task from collections import ChainMap, deque from concurrent.futures import Future from dataclasses import dataclass from inspect import iscoroutinefunction from os import getenv from textwrap...
python
Apache-2.0
26b9daa0fb760c3ad8384e1ba9218b1bce854535
2026-01-04T14:41:49.609528Z
true
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/gradio_fake_scribble2image.py
gradio_fake_scribble2image.py
from share import * import config import cv2 import einops import gradio as gr import numpy as np import torch import random from pytorch_lightning import seed_everything from annotator.util import resize_image, HWC3 from annotator.hed import HEDdetector, nms from cldm.model import create_model, load_state_dict from ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/tutorial_train_sd21.py
tutorial_train_sd21.py
from share import * import pytorch_lightning as pl from torch.utils.data import DataLoader from tutorial_dataset import MyDataset from cldm.logger import ImageLogger from cldm.model import create_model, load_state_dict # Configs resume_path = './models/control_sd21_ini.ckpt' batch_size = 4 logger_freq = 300 learning...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/gradio_hough2image.py
gradio_hough2image.py
from share import * import config import cv2 import einops import gradio as gr import numpy as np import torch import random from pytorch_lightning import seed_everything from annotator.util import resize_image, HWC3 from annotator.mlsd import MLSDdetector from cldm.model import create_model, load_state_dict from cld...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/gradio_canny2image.py
gradio_canny2image.py
from share import * import config import cv2 import einops import gradio as gr import numpy as np import torch import random from pytorch_lightning import seed_everything from annotator.util import resize_image, HWC3 from annotator.canny import CannyDetector from cldm.model import create_model, load_state_dict from c...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/gradio_normal2image.py
gradio_normal2image.py
from share import * import config import cv2 import einops import gradio as gr import numpy as np import torch import random from pytorch_lightning import seed_everything from annotator.util import resize_image, HWC3 from annotator.midas import MidasDetector from cldm.model import create_model, load_state_dict from c...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/tool_transfer_control.py
tool_transfer_control.py
path_sd15 = './models/v1-5-pruned.ckpt' path_sd15_with_control = './models/control_sd15_openpose.pth' path_input = './models/anything-v3-full.safetensors' path_output = './models/control_any3_openpose.pth' import os assert os.path.exists(path_sd15), 'Input path_sd15 does not exists!' assert os.path.exists(path_sd15...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/gradio_scribble2image.py
gradio_scribble2image.py
from share import * import config import cv2 import einops import gradio as gr import numpy as np import torch import random from pytorch_lightning import seed_everything from annotator.util import resize_image, HWC3 from cldm.model import create_model, load_state_dict from cldm.ddim_hacked import DDIMSampler model...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/tool_add_control_sd21.py
tool_add_control_sd21.py
import sys import os assert len(sys.argv) == 3, 'Args are wrong.' input_path = sys.argv[1] output_path = sys.argv[2] assert os.path.exists(input_path), 'Input model does not exist.' assert not os.path.exists(output_path), 'Output filename already exists.' assert os.path.exists(os.path.dirname(output_path)), 'Output ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/tutorial_dataset.py
tutorial_dataset.py
import json import cv2 import numpy as np from torch.utils.data import Dataset class MyDataset(Dataset): def __init__(self): self.data = [] with open('./training/fill50k/prompt.json', 'rt') as f: for line in f: self.data.append(json.loads(line)) def __len__(self):...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/gradio_seg2image.py
gradio_seg2image.py
from share import * import config import cv2 import einops import gradio as gr import numpy as np import torch import random from pytorch_lightning import seed_everything from annotator.util import resize_image, HWC3 from annotator.uniformer import UniformerDetector from cldm.model import create_model, load_state_dic...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/gradio_depth2image.py
gradio_depth2image.py
from share import * import config import cv2 import einops import gradio as gr import numpy as np import torch import random from pytorch_lightning import seed_everything from annotator.util import resize_image, HWC3 from annotator.midas import MidasDetector from cldm.model import create_model, load_state_dict from c...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/gradio_hed2image.py
gradio_hed2image.py
from share import * import config import cv2 import einops import gradio as gr import numpy as np import torch import random from pytorch_lightning import seed_everything from annotator.util import resize_image, HWC3 from annotator.hed import HEDdetector from cldm.model import create_model, load_state_dict from cldm....
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/tool_add_control.py
tool_add_control.py
import sys import os assert len(sys.argv) == 3, 'Args are wrong.' input_path = sys.argv[1] output_path = sys.argv[2] assert os.path.exists(input_path), 'Input model does not exist.' assert not os.path.exists(output_path), 'Output filename already exists.' assert os.path.exists(os.path.dirname(output_path)), 'Output ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/gradio_pose2image.py
gradio_pose2image.py
from share import * import config import cv2 import einops import gradio as gr import numpy as np import torch import random from pytorch_lightning import seed_everything from annotator.util import resize_image, HWC3 from annotator.openpose import OpenposeDetector from cldm.model import create_model, load_state_dict ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/config.py
config.py
save_memory = False
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/share.py
share.py
import config from cldm.hack import disable_verbosity, enable_sliced_attention disable_verbosity() if config.save_memory: enable_sliced_attention()
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/gradio_scribble2image_interactive.py
gradio_scribble2image_interactive.py
from share import * import config import cv2 import einops import gradio as gr import numpy as np import torch import random from pytorch_lightning import seed_everything from annotator.util import resize_image, HWC3 from cldm.model import create_model, load_state_dict from cldm.ddim_hacked import DDIMSampler model...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/tutorial_dataset_test.py
tutorial_dataset_test.py
from tutorial_dataset import MyDataset dataset = MyDataset() print(len(dataset)) item = dataset[1234] jpg = item['jpg'] txt = item['txt'] hint = item['hint'] print(txt) print(jpg.shape) print(hint.shape)
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/tutorial_train.py
tutorial_train.py
from share import * import pytorch_lightning as pl from torch.utils.data import DataLoader from tutorial_dataset import MyDataset from cldm.logger import ImageLogger from cldm.model import create_model, load_state_dict # Configs resume_path = './models/control_sd15_ini.ckpt' batch_size = 4 logger_freq = 300 learning...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/gradio_annotator.py
gradio_annotator.py
import gradio as gr from annotator.util import resize_image, HWC3 model_canny = None def canny(img, res, l, h): img = resize_image(HWC3(img), res) global model_canny if model_canny is None: from annotator.canny import CannyDetector model_canny = CannyDetector() result = model_canny(...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/util.py
annotator/util.py
import numpy as np import cv2 import os annotator_ckpts_path = os.path.join(os.path.dirname(__file__), 'ckpts') def HWC3(x): assert x.dtype == np.uint8 if x.ndim == 2: x = x[:, :, None] assert x.ndim == 3 H, W, C = x.shape assert C == 1 or C == 3 or C == 4 if C == 3: return x...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/mlsd/utils.py
annotator/mlsd/utils.py
''' modified by lihaoweicv pytorch version ''' ''' M-LSD Copyright 2021-present NAVER Corp. Apache License v2.0 ''' import os import numpy as np import cv2 import torch from torch.nn import functional as F def deccode_output_score_and_ptss(tpMap, topk_n = 200, ksize = 5): ''' tpMap: center: tpMap[1, ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/mlsd/__init__.py
annotator/mlsd/__init__.py
# MLSD Line Detection # From https://github.com/navervision/mlsd # Apache-2.0 license import cv2 import numpy as np import torch import os from einops import rearrange from .models.mbv2_mlsd_tiny import MobileV2_MLSD_Tiny from .models.mbv2_mlsd_large import MobileV2_MLSD_Large from .utils import pred_lines from anno...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/mlsd/models/mbv2_mlsd_tiny.py
annotator/mlsd/models/mbv2_mlsd_tiny.py
import os import sys import torch import torch.nn as nn import torch.utils.model_zoo as model_zoo from torch.nn import functional as F class BlockTypeA(nn.Module): def __init__(self, in_c1, in_c2, out_c1, out_c2, upscale = True): super(BlockTypeA, self).__init__() self.conv1 = nn.Sequential( ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/mlsd/models/mbv2_mlsd_large.py
annotator/mlsd/models/mbv2_mlsd_large.py
import os import sys import torch import torch.nn as nn import torch.utils.model_zoo as model_zoo from torch.nn import functional as F class BlockTypeA(nn.Module): def __init__(self, in_c1, in_c2, out_c1, out_c2, upscale = True): super(BlockTypeA, self).__init__() self.conv1 = nn.Sequential( ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/hed/__init__.py
annotator/hed/__init__.py
# This is an improved version and model of HED edge detection with Apache License, Version 2.0. # Please use this implementation in your products # This implementation may produce slightly different results from Saining Xie's official implementations, # but it generates smoother edges and is more suitable for ControlNe...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/midas/api.py
annotator/midas/api.py
# based on https://github.com/isl-org/MiDaS import cv2 import os import torch import torch.nn as nn from torchvision.transforms import Compose from .midas.dpt_depth import DPTDepthModel from .midas.midas_net import MidasNet from .midas.midas_net_custom import MidasNet_small from .midas.transforms import Resize, Norma...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/midas/utils.py
annotator/midas/utils.py
"""Utils for monoDepth.""" import sys import re import numpy as np import cv2 import torch def read_pfm(path): """Read pfm file. Args: path (str): path to file Returns: tuple: (data, scale) """ with open(path, "rb") as file: color = None width = None heig...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/midas/__init__.py
annotator/midas/__init__.py
# Midas Depth Estimation # From https://github.com/isl-org/MiDaS # MIT LICENSE import cv2 import numpy as np import torch from einops import rearrange from .api import MiDaSInference class MidasDetector: def __init__(self): self.model = MiDaSInference(model_type="dpt_hybrid").cuda() def __call__(se...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/midas/midas/midas_net_custom.py
annotator/midas/midas/midas_net_custom.py
"""MidashNet: Network for monocular depth estimation trained by mixing several datasets. This file contains code that is adapted from https://github.com/thomasjpfan/pytorch_refinenet/blob/master/pytorch_refinenet/refinenet/refinenet_4cascade.py """ import torch import torch.nn as nn from .base_model import BaseModel f...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/midas/midas/base_model.py
annotator/midas/midas/base_model.py
import torch class BaseModel(torch.nn.Module): def load(self, path): """Load model from file. Args: path (str): file path """ parameters = torch.load(path, map_location=torch.device('cpu')) if "optimizer" in parameters: parameters = parameters["mod...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/midas/midas/dpt_depth.py
annotator/midas/midas/dpt_depth.py
import torch import torch.nn as nn import torch.nn.functional as F from .base_model import BaseModel from .blocks import ( FeatureFusionBlock, FeatureFusionBlock_custom, Interpolate, _make_encoder, forward_vit, ) def _make_fusion_block(features, use_bn): return FeatureFusionBlock_custom( ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/midas/midas/blocks.py
annotator/midas/midas/blocks.py
import torch import torch.nn as nn from .vit import ( _make_pretrained_vitb_rn50_384, _make_pretrained_vitl16_384, _make_pretrained_vitb16_384, forward_vit, ) def _make_encoder(backbone, features, use_pretrained, groups=1, expand=False, exportable=True, hooks=None, use_vit_only=False, use_readout="ign...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/midas/midas/midas_net.py
annotator/midas/midas/midas_net.py
"""MidashNet: Network for monocular depth estimation trained by mixing several datasets. This file contains code that is adapted from https://github.com/thomasjpfan/pytorch_refinenet/blob/master/pytorch_refinenet/refinenet/refinenet_4cascade.py """ import torch import torch.nn as nn from .base_model import BaseModel f...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/midas/midas/vit.py
annotator/midas/midas/vit.py
import torch import torch.nn as nn import timm import types import math import torch.nn.functional as F class Slice(nn.Module): def __init__(self, start_index=1): super(Slice, self).__init__() self.start_index = start_index def forward(self, x): return x[:, self.start_index :] class...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/midas/midas/__init__.py
annotator/midas/midas/__init__.py
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/midas/midas/transforms.py
annotator/midas/midas/transforms.py
import numpy as np import cv2 import math def apply_min_size(sample, size, image_interpolation_method=cv2.INTER_AREA): """Rezise the sample to ensure the given size. Keeps aspect ratio. Args: sample (dict): sample size (tuple): image size Returns: tuple: new size """ shap...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/openpose/hand.py
annotator/openpose/hand.py
import cv2 import json import numpy as np import math import time from scipy.ndimage.filters import gaussian_filter import matplotlib.pyplot as plt import matplotlib import torch from skimage.measure import label from .model import handpose_model from . import util class Hand(object): def __init__(self, model_pat...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/openpose/util.py
annotator/openpose/util.py
import math import numpy as np import matplotlib import cv2 def padRightDownCorner(img, stride, padValue): h = img.shape[0] w = img.shape[1] pad = 4 * [None] pad[0] = 0 # up pad[1] = 0 # left pad[2] = 0 if (h % stride == 0) else stride - (h % stride) # down pad[3] = 0 if (w % stride == 0)...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/openpose/model.py
annotator/openpose/model.py
import torch from collections import OrderedDict import torch import torch.nn as nn def make_layers(block, no_relu_layers): layers = [] for layer_name, v in block.items(): if 'pool' in layer_name: layer = nn.MaxPool2d(kernel_size=v[0], stride=v[1], paddi...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/openpose/__init__.py
annotator/openpose/__init__.py
# Openpose # Original from CMU https://github.com/CMU-Perceptual-Computing-Lab/openpose # 2nd Edited by https://github.com/Hzzone/pytorch-openpose # 3rd Edited by ControlNet import os os.environ["KMP_DUPLICATE_LIB_OK"]="TRUE" import torch import numpy as np from . import util from .body import Body from .hand import ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/openpose/body.py
annotator/openpose/body.py
import cv2 import numpy as np import math import time from scipy.ndimage.filters import gaussian_filter import matplotlib.pyplot as plt import matplotlib import torch from torchvision import transforms from . import util from .model import bodypose_model class Body(object): def __init__(self, model_path): ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/__init__.py
annotator/uniformer/__init__.py
# Uniformer # From https://github.com/Sense-X/UniFormer # # Apache-2.0 license import os from annotator.uniformer.mmseg.apis import init_segmentor, inference_segmentor, show_result_pyplot from annotator.uniformer.mmseg.core.evaluation import get_palette from annotator.util import annotator_ckpts_path checkpoint_fil...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/exp/upernet_global_small/test_config_w32.py
annotator/uniformer/exp/upernet_global_small/test_config_w32.py
_base_ = [ '../../configs/_base_/models/upernet_uniformer.py', '../../configs/_base_/datasets/ade20k.py', '../../configs/_base_/default_runtime.py', '../../configs/_base_/schedules/schedule_160k.py' ] model = dict( backbone=dict( type='UniFormer', embed_dim=[64, 128, 320, 512], ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/exp/upernet_global_small/test_config_h32.py
annotator/uniformer/exp/upernet_global_small/test_config_h32.py
_base_ = [ '../../configs/_base_/models/upernet_uniformer.py', '../../configs/_base_/datasets/ade20k.py', '../../configs/_base_/default_runtime.py', '../../configs/_base_/schedules/schedule_160k.py' ] model = dict( backbone=dict( type='UniFormer', embed_dim=[64, 128, 320, 512], ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/exp/upernet_global_small/config.py
annotator/uniformer/exp/upernet_global_small/config.py
_base_ = [ '../../configs/_base_/models/upernet_uniformer.py', '../../configs/_base_/datasets/ade20k.py', '../../configs/_base_/default_runtime.py', '../../configs/_base_/schedules/schedule_160k.py' ] model = dict( backbone=dict( type='UniFormer', embed_dim=[64, 128, 320, 512], ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/exp/upernet_global_small/test_config_g.py
annotator/uniformer/exp/upernet_global_small/test_config_g.py
_base_ = [ '../../configs/_base_/models/upernet_uniformer.py', '../../configs/_base_/datasets/ade20k.py', '../../configs/_base_/default_runtime.py', '../../configs/_base_/schedules/schedule_160k.py' ] model = dict( backbone=dict( type='UniFormer', embed_dim=[64, 128, 320, 512], ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/datasets/hrf.py
annotator/uniformer/mmseg/datasets/hrf.py
import os.path as osp from .builder import DATASETS from .custom import CustomDataset @DATASETS.register_module() class HRFDataset(CustomDataset): """HRF dataset. In segmentation map annotation for HRF, 0 stands for background, which is included in 2 categories. ``reduce_zero_label`` is fixed to False. ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/datasets/drive.py
annotator/uniformer/mmseg/datasets/drive.py
import os.path as osp from .builder import DATASETS from .custom import CustomDataset @DATASETS.register_module() class DRIVEDataset(CustomDataset): """DRIVE dataset. In segmentation map annotation for DRIVE, 0 stands for background, which is included in 2 categories. ``reduce_zero_label`` is fixed to F...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/datasets/dataset_wrappers.py
annotator/uniformer/mmseg/datasets/dataset_wrappers.py
from torch.utils.data.dataset import ConcatDataset as _ConcatDataset from .builder import DATASETS @DATASETS.register_module() class ConcatDataset(_ConcatDataset): """A wrapper of concatenated dataset. Same as :obj:`torch.utils.data.dataset.ConcatDataset`, but concat the group flag for image aspect rati...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/datasets/voc.py
annotator/uniformer/mmseg/datasets/voc.py
import os.path as osp from .builder import DATASETS from .custom import CustomDataset @DATASETS.register_module() class PascalVOCDataset(CustomDataset): """Pascal VOC dataset. Args: split (str): Split txt file for Pascal VOC. """ CLASSES = ('background', 'aeroplane', 'bicycle', 'bird', 'boa...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/datasets/stare.py
annotator/uniformer/mmseg/datasets/stare.py
import os.path as osp from .builder import DATASETS from .custom import CustomDataset @DATASETS.register_module() class STAREDataset(CustomDataset): """STARE dataset. In segmentation map annotation for STARE, 0 stands for background, which is included in 2 categories. ``reduce_zero_label`` is fixed to F...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/datasets/chase_db1.py
annotator/uniformer/mmseg/datasets/chase_db1.py
import os.path as osp from .builder import DATASETS from .custom import CustomDataset @DATASETS.register_module() class ChaseDB1Dataset(CustomDataset): """Chase_db1 dataset. In segmentation map annotation for Chase_db1, 0 stands for background, which is included in 2 categories. ``reduce_zero_label`` is...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/datasets/cityscapes.py
annotator/uniformer/mmseg/datasets/cityscapes.py
import os.path as osp import tempfile import annotator.uniformer.mmcv as mmcv import numpy as np from annotator.uniformer.mmcv.utils import print_log from PIL import Image from .builder import DATASETS from .custom import CustomDataset @DATASETS.register_module() class CityscapesDataset(CustomDataset): """Citys...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/datasets/__init__.py
annotator/uniformer/mmseg/datasets/__init__.py
from .ade import ADE20KDataset from .builder import DATASETS, PIPELINES, build_dataloader, build_dataset from .chase_db1 import ChaseDB1Dataset from .cityscapes import CityscapesDataset from .custom import CustomDataset from .dataset_wrappers import ConcatDataset, RepeatDataset from .drive import DRIVEDataset from .hrf...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/datasets/pascal_context.py
annotator/uniformer/mmseg/datasets/pascal_context.py
import os.path as osp from .builder import DATASETS from .custom import CustomDataset @DATASETS.register_module() class PascalContextDataset(CustomDataset): """PascalContext dataset. In segmentation map annotation for PascalContext, 0 stands for background, which is included in 60 categories. ``reduce_z...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/datasets/builder.py
annotator/uniformer/mmseg/datasets/builder.py
import copy import platform import random from functools import partial import numpy as np from annotator.uniformer.mmcv.parallel import collate from annotator.uniformer.mmcv.runner import get_dist_info from annotator.uniformer.mmcv.utils import Registry, build_from_cfg from annotator.uniformer.mmcv.utils.parrots_wrap...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/datasets/custom.py
annotator/uniformer/mmseg/datasets/custom.py
import os import os.path as osp from collections import OrderedDict from functools import reduce import annotator.uniformer.mmcv as mmcv import numpy as np from annotator.uniformer.mmcv.utils import print_log from prettytable import PrettyTable from torch.utils.data import Dataset from annotator.uniformer.mmseg.core ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/datasets/ade.py
annotator/uniformer/mmseg/datasets/ade.py
from .builder import DATASETS from .custom import CustomDataset @DATASETS.register_module() class ADE20KDataset(CustomDataset): """ADE20K dataset. In segmentation map annotation for ADE20K, 0 stands for background, which is not included in 150 categories. ``reduce_zero_label`` is fixed to True. The `...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/datasets/pipelines/compose.py
annotator/uniformer/mmseg/datasets/pipelines/compose.py
import collections from annotator.uniformer.mmcv.utils import build_from_cfg from ..builder import PIPELINES @PIPELINES.register_module() class Compose(object): """Compose multiple transforms sequentially. Args: transforms (Sequence[dict | callable]): Sequence of transform object or con...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/datasets/pipelines/formating.py
annotator/uniformer/mmseg/datasets/pipelines/formating.py
from collections.abc import Sequence import annotator.uniformer.mmcv as mmcv import numpy as np import torch from annotator.uniformer.mmcv.parallel import DataContainer as DC from ..builder import PIPELINES def to_tensor(data): """Convert objects of various python types to :obj:`torch.Tensor`. Supported ty...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/datasets/pipelines/loading.py
annotator/uniformer/mmseg/datasets/pipelines/loading.py
import os.path as osp import annotator.uniformer.mmcv as mmcv import numpy as np from ..builder import PIPELINES @PIPELINES.register_module() class LoadImageFromFile(object): """Load an image from file. Required keys are "img_prefix" and "img_info" (a dict that must contain the key "filename"). Added o...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/datasets/pipelines/__init__.py
annotator/uniformer/mmseg/datasets/pipelines/__init__.py
from .compose import Compose from .formating import (Collect, ImageToTensor, ToDataContainer, ToTensor, Transpose, to_tensor) from .loading import LoadAnnotations, LoadImageFromFile from .test_time_aug import MultiScaleFlipAug from .transforms import (CLAHE, AdjustGamma, Normalize, Pad, ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/datasets/pipelines/test_time_aug.py
annotator/uniformer/mmseg/datasets/pipelines/test_time_aug.py
import warnings import annotator.uniformer.mmcv as mmcv from ..builder import PIPELINES from .compose import Compose @PIPELINES.register_module() class MultiScaleFlipAug(object): """Test-time augmentation with multiple scales and flipping. An example configuration is as followed: .. code-block:: ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/datasets/pipelines/transforms.py
annotator/uniformer/mmseg/datasets/pipelines/transforms.py
import annotator.uniformer.mmcv as mmcv import numpy as np from annotator.uniformer.mmcv.utils import deprecated_api_warning, is_tuple_of from numpy import random from ..builder import PIPELINES @PIPELINES.register_module() class Resize(object): """Resize images & seg. This transform resizes the input image...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/__init__.py
annotator/uniformer/mmseg/models/__init__.py
from .backbones import * # noqa: F401,F403 from .builder import (BACKBONES, HEADS, LOSSES, SEGMENTORS, build_backbone, build_head, build_loss, build_segmentor) from .decode_heads import * # noqa: F401,F403 from .losses import * # noqa: F401,F403 from .necks import * # noqa: F401,F403 from .seg...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/builder.py
annotator/uniformer/mmseg/models/builder.py
import warnings from annotator.uniformer.mmcv.cnn import MODELS as MMCV_MODELS from annotator.uniformer.mmcv.utils import Registry MODELS = Registry('models', parent=MMCV_MODELS) BACKBONES = MODELS NECKS = MODELS HEADS = MODELS LOSSES = MODELS SEGMENTORS = MODELS def build_backbone(cfg): """Build backbone.""" ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/losses/accuracy.py
annotator/uniformer/mmseg/models/losses/accuracy.py
import torch.nn as nn 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, , ...) topk (...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/losses/cross_entropy_loss.py
annotator/uniformer/mmseg/models/losses/cross_entropy_loss.py
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', ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/losses/utils.py
annotator/uniformer/mmseg/models/losses/utils.py
import functools import annotator.uniformer.mmcv as mmcv import numpy as np import torch.nn.functional as F 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 ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/losses/dice_loss.py
annotator/uniformer/mmseg/models/losses/dice_loss.py
"""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 from ..builder import LOSSES from .utils import get_class_weight, weighted_loss @weighted_loss def dice_loss(pred, ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/losses/__init__.py
annotator/uniformer/mmseg/models/losses/__init__.py
from .accuracy import Accuracy, accuracy from .cross_entropy_loss import (CrossEntropyLoss, binary_cross_entropy, cross_entropy, mask_cross_entropy) from .dice_loss import DiceLoss from .lovasz_loss import LovaszLoss from .utils import reduce_loss, weight_reduce_loss, weighted_loss __a...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/losses/lovasz_loss.py
annotator/uniformer/mmseg/models/losses/lovasz_loss.py
"""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.uniformer.mmcv as mmcv import torch import torch.nn as nn import torch.nn.functional as F from ..b...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/decode_heads/dnl_head.py
annotator/uniformer/mmseg/models/decode_heads/dnl_head.py
import torch from annotator.uniformer.mmcv.cnn import NonLocal2d from torch import nn from ..builder import HEADS from .fcn_head import FCNHead class DisentangledNonLocal2d(NonLocal2d): """Disentangled Non-Local Blocks. Args: temperature (float): Temperature to adjust attention. Default: 0.05 ""...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/decode_heads/dm_head.py
annotator/uniformer/mmseg/models/decode_heads/dm_head.py
import torch import torch.nn as nn import torch.nn.functional as F from annotator.uniformer.mmcv.cnn import ConvModule, build_activation_layer, build_norm_layer from ..builder import HEADS from .decode_head import BaseDecodeHead class DCM(nn.Module): """Dynamic Convolutional Module used in DMNet. Args: ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/decode_heads/da_head.py
annotator/uniformer/mmseg/models/decode_heads/da_head.py
import torch import torch.nn.functional as F from annotator.uniformer.mmcv.cnn import ConvModule, Scale from torch import nn from annotator.uniformer.mmseg.core import add_prefix from ..builder import HEADS from ..utils import SelfAttentionBlock as _SelfAttentionBlock from .decode_head import BaseDecodeHead class PA...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/decode_heads/ocr_head.py
annotator/uniformer/mmseg/models/decode_heads/ocr_head.py
import torch import torch.nn as nn import torch.nn.functional as F from annotator.uniformer.mmcv.cnn import ConvModule from annotator.uniformer.mmseg.ops import resize from ..builder import HEADS from ..utils import SelfAttentionBlock as _SelfAttentionBlock from .cascade_decode_head import BaseCascadeDecodeHead clas...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/decode_heads/enc_head.py
annotator/uniformer/mmseg/models/decode_heads/enc_head.py
import torch import torch.nn as nn import torch.nn.functional as F from annotator.uniformer.mmcv.cnn import ConvModule, build_norm_layer from annotator.uniformer.mmseg.ops import Encoding, resize from ..builder import HEADS, build_loss from .decode_head import BaseDecodeHead class EncModule(nn.Module): """Encodi...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/decode_heads/point_head.py
annotator/uniformer/mmseg/models/decode_heads/point_head.py
# Modified from https://github.com/facebookresearch/detectron2/tree/master/projects/PointRend/point_head/point_head.py # noqa import torch import torch.nn as nn from annotator.uniformer.mmcv.cnn import ConvModule, normal_init from annotator.uniformer.mmcv.ops import point_sample from annotator.uniformer.mmseg.models...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/decode_heads/uper_head.py
annotator/uniformer/mmseg/models/decode_heads/uper_head.py
import torch import torch.nn as nn from annotator.uniformer.mmcv.cnn import ConvModule from annotator.uniformer.mmseg.ops import resize from ..builder import HEADS from .decode_head import BaseDecodeHead from .psp_head import PPM @HEADS.register_module() class UPerHead(BaseDecodeHead): """Unified Perceptual Pars...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/decode_heads/ann_head.py
annotator/uniformer/mmseg/models/decode_heads/ann_head.py
import torch import torch.nn as nn from annotator.uniformer.mmcv.cnn import ConvModule from ..builder import HEADS from ..utils import SelfAttentionBlock as _SelfAttentionBlock from .decode_head import BaseDecodeHead class PPMConcat(nn.ModuleList): """Pyramid Pooling Module that only concat the features of each ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/decode_heads/nl_head.py
annotator/uniformer/mmseg/models/decode_heads/nl_head.py
import torch from annotator.uniformer.mmcv.cnn import NonLocal2d from ..builder import HEADS from .fcn_head import FCNHead @HEADS.register_module() class NLHead(FCNHead): """Non-local Neural Networks. This head is the implementation of `NLNet <https://arxiv.org/abs/1711.07971>`_. Args: redu...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/decode_heads/ema_head.py
annotator/uniformer/mmseg/models/decode_heads/ema_head.py
import math import torch import torch.distributed as dist import torch.nn as nn import torch.nn.functional as F from annotator.uniformer.mmcv.cnn import ConvModule from ..builder import HEADS from .decode_head import BaseDecodeHead def reduce_mean(tensor): """Reduce mean when distributed training.""" if not...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/decode_heads/fpn_head.py
annotator/uniformer/mmseg/models/decode_heads/fpn_head.py
import numpy as np import torch.nn as nn from annotator.uniformer.mmcv.cnn import ConvModule from annotator.uniformer.mmseg.ops import resize from ..builder import HEADS from .decode_head import BaseDecodeHead @HEADS.register_module() class FPNHead(BaseDecodeHead): """Panoptic Feature Pyramid Networks. This...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/decode_heads/psa_head.py
annotator/uniformer/mmseg/models/decode_heads/psa_head.py
import torch import torch.nn as nn import torch.nn.functional as F from annotator.uniformer.mmcv.cnn import ConvModule from annotator.uniformer.mmseg.ops import resize from ..builder import HEADS from .decode_head import BaseDecodeHead try: from annotator.uniformer.mmcv.ops import PSAMask except ModuleNotFoundErr...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/decode_heads/aspp_head.py
annotator/uniformer/mmseg/models/decode_heads/aspp_head.py
import torch import torch.nn as nn from annotator.uniformer.mmcv.cnn import ConvModule from annotator.uniformer.mmseg.ops import resize from ..builder import HEADS from .decode_head import BaseDecodeHead class ASPPModule(nn.ModuleList): """Atrous Spatial Pyramid Pooling (ASPP) Module. Args: dilation...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/decode_heads/sep_fcn_head.py
annotator/uniformer/mmseg/models/decode_heads/sep_fcn_head.py
from annotator.uniformer.mmcv.cnn import DepthwiseSeparableConvModule from ..builder import HEADS from .fcn_head import FCNHead @HEADS.register_module() class DepthwiseSeparableFCNHead(FCNHead): """Depthwise-Separable Fully Convolutional Network for Semantic Segmentation. This head is implemented accord...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/decode_heads/lraspp_head.py
annotator/uniformer/mmseg/models/decode_heads/lraspp_head.py
import torch import torch.nn as nn from annotator.uniformer.mmcv import is_tuple_of from annotator.uniformer.mmcv.cnn import ConvModule from annotator.uniformer.mmseg.ops import resize from ..builder import HEADS from .decode_head import BaseDecodeHead @HEADS.register_module() class LRASPPHead(BaseDecodeHead): "...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/decode_heads/gc_head.py
annotator/uniformer/mmseg/models/decode_heads/gc_head.py
import torch from annotator.uniformer.mmcv.cnn import ContextBlock from ..builder import HEADS from .fcn_head import FCNHead @HEADS.register_module() class GCHead(FCNHead): """GCNet: Non-local Networks Meet Squeeze-Excitation Networks and Beyond. This head is the implementation of `GCNet <https://arxiv....
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/decode_heads/psp_head.py
annotator/uniformer/mmseg/models/decode_heads/psp_head.py
import torch import torch.nn as nn from annotator.uniformer.mmcv.cnn import ConvModule from annotator.uniformer.mmseg.ops import resize from ..builder import HEADS from .decode_head import BaseDecodeHead class PPM(nn.ModuleList): """Pooling Pyramid Module used in PSPNet. Args: pool_scales (tuple[int...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/decode_heads/sep_aspp_head.py
annotator/uniformer/mmseg/models/decode_heads/sep_aspp_head.py
import torch import torch.nn as nn from annotator.uniformer.mmcv.cnn import ConvModule, DepthwiseSeparableConvModule from annotator.uniformer.mmseg.ops import resize from ..builder import HEADS from .aspp_head import ASPPHead, ASPPModule class DepthwiseSeparableASPPModule(ASPPModule): """Atrous Spatial Pyramid P...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/decode_heads/apc_head.py
annotator/uniformer/mmseg/models/decode_heads/apc_head.py
import torch import torch.nn as nn import torch.nn.functional as F from annotator.uniformer.mmcv.cnn import ConvModule from annotator.uniformer.mmseg.ops import resize from ..builder import HEADS from .decode_head import BaseDecodeHead class ACM(nn.Module): """Adaptive Context Module used in APCNet. Args: ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/decode_heads/cascade_decode_head.py
annotator/uniformer/mmseg/models/decode_heads/cascade_decode_head.py
from abc import ABCMeta, abstractmethod from .decode_head import BaseDecodeHead class BaseCascadeDecodeHead(BaseDecodeHead, metaclass=ABCMeta): """Base class for cascade decode head used in :class:`CascadeEncoderDecoder.""" def __init__(self, *args, **kwargs): super(BaseCascadeDecodeHead, self)....
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/decode_heads/fcn_head.py
annotator/uniformer/mmseg/models/decode_heads/fcn_head.py
import torch import torch.nn as nn from annotator.uniformer.mmcv.cnn import ConvModule from ..builder import HEADS from .decode_head import BaseDecodeHead @HEADS.register_module() class FCNHead(BaseDecodeHead): """Fully Convolution Networks for Semantic Segmentation. This head is implemented of `FCNNet <htt...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/decode_heads/__init__.py
annotator/uniformer/mmseg/models/decode_heads/__init__.py
from .ann_head import ANNHead from .apc_head import APCHead from .aspp_head import ASPPHead from .cc_head import CCHead from .da_head import DAHead from .dm_head import DMHead from .dnl_head import DNLHead from .ema_head import EMAHead from .enc_head import EncHead from .fcn_head import FCNHead from .fpn_head import FP...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false
lllyasviel/ControlNet
https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/annotator/uniformer/mmseg/models/decode_heads/cc_head.py
annotator/uniformer/mmseg/models/decode_heads/cc_head.py
import torch from ..builder import HEADS from .fcn_head import FCNHead try: from annotator.uniformer.mmcv.ops import CrissCrossAttention except ModuleNotFoundError: CrissCrossAttention = None @HEADS.register_module() class CCHead(FCNHead): """CCNet: Criss-Cross Attention for Semantic Segmentation. ...
python
Apache-2.0
ed85cd1e25a5ed592f7d8178495b4483de0331bf
2026-01-04T14:42:42.940079Z
false