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 |
|---|---|---|---|---|---|---|---|---|
QWTforGithub/CDSegNet | https://github.com/QWTforGithub/CDSegNet/blob/87b603dbd011c0f57fb498d70680e32d4f8cf2f0/libs/pointops/functions/attention.py | libs/pointops/functions/attention.py | import torch
from torch.autograd import Function
from pointops._C import (
attention_relation_step_forward_cuda,
attention_relation_step_backward_cuda,
attention_fusion_step_forward_cuda,
attention_fusion_step_backward_cuda,
)
class AttentionRelationStep(Function):
@staticmethod
def forward(c... | python | MIT | 87b603dbd011c0f57fb498d70680e32d4f8cf2f0 | 2026-01-05T07:13:40.759144Z | false |
QWTforGithub/CDSegNet | https://github.com/QWTforGithub/CDSegNet/blob/87b603dbd011c0f57fb498d70680e32d4f8cf2f0/libs/pointops/functions/aggregation.py | libs/pointops/functions/aggregation.py | import torch
from torch.autograd import Function
from pointops._C import aggregation_forward_cuda, aggregation_backward_cuda
class Aggregation(Function):
@staticmethod
def forward(ctx, input, position, weight, idx):
"""
input: input: (n, c), position: (n, nsample, c), weight : (n, nsample, c'... | python | MIT | 87b603dbd011c0f57fb498d70680e32d4f8cf2f0 | 2026-01-05T07:13:40.759144Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/train_net.py | train_net.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
"""
This script is a simplified version of the training script in detectron2/tools.
"""
from functools import partial
import copy
import itertools
import logging
import os
from collections import OrderedDict
from typing import Any, Dict, List, Set
... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/third_party/CLIP/setup.py | third_party/CLIP/setup.py | import os
import pkg_resources
from setuptools import setup, find_packages
setup(
name="clip",
py_modules=["clip"],
version="1.0",
description="",
author="OpenAI",
packages=find_packages(exclude=["tests*"]),
install_requires=[
str(r)
for r in pkg_resources.parse_requirement... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/third_party/CLIP/tests/test_consistency.py | third_party/CLIP/tests/test_consistency.py | import numpy as np
import pytest
import torch
from PIL import Image
import clip
@pytest.mark.parametrize("model_name", clip.available_models())
def test_consistency(model_name):
device = "cpu"
jit_model, transform = clip.load(model_name, device=device, jit=True)
py_model, _ = clip.load(model_name, device... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/third_party/CLIP/clip/model.py | third_party/CLIP/clip/model.py | from collections import OrderedDict
from typing import Tuple, Union
from scipy import interpolate
import numpy as np
import torch
import torch.nn.functional as F
from torch import nn
class Bottleneck(nn.Module):
expansion = 4
def __init__(self, inplanes, planes, stride=1):
super().__init__()
... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/third_party/CLIP/clip/simple_tokenizer.py | third_party/CLIP/clip/simple_tokenizer.py | import gzip
import html
import os
from functools import lru_cache
import ftfy
import regex as re
@lru_cache()
def default_bpe():
return os.path.join(
os.path.dirname(os.path.abspath(__file__)), "bpe_simple_vocab_16e6.txt.gz"
)
@lru_cache()
def bytes_to_unicode():
"""
Returns list of utf-8 b... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/third_party/CLIP/clip/__init__.py | third_party/CLIP/clip/__init__.py | from .clip import *
| python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/third_party/CLIP/clip/clip.py | third_party/CLIP/clip/clip.py | import hashlib
import os
import urllib
import warnings
from typing import Union, List
import torch
from PIL import Image
from torchvision.transforms import Compose, Resize, CenterCrop, ToTensor, Normalize
from tqdm import tqdm
from .model import build_model
from .simple_tokenizer import SimpleTokenizer as _Tokenizer
... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/tools/parse_name.py | tools/parse_name.py | import sys
cfg_path = sys.argv[1]
print(cfg_path.split(".")[0].replace("/", "_"))
| python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/tools/convert-torchvision-to-d2.py | tools/convert-torchvision-to-d2.py | #!/usr/bin/env python
# Copyright (c) Facebook, Inc. and its affiliates.
import pickle as pkl
import sys
import torch
"""
Usage:
# download one of the ResNet{18,34,50,101,152} models from torchvision:
wget https://download.pytorch.org/models/resnet50-19c8e357.pth -O r50.pth
# run the conversion
./convert-tor... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/tools/mask_cls_collect.py | tools/mask_cls_collect.py | import os
import glob
import functools
from mmcv.utils import track_parallel_progress
import numpy as np
from PIL import Image
import json
import warnings
import fire
from itertools import chain
def count_cls(file_path, ignore_index=[255], depth=1):
cls_label = np.unique(np.asarray(Image.open(file_path))).tolist(... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/tools/convert-pretrained-clip-model-to-d2.py | tools/convert-pretrained-clip-model-to-d2.py | #!/usr/bin/env python
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import pickle as pkl
import sys
import torch
"""
Usage:
# download pretrained swin model:
wget https://github.com/SwinTransformer/storage/releases/download/v1.0.0/swin_tiny_patch4_window7_224.pth
# run the conversion
... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/tools/convert-pretrained-swin-model-to-d2.py | tools/convert-pretrained-swin-model-to-d2.py | #!/usr/bin/env python
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import pickle as pkl
import sys
import torch
"""
Usage:
# download pretrained swin model:
wget https://github.com/SwinTransformer/storage/releases/download/v1.0.0/swin_tiny_patch4_window7_224.pth
# run the conversion
... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/datasets/prepare_coco_alldata.py | datasets/prepare_coco_alldata.py | import argparse
import os
import os.path as osp
import json
import copy
import shutil
from functools import partial
from glob import glob
from panopticapi.utils import rgb2id, id2rgb
import mmcv
import numpy as np
from PIL import Image
import torch
from detectron2.structures import Boxes, ImageList, Instances, BitMa... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/datasets/prepare_ade20k_pan_seg_novel.py | datasets/prepare_ade20k_pan_seg_novel.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (c) Facebook, Inc. and its affiliates.
import glob
import json
import os
from collections import Counter
import numpy as np
import tqdm
from panopticapi.utils import IdGenerator, save_json
from PIL import Image
ADE20K_SEM_SEG_CATEGORIES = [
"wall",
"b... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/datasets/prepare_ade20k_sem_seg_novel.py | datasets/prepare_ade20k_sem_seg_novel.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (c) Facebook, Inc. and its affiliates.
import os
from pathlib import Path
import numpy as np
import tqdm
from PIL import Image
ALL_ID = [i for i in range(150)]
NOVEL_ID = [9, 15, 30, 37, 49, 60, 74, 81, 89, 99, 112, 128, 136, 143, 149]
BASE_ID = [i for i in A... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/datasets/prepare_voc_sem_seg.py | datasets/prepare_voc_sem_seg.py | import argparse
import os
import os.path as osp
import shutil
from functools import partial
from glob import glob
import mmcv
import numpy as np
from PIL import Image
full_clsID_to_trID = {
0: 255,
1: 0,
2: 1,
3: 2,
4: 3,
5: 4,
6: 5,
7: 6,
8: 7,
9: 8,
10: 9,
11: 10,
... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/datasets/prepare_ade20k_ins_seg_novel.py | datasets/prepare_ade20k_ins_seg_novel.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (c) Facebook, Inc. and its affiliates.
import glob
import json
import os
from collections import Counter
import numpy as np
import tqdm
from panopticapi.utils import IdGenerator, save_json
from PIL import Image
import pycocotools.mask as mask_util
ALL_ID = [i... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/datasets/prepare_coco_stuff_164k_sem_seg.py | datasets/prepare_coco_stuff_164k_sem_seg.py | import argparse
import os
import os.path as osp
import shutil
from functools import partial
from glob import glob
import mmcv
import numpy as np
from PIL import Image
COCO_LEN = 123287
full_clsID_to_trID = {
0: 0,
1: 1,
2: 2,
3: 3,
4: 4,
5: 5,
6: 6,
7: 7,
8: 8,
9: 9,
10: 1... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/open_vocabulary_model.py | mask2former/open_vocabulary_model.py | # Copyright (c) Facebook, Inc. and its affiliates.
from cgitb import text
import logging
import copy
import random
import os
from typing import Tuple
from PIL import Image
import numpy as np
import torch
from torch import nn
from torch.nn import functional as F
from detectron2.config import configurable
from detectro... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/proposal_classification.py | mask2former/proposal_classification.py | # Copyright (c) Facebook, Inc. and its affiliates.
import logging
import torch
import numpy as np
from detectron2.config import configurable
from detectron2.data import MetadataCatalog
from detectron2.modeling import META_ARCH_REGISTRY
from detectron2.utils.logger import log_every_n, log_first_n
from detectron2.utils.... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/config.py | mask2former/config.py | # -*- coding: utf-8 -*-
# Copyright (c) Facebook, Inc. and its affiliates.
from detectron2.config import CfgNode as CN
def add_mask_former_default_config(cfg):
# data config
# select the dataset mapper
cfg.INPUT.DATASET_MAPPER_NAME = "mask_former_semantic"
# Color augmentation
cfg.INPUT.COLOR_AUG_... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/__init__.py | mask2former/__init__.py | from . import data
from . import modeling
from .config import add_mask_former_config
from .test_time_augmentation import SemanticSegmentorWithTTA
from .mask_former_model import MaskFormer
from .open_vocabulary_model import OpenVocabulary
from .proposal_classification import ProposalClipClassifier
| python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/mask_former_model.py | mask2former/mask_former_model.py | # Copyright (c) Facebook, Inc. and its affiliates.
from typing import Tuple
import torch
from torch import nn
from torch.nn import functional as F
from detectron2.config import configurable
from detectron2.data import MetadataCatalog
from detectron2.modeling import META_ARCH_REGISTRY, build_backbone, build_sem_seg_he... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/test_time_augmentation.py | mask2former/test_time_augmentation.py | # Copyright (c) Facebook, Inc. and its affiliates.
import copy
from itertools import count
import math
import numpy as np
import torch
from fvcore.transforms import HFlipTransform
from torch import nn
from torch.nn.parallel import DistributedDataParallel
from detectron2.data.detection_utils import read_image
from dete... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/utils/selective_search.py | mask2former/utils/selective_search.py | # Modified from https://github.com/ranchirino/segmentation-as-selective-search/blob/master/selective_search.py
import numpy as np
from skimage import segmentation
from skimage.feature import local_binary_pattern
from skimage.color import rgb2hsv
from sklearn.preprocessing import normalize
from scipy.ndimage.morphology ... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/utils/post_process_utils.py | mask2former/utils/post_process_utils.py | import torch
from torch.nn import functional as F
import numpy as np
try:
import pydensecrf.densecrf as dcrf
from pydensecrf.utils import (
unary_from_softmax,
unary_from_labels,
create_pairwise_bilateral,
create_pairwise_gaussian,
)
except:
dcrf = None
def dense_crf_p... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/utils/events.py | mask2former/utils/events.py | import os
import wandb
from detectron2.utils import comm
from detectron2.utils.events import EventWriter, get_event_storage
def setup_wandb(cfg, args):
if comm.is_main_process():
init_args = {
k.lower(): v
for k, v in cfg.WANDB.items()
if isinstance(k, str) and k not in... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/utils/misc.py | mask2former/utils/misc.py | # Copyright (c) Facebook, Inc. and its affiliates.
# Modified by Bowen Cheng from https://github.com/facebookresearch/detr/blob/master/util/misc.py
"""
Misc functions, including distributed helpers.
Mostly copy-paste from torchvision references.
"""
from typing import List, Optional
import torch
import torch.distribu... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/utils/__init__.py | mask2former/utils/__init__.py | # Copyright (c) Facebook, Inc. and its affiliates.
from .events import setup_wandb, WandbWriter
| python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/modeling/criterion.py | mask2former/modeling/criterion.py | # Copyright (c) Facebook, Inc. and its affiliates.
# Modified by Bowen Cheng from https://github.com/facebookresearch/detr/blob/master/models/detr.py
"""
MaskFormer criterion.
"""
import torch
import torch.nn.functional as F
from torch import nn
from detectron2.utils.comm import get_world_size
from ..utils.misc impor... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/modeling/matcher.py | mask2former/modeling/matcher.py | # Copyright (c) Facebook, Inc. and its affiliates.
# Modified by Bowen Cheng from https://github.com/facebookresearch/detr/blob/master/models/matcher.py
"""
Modules to compute the matching cost and solve the corresponding LSAP.
"""
import torch
import torch.nn.functional as F
from scipy.optimize import linear_sum_assig... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/modeling/__init__.py | mask2former/modeling/__init__.py | # Copyright (c) Facebook, Inc. and its affiliates.
from .backbone.swin import D2SwinTransformer
from .backbone.clip_resnet import D2ModifiedResNet
from .heads.mask_former_head import MaskFormerHead
from .heads.mask_former_interaction_head import MaskFormerInteractionHead
from .heads.per_pixel_baseline import (
PerP... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/modeling/heads/mask_former_interaction_head.py | mask2former/modeling/heads/mask_former_interaction_head.py | # Copyright (c) Facebook, Inc. and its affiliates.
import logging
from copy import deepcopy
from typing import Callable, Dict, List, 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 detectron2.config import configurable
from... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/modeling/heads/module.py | mask2former/modeling/heads/module.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from timm.models.layers import DropPath
class MultiHeadAttention(nn.Module):
"""
Multi-head attention module for both image and text
"""
def __init__(self, q_dim, k_dim, embed_dim, num_heads, dropout=0.1,
clamp_min_for_underf... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/modeling/heads/per_pixel_baseline.py | mask2former/modeling/heads/per_pixel_baseline.py | # Copyright (c) Facebook, Inc. and its affiliates.
import logging
from typing import Callable, Dict, List, Optional, Tuple, Union
import fvcore.nn.weight_init as weight_init
from torch import nn
from torch.nn import functional as F
from detectron2.config import configurable
from detectron2.layers import Conv2d, Shape... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/modeling/heads/msdeformattn.py | mask2former/modeling/heads/msdeformattn.py | # Copyright (c) Facebook, Inc. and its affiliates.
import logging
import numpy as np
from typing import Callable, Dict, List, 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 torch.nn.init import xavier_uniform_, constant_, u... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/modeling/heads/__init__.py | mask2former/modeling/heads/__init__.py | # Copyright (c) Facebook, Inc. and its affiliates.
| python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/modeling/heads/pixel_decoder.py | mask2former/modeling/heads/pixel_decoder.py | # Copyright (c) Facebook, Inc. and its affiliates.
import logging
from typing import Callable, Dict, List, Optional, Tuple, Union
import fvcore.nn.weight_init as weight_init
from torch import nn
from torch.nn import functional as F
from detectron2.config import configurable
from detectron2.layers import Conv2d, Shape... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/modeling/heads/mask_former_head.py | mask2former/modeling/heads/mask_former_head.py | # Copyright (c) Facebook, Inc. and its affiliates.
import logging
from copy import deepcopy
from typing import Callable, Dict, List, Optional, Tuple, Union
import fvcore.nn.weight_init as weight_init
from torch import nn
from torch.nn import functional as F
from detectron2.config import configurable
from detectron2.l... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/modeling/heads/ops/setup.py | mask2former/modeling/heads/ops/setup.py | # ------------------------------------------------------------------------------------------------
# Deformable DETR
# Copyright (c) 2020 SenseTime. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 [see LICENSE for details]
# -------------------------------------------------------------------------... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/modeling/heads/ops/test.py | mask2former/modeling/heads/ops/test.py | # ------------------------------------------------------------------------------------------------
# Deformable DETR
# Copyright (c) 2020 SenseTime. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 [see LICENSE for details]
# -------------------------------------------------------------------------... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/modeling/heads/ops/modules/ms_deform_attn.py | mask2former/modeling/heads/ops/modules/ms_deform_attn.py | # ------------------------------------------------------------------------------------------------
# Deformable DETR
# Copyright (c) 2020 SenseTime. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 [see LICENSE for details]
# -------------------------------------------------------------------------... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/modeling/heads/ops/modules/__init__.py | mask2former/modeling/heads/ops/modules/__init__.py | # ------------------------------------------------------------------------------------------------
# Deformable DETR
# Copyright (c) 2020 SenseTime. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 [see LICENSE for details]
# -------------------------------------------------------------------------... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/modeling/heads/ops/functions/ms_deform_attn_func.py | mask2former/modeling/heads/ops/functions/ms_deform_attn_func.py | # ------------------------------------------------------------------------------------------------
# Deformable DETR
# Copyright (c) 2020 SenseTime. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 [see LICENSE for details]
# -------------------------------------------------------------------------... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/modeling/heads/ops/functions/__init__.py | mask2former/modeling/heads/ops/functions/__init__.py | # ------------------------------------------------------------------------------------------------
# Deformable DETR
# Copyright (c) 2020 SenseTime. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 [see LICENSE for details]
# -------------------------------------------------------------------------... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/modeling/transformer/transformer_predictor.py | mask2former/modeling/transformer/transformer_predictor.py | # Copyright (c) Facebook, Inc. and its affiliates.
# Modified by Bowen Cheng from: https://github.com/facebookresearch/detr/blob/master/models/detr.py
import fvcore.nn.weight_init as weight_init
import torch
from torch import nn
from torch.nn import functional as F
from detectron2.config import configurable
from detec... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/modeling/transformer/__init__.py | mask2former/modeling/transformer/__init__.py | # Copyright (c) Facebook, Inc. and its affiliates.
| python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/modeling/transformer/position_encoding.py | mask2former/modeling/transformer/position_encoding.py | # Copyright (c) Facebook, Inc. and its affiliates.
# # Modified by Bowen Cheng from: https://github.com/facebookresearch/detr/blob/master/models/position_encoding.py
"""
Various positional encodings for the transformer.
"""
import math
import torch
from torch import nn
class PositionEmbeddingSine(nn.Module):
"""... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/modeling/transformer/mask2former_transformer_predictor.py | mask2former/modeling/transformer/mask2former_transformer_predictor.py | # Copyright (c) Facebook, Inc. and its affiliates.
# Modified by Bowen Cheng from: https://github.com/facebookresearch/detr/blob/master/models/detr.py
import logging
import fvcore.nn.weight_init as weight_init
from typing import Optional
import torch
from torch import nn, Tensor
from torch.nn import functional as F
fr... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/modeling/transformer/transformer.py | mask2former/modeling/transformer/transformer.py | # Copyright (c) Facebook, Inc. and its affiliates.
# Modified by Bowen Cheng from: https://github.com/facebookresearch/detr/blob/master/models/transformer.py
"""
Transformer class.
Copy-paste from torch.nn.Transformer with modifications:
* positional encodings are passed in MHattention
* extra LN at the end of... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/modeling/transformer/open_transformer_predictor.py | mask2former/modeling/transformer/open_transformer_predictor.py | # Copyright (c) Facebook, Inc. and its affiliates.
# Modified by Bowen Cheng from: https://github.com/facebookresearch/detr/blob/master/models/detr.py
from torch import nn
from detectron2.config import configurable
from .transformer_predictor import TransformerPredictor, MLP
from .mask2former_transformer_predictor impo... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/modeling/clip_adapter/__init__.py | mask2former/modeling/clip_adapter/__init__.py | import logging
import torch
from detectron2.utils.logger import log_first_n
from .text_prompt import (
PredefinedPromptExtractor,
LearnablePromptExtractor,
)
from .adapter import ClipAdapter, MaskFormerClipAdapter, PerPixelClipAdapter
def build_prompt_learner(cfg, task_names):
if cfg.PROMPT_LEARNER == "pr... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/modeling/clip_adapter/text_prompt.py | mask2former/modeling/clip_adapter/text_prompt.py | from typing import List, Tuple
import clip
import torch
from torch import nn
from .clip import CLIP
class PromptExtractor(nn.Module):
def __init__(self):
super().__init__()
self._buffer_init = False
self.with_trainable_params = False
def init_buffer(self, clip_model):
self._... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/modeling/clip_adapter/adapter.py | mask2former/modeling/clip_adapter/adapter.py | from typing import List
import torch
from torch import nn
from torch.nn import functional as F
from detectron2.structures import BitMasks
from .clip import build_clip_model, crop_with_mask, CLIP
from .text_prompt import PromptExtractor
class ClipAdapter(nn.Module):
def __init__(self, clip_model_name: str, prompt_... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/modeling/clip_adapter/clip.py | mask2former/modeling/clip_adapter/clip.py | from typing import Tuple
import numpy as np
import torch
import timm
import clip
from detectron2.utils.comm import get_local_rank, synchronize
class CLIP:
PIXEL_MEAN = (0.48145466, 0.4578275, 0.40821073)
PIXEL_STD = (0.26862954, 0.26130258, 0.27577711)
IMAGENET_PROMPT = [
"a bad photo of a {}.",
... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/modeling/backbone/__init__.py | mask2former/modeling/backbone/__init__.py | # Copyright (c) Facebook, Inc. and its affiliates.
| python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/modeling/backbone/clip_resnet.py | mask2former/modeling/backbone/clip_resnet.py | from collections import OrderedDict
from typing import Tuple, Union
from scipy import interpolate
import numpy as np
import torch
import torch.nn.functional as F
from torch import nn
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from detectron2.modeling import BACKBONE_REGISTRY, ... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/modeling/backbone/swin.py | mask2former/modeling/backbone/swin.py | # --------------------------------------------------------
# Swin Transformer
# Copyright (c) 2021 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ze Liu, Yutong Lin, Yixuan Wei
# --------------------------------------------------------
# Copyright (c) Facebook, Inc. and its affiliate... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/data/build.py | mask2former/data/build.py | import itertools
import logging
import numpy as np
from collections import Counter
import torch.utils.data
from tabulate import tabulate
from termcolor import colored
from detectron2.utils.logger import _log_api_usage, log_first_n
from detectron2.data.catalog import DatasetCatalog, MetadataCatalog
import torch.utils.d... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/data/augmentations.py | mask2former/data/augmentations.py | import math
import numbers
import numpy as np
from detectron2.data.transforms.augmentation import Augmentation
from detectron2.data.transforms.transform import (
CropTransform,
ResizeTransform,
TransformList,
)
from PIL import Image
from fvcore.transforms.transform import PadTransform
def mask2box(mask: n... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/data/__init__.py | mask2former/data/__init__.py | from .dataset_mappers import *
from . import datasets
from .build import (
build_detection_train_loader,
build_detection_test_loader,
dataset_sample_per_class,
dataset_sample_per_task_class,
)
| python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/data/datasets/register_coco_stuff.py | mask2former/data/datasets/register_coco_stuff.py | # Copyright (c) Facebook, Inc. and its affiliates.
import os
from detectron2.data import DatasetCatalog, MetadataCatalog
from detectron2.data.datasets import load_sem_seg
from .utils import load_binary_mask
COCO_CATEGORIES = [
{"color": [220, 20, 60], "isthing": 1, "id": 1, "name": "person"},
{"color": [119,... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/data/datasets/register_coco_full.py | mask2former/data/datasets/register_coco_full.py | # Copyright (c) Facebook, Inc. and its affiliates.
import os
import json
import logging
from PIL import Image
from detectron2.data import DatasetCatalog, MetadataCatalog
from detectron2.data.datasets import load_sem_seg
from detectron2.utils.file_io import PathManager
from .utils import load_binary_mask
logger = log... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/data/datasets/register_coco_panoptic.py | mask2former/data/datasets/register_coco_panoptic.py | # Copyright (c) Facebook, Inc. and its affiliates.
import json
import os
from PIL import Image
from detectron2.data import DatasetCatalog, MetadataCatalog
from detectron2.data.datasets import load_sem_seg
from detectron2.data.datasets.builtin_meta import COCO_CATEGORIES
from detectron2.utils.file_io import PathManager... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/data/datasets/utils.py | mask2former/data/datasets/utils.py | import json
import logging
import os
from detectron2.data.datasets.coco import load_sem_seg
logger = logging.getLogger(__name__)
def load_binary_mask(gt_root, image_root, gt_ext="png", image_ext="jpg"):
"""
Flatten the results of `load_sem_seg` to annotations for binary mask.
`label_count_file` contain... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/data/datasets/register_voc_seg.py | mask2former/data/datasets/register_voc_seg.py | # Copyright (c) Facebook, Inc. and its affiliates.
import os
from detectron2.data import DatasetCatalog, MetadataCatalog
from detectron2.data.datasets import load_sem_seg
from .utils import load_binary_mask
CLASS_NAMES = (
"aeroplane",
"bicycle",
"bird",
"boat",
"bottle",
"bus",
"car",
... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/data/datasets/__init__.py | mask2former/data/datasets/__init__.py | # Copyright (c) Facebook, Inc. and its affiliates.
from . import register_coco_stuff, register_voc_seg, register_coco_full, register_coco_panoptic | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/data/datasets/register_ade20k_all_data.py | mask2former/data/datasets/register_ade20k_all_data.py | # Copyright (c) Facebook, Inc. and its affiliates.
import json
import os
from detectron2.data import DatasetCatalog, MetadataCatalog
from detectron2.utils.file_io import PathManager
from .utils import load_binary_mask
ADE20K_150_CATEGORIES = [
{"color": [120, 120, 120], "id": 0, "isthing": 0, "name": "wall"},
... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/data/dataset_mappers/coco_full_task_new_baseline_dataset_mapper.py | mask2former/data/dataset_mappers/coco_full_task_new_baseline_dataset_mapper.py | # Copyright (c) Facebook, Inc. and its affiliates.
# Modified by Bowen Cheng from https://github.com/facebookresearch/detr/blob/master/d2/detr/dataset_mapper.py
import copy
import logging
import numpy as np
import torch
from torch.nn import functional as F
from detectron2.config import configurable
from detectron2.da... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/data/dataset_mappers/mask_former_binary_semantic_dataset_mapper.py | mask2former/data/dataset_mappers/mask_former_binary_semantic_dataset_mapper.py | # Copyright (c) Facebook, Inc. and its affiliates.
import copy
import logging
import numpy as np
import torch
from torch.nn import functional as F
from detectron2.config import configurable
from detectron2.data import MetadataCatalog
from detectron2.data import detection_utils as utils
from detectron2.data import tra... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/data/dataset_mappers/mask_former_instance_dataset_mapper.py | mask2former/data/dataset_mappers/mask_former_instance_dataset_mapper.py | # Copyright (c) Facebook, Inc. and its affiliates.
import copy
import logging
import numpy as np
import pycocotools.mask as mask_util
import torch
from torch.nn import functional as F
from detectron2.config import configurable
from detectron2.data import detection_utils as utils
from detectron2.data import transforms... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/data/dataset_mappers/mask_former_semantic_dataset_mapper.py | mask2former/data/dataset_mappers/mask_former_semantic_dataset_mapper.py | # Copyright (c) Facebook, Inc. and its affiliates.
import copy
import logging
import numpy as np
import torch
from torch.nn import functional as F
from detectron2.config import configurable
from detectron2.data import MetadataCatalog
from detectron2.data import detection_utils as utils
from detectron2.data import tra... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/data/dataset_mappers/mask_former_binary_full_dataset_mapper.py | mask2former/data/dataset_mappers/mask_former_binary_full_dataset_mapper.py | # Copyright (c) Facebook, Inc. and its affiliates.
import copy
import logging
import numpy as np
import torch
from torch.nn import functional as F
from detectron2.config import configurable
from detectron2.data import MetadataCatalog
from detectron2.data import detection_utils as utils
from detectron2.data import tra... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/data/dataset_mappers/__init__.py | mask2former/data/dataset_mappers/__init__.py | # Copyright (c) Facebook, Inc. and its affiliates.
from .mask_former_binary_semantic_dataset_mapper import (
MaskFormerBinarySemanticDatasetMapper,
)
from .mask_former_binary_full_dataset_mapper import MaskFormerBinaryFullDatasetMapper
from .mask_former_semantic_dataset_mapper import MaskFormerSemanticDatasetMapper... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/data/dataset_mappers/proposal_classification_dataset_mapper.py | mask2former/data/dataset_mappers/proposal_classification_dataset_mapper.py | from detectron2.data.dataset_mapper import DatasetMapper
# Copyright (c) Facebook, Inc. and its affiliates.
import copy
import logging
import numpy as np
import torch
from torch.nn import functional as F
from detectron2.config import configurable
from detectron2.data import detection_utils as utils
from detectron2.d... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/data/dataset_mappers/mask_former_panoptic_dataset_mapper.py | mask2former/data/dataset_mappers/mask_former_panoptic_dataset_mapper.py | # Copyright (c) Facebook, Inc. and its affiliates.
import copy
import logging
import numpy as np
import torch
from torch.nn import functional as F
from detectron2.config import configurable
from detectron2.data import detection_utils as utils
from detectron2.data import transforms as T
from detectron2.structures impo... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/data/dataset_mappers/ade_all_task_dataset_mapper.py | mask2former/data/dataset_mappers/ade_all_task_dataset_mapper.py | # Copyright (c) Facebook, Inc. and its affiliates.
import copy
import logging
import numpy as np
import torch
from torch.nn import functional as F
from detectron2.config import configurable
from detectron2.data import detection_utils as utils
from detectron2.data import transforms as T
from detectron2.structures impo... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/evaluation/instance_seg_evaluation.py | mask2former/evaluation/instance_seg_evaluation.py | # 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 pycocotools.mask as mask_util
import torch
from pycocotools.coco import COCO
from pycocotools.cocoe... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/evaluation/pseudo_sem_seg_evaluation.py | mask2former/evaluation/pseudo_sem_seg_evaluation.py | # Copyright (c) Facebook, Inc. and its affiliates.
import itertools
import json
import logging
import numpy as np
import os
from collections import OrderedDict
import PIL.Image as Image
import torch
from detectron2.data import MetadataCatalog
from detectron2.utils.comm import all_gather, is_main_process, synchronize
f... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/evaluation/classification_evaluation.py | mask2former/evaluation/classification_evaluation.py | # Copyright (c) Facebook, Inc. and its affiliates.
import copy
import itertools
import logging
from collections import OrderedDict
import numpy as np
import torch
import detectron2.utils.comm as comm
from detectron2.data import MetadataCatalog
from detectron2.evaluation import DatasetEvaluator
class ClassificationEv... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/evaluation/panoptic_seg_evaluation.py | mask2former/evaluation/panoptic_seg_evaluation.py | # 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 detectron2.data import Metadat... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/evaluation/instance_evaluation.py | mask2former/evaluation/instance_evaluation.py | # 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 pycocotools.mask as mask_util
import torch
from pycocotools.coco import COCO
from pycocotools.cocoe... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/evaluation/__init__.py | mask2former/evaluation/__init__.py | from .generalized_sem_seg_evaluation import GeneralizedSemSegEvaluator
from .classification_evaluation import ClassificationEvaluator
from .pseudo_sem_seg_evaluation import GeneralizedPseudoSemSegEvaluator
from .panoptic_seg_evaluation import GeneralizedPanopticEvaluator
from .instance_evaluation import InstanceSegEval... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
bytedance/FreeSeg | https://github.com/bytedance/FreeSeg/blob/7707335cc3f2a1a73d4d2829f3cdbb0e031d3961/mask2former/evaluation/generalized_sem_seg_evaluation.py | mask2former/evaluation/generalized_sem_seg_evaluation.py | # Copyright (c) Facebook, Inc. and its affiliates.
import itertools
import json
import logging
import numpy as np
import os
from collections import OrderedDict
import PIL.Image as Image
import pycocotools.mask as mask_util
import torch
from detectron2.data import DatasetCatalog, MetadataCatalog
from detectron2.utils.c... | python | Apache-2.0 | 7707335cc3f2a1a73d4d2829f3cdbb0e031d3961 | 2026-01-05T07:13:42.671257Z | false |
johngai19/TextDistiller | https://github.com/johngai19/TextDistiller/blob/18d18b8c7845d6a1baee9a011b985853278d0f53/bsCLI.py | bsCLI.py | from preprocess import *
import argparse
import os
from shutil import copyfile
def dir_path(path):
if os.path.exists(path):
return path
else:
raise argparse.ArgumentTypeError(f"readable_dir:{path} is not a valid path")
if __name__ == '__main__':
parser = argparse.ArgumentParser(descripti... | python | MIT | 18d18b8c7845d6a1baee9a011b985853278d0f53 | 2026-01-05T07:13:40.590988Z | false |
johngai19/TextDistiller | https://github.com/johngai19/TextDistiller/blob/18d18b8c7845d6a1baee9a011b985853278d0f53/mail.py | mail.py | from imports import *
def send_fail(receiver_address):
mail_content_file = open('error_body.txt')
sender_address = 'YOUR_EMAIL_HERE'
sender_pass = 'PASS'
# Setup the MIME
message = MIMEMultipart()
message['From'] = "John Ngai"
message['To'] = receiver_address
message['Subject'] = 'Chapt... | python | MIT | 18d18b8c7845d6a1baee9a011b985853278d0f53 | 2026-01-05T07:13:40.590988Z | false |
johngai19/TextDistiller | https://github.com/johngai19/TextDistiller/blob/18d18b8c7845d6a1baee9a011b985853278d0f53/views.py | views.py | from imports import *
from preprocess import *
from mail import *
def allowed_pdf(filename):
if not "." in filename:
return False
ext = filename.rsplit(".", 1)[1]
if ext.upper() in app.config["ALLOWED_EXTENSIONS"]:
return True
return False
@app.route("/", methods=["GET"])
def redirect... | python | MIT | 18d18b8c7845d6a1baee9a011b985853278d0f53 | 2026-01-05T07:13:40.590988Z | false |
johngai19/TextDistiller | https://github.com/johngai19/TextDistiller/blob/18d18b8c7845d6a1baee9a011b985853278d0f53/model.py | model.py | from imports import *
from mail import *
model = T5ForConditionalGeneration.from_pretrained('t5-small')
tokenizer = T5Tokenizer.from_pretrained('t5-small')
device = torch.device('cpu')
try:
nltk.data.find('tokenizers/punkt')
except LookupError:
nltk.download('punkt')
def cleanText(text):
text = re.sub(r"... | python | MIT | 18d18b8c7845d6a1baee9a011b985853278d0f53 | 2026-01-05T07:13:40.590988Z | false |
johngai19/TextDistiller | https://github.com/johngai19/TextDistiller/blob/18d18b8c7845d6a1baee9a011b985853278d0f53/imports.py | imports.py | import fnmatch
import io
import json
import nltk
import os
import re
import shutil
import smtplib
import sys
import torch
from email import encoders
from email.mime.base import MIMEBase
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from flask import flash, Flask, render_template, ... | python | MIT | 18d18b8c7845d6a1baee9a011b985853278d0f53 | 2026-01-05T07:13:40.590988Z | false |
johngai19/TextDistiller | https://github.com/johngai19/TextDistiller/blob/18d18b8c7845d6a1baee9a011b985853278d0f53/preprocess.py | preprocess.py | from imports import *
from model import *
def splitChapters(filename, mailid=None):
checkFlag = 0
skipCount = 0
flag = 0
chapterNumber = 0
filename = filename[:-4]
file = filename + '.txt'
with open(file, 'r', encoding='utf-8') as f1:
lines = f1.readlines()
print('Total Num... | python | MIT | 18d18b8c7845d6a1baee9a011b985853278d0f53 | 2026-01-05T07:13:40.590988Z | false |
tunz/binch | https://github.com/tunz/binch/blob/b3a0558b4f0468e1fd7fa58c3559f7dff14b1e34/setup.py | setup.py | from setuptools import setup, find_packages
py_modules = [
'pyelftools',
'capstone',
'keystone-engine',
'urwid',
'blinker',
'progressbar2'
]
setup (
name = 'binch',
version = '0.3.1',
description = 'a light ELF binary patch tool',
author = 'Choongwoo Han',
author_email = 'cwhan... | python | MIT | b3a0558b4f0468e1fd7fa58c3559f7dff14b1e34 | 2026-01-05T07:13:47.889227Z | false |
tunz/binch | https://github.com/tunz/binch/blob/b3a0558b4f0468e1fd7fa58c3559f7dff14b1e34/binchlib/view.py | binchlib/view.py | import urwid
from .disassemble import *
from .statusbar import *
from . import signals
from capstone.x86 import X86_OP_IMM
from capstone.arm import ARM_OP_IMM
import traceback
import progressbar
import sys
import re
class DisassembleText(urwid.Text):
def selectable(self):
return False
def keypress(se... | python | MIT | b3a0558b4f0468e1fd7fa58c3559f7dff14b1e34 | 2026-01-05T07:13:47.889227Z | false |
tunz/binch | https://github.com/tunz/binch/blob/b3a0558b4f0468e1fd7fa58c3559f7dff14b1e34/binchlib/signals.py | binchlib/signals.py | import blinker
focus = blinker.Signal()
set_prompt = blinker.Signal()
set_prompt_yn = blinker.Signal()
set_message = blinker.Signal()
redraw_status = blinker.Signal()
call_delay = blinker.Signal()
| python | MIT | b3a0558b4f0468e1fd7fa58c3559f7dff14b1e34 | 2026-01-05T07:13:47.889227Z | false |
tunz/binch | https://github.com/tunz/binch/blob/b3a0558b4f0468e1fd7fa58c3559f7dff14b1e34/binchlib/main.py | binchlib/main.py | #!/usr/bin/env python
from .view import DisassembleView
import argparse
import sys
import os
def binch(args=None):
parser = argparse.ArgumentParser(description='A light ELF binary patch tool.')
parser.add_argument('filename', metavar='filename', type=str,
help='a binary filename... | python | MIT | b3a0558b4f0468e1fd7fa58c3559f7dff14b1e34 | 2026-01-05T07:13:47.889227Z | false |
tunz/binch | https://github.com/tunz/binch/blob/b3a0558b4f0468e1fd7fa58c3559f7dff14b1e34/binchlib/__init__.py | binchlib/__init__.py | python | MIT | b3a0558b4f0468e1fd7fa58c3559f7dff14b1e34 | 2026-01-05T07:13:47.889227Z | false | |
tunz/binch | https://github.com/tunz/binch/blob/b3a0558b4f0468e1fd7fa58c3559f7dff14b1e34/binchlib/statusbar.py | binchlib/statusbar.py | from . import signals
import view
import urwid
class CommandLine(urwid.WidgetWrap):
def __init__(self):
urwid.WidgetWrap.__init__(self, None)
self.clear()
signals.set_prompt.connect(self.sig_prompt)
signals.set_prompt_yn.connect(self.sig_prompt_yn)
signals.set_message.connec... | python | MIT | b3a0558b4f0468e1fd7fa58c3559f7dff14b1e34 | 2026-01-05T07:13:47.889227Z | false |
tunz/binch | https://github.com/tunz/binch/blob/b3a0558b4f0468e1fd7fa58c3559f7dff14b1e34/binchlib/disassemble.py | binchlib/disassemble.py | from capstone import *
from keystone import *
from elftools.elf.elffile import ELFFile
from elftools.elf.sections import SymbolTableSection
import sys, os
from . import signals
class Disassembler():
memory = []
def __init__(self, filename):
self.filename = filename
self.loadELF(filename)
... | python | MIT | b3a0558b4f0468e1fd7fa58c3559f7dff14b1e34 | 2026-01-05T07:13:47.889227Z | false |
taomanwai/tensorboardcolab | https://github.com/taomanwai/tensorboardcolab/blob/337dce9890dadcb977b60322c30c76dee7fb42b1/setup.py | setup.py | from distutils.core import setup
setup(
name='tensorboardcolab',
version='0.0.21',
packages=['tensorboardcolab'],
url='https://github.com/taomanwai/tensorboardcolab',
license='MIT',
author='Tommy Tao',
author_email='o_otaotao@hotmail.com',
description=''
)
| python | MIT | 337dce9890dadcb977b60322c30c76dee7fb42b1 | 2026-01-05T07:13:48.796857Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.