repo
stringlengths
1
99
file
stringlengths
13
215
code
stringlengths
12
59.2M
file_length
int64
12
59.2M
avg_line_length
float64
3.82
1.48M
max_line_length
int64
12
2.51M
extension_type
stringclasses
1 value
sam-hq
sam-hq-main/seginw/GroundingDINO/groundingdino/models/GroundingDINO/backbone/backbone.py
# ------------------------------------------------------------------------ # Grounding DINO # url: https://github.com/IDEA-Research/GroundingDINO # Copyright (c) 2023 IDEA. All Rights Reserved. # Licensed under the Apache License, Version 2.0 [see LICENSE for details] # -------------------------------------------------...
7,972
34.914414
112
py
sam-hq
sam-hq-main/seginw/GroundingDINO/groundingdino/util/inference.py
from typing import Tuple, List import re import cv2 import numpy as np import supervision as sv import torch from PIL import Image from torchvision.ops import box_convert import groundingdino.datasets.transforms as T from groundingdino.models import build_model from groundingdino.util.misc import clean_state_dict fro...
8,705
32.875486
194
py
sam-hq
sam-hq-main/seginw/GroundingDINO/groundingdino/util/vl_utils.py
import os import random from typing import List import torch def create_positive_map_from_span(tokenized, token_span, max_text_len=256): """construct a map such that positive_map[i,j] = True iff box i is associated to token j Input: - tokenized: - input_ids: Tensor[1, ntokens] ...
3,489
33.554455
92
py
sam-hq
sam-hq-main/seginw/GroundingDINO/groundingdino/util/misc.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved """ Misc functions, including distributed helpers. Mostly copy-paste from torchvision references. """ import colorsys import datetime import functools import io import json import os import pickle import subprocess import time from collections impo...
23,348
31.519499
141
py
sam-hq
sam-hq-main/seginw/GroundingDINO/groundingdino/util/utils.py
import argparse import json import warnings from collections import OrderedDict from copy import deepcopy from typing import Any, Dict, List import numpy as np import torch from transformers import AutoTokenizer from groundingdino.util.slconfig import SLConfig def slprint(x, name="x"): if isinstance(x, (torch.T...
17,712
28.085386
119
py
sam-hq
sam-hq-main/seginw/GroundingDINO/groundingdino/util/visualizer.py
# -*- coding: utf-8 -*- """ @File : visualizer.py @Time : 2022/04/05 11:39:33 @Author : Shilong Liu @Contact : slongliu86@gmail.com """ import datetime import os import cv2 import matplotlib.pyplot as plt import numpy as np import torch from matplotlib import transforms from matplotlib.collections imp...
12,047
36.768025
119
py
sam-hq
sam-hq-main/seginw/GroundingDINO/groundingdino/util/box_ops.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved """ Utilities for bounding box manipulation and GIoU. """ import torch from torchvision.ops.boxes import box_area def box_cxcywh_to_xyxy(x): x_c, y_c, w, h = x.unbind(-1) b = [(x_c - 0.5 * w), (y_c - 0.5 * h), (x_c + 0.5 * w), (y_c + 0.5 *...
3,905
26.702128
110
py
sam-hq
sam-hq-main/seginw/GroundingDINO/groundingdino/datasets/cocogrounding_eval.py
# ------------------------------------------------------------------------ # Grounding DINO. Midified by Shilong Liu. # url: https://github.com/IDEA-Research/GroundingDINO # Copyright (c) 2023 IDEA. All Rights Reserved. # Licensed under the Apache License, Version 2.0 [see LICENSE for details] # -----------------------...
9,422
33.643382
109
py
sam-hq
sam-hq-main/seginw/GroundingDINO/groundingdino/datasets/transforms.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved """ Transforms and data augmentation for both image + bbox. """ import os import random import PIL import torch import torchvision.transforms as T import torchvision.transforms.functional as F from groundingdino.util.box_ops import box_xyxy_to_cxc...
9,711
30.128205
98
py
sam-hq
sam-hq-main/seginw/GroundingDINO/demo/gradio_app.py
import argparse from functools import partial import cv2 import requests import os from io import BytesIO from PIL import Image import numpy as np from pathlib import Path import warnings import torch # prepare the environment os.system("python setup.py build develop --user") os.system("pip install packaging==21.3"...
4,463
34.428571
121
py
sam-hq
sam-hq-main/seginw/GroundingDINO/demo/inference_on_a_image.py
import argparse import os import sys import numpy as np import torch from PIL import Image, ImageDraw, ImageFont import groundingdino.datasets.transforms as T from groundingdino.models import build_model from groundingdino.util import box_ops from groundingdino.util.slconfig import SLConfig from groundingdino.util.ut...
6,001
33.693642
113
py
FASeg
FASeg-main/train_net.py
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved """ MaskFormer Training Script. This script is a simplified version of the training script in detectron2/tools. """ # Modifications copyright (c) 2022 ZIP Group Group, Haoyu He import copy import itertools import logging import os from collection...
13,101
38.823708
108
py
FASeg
FASeg-main/tools/evaluate_pq_for_semantic_segmentation.py
#!/usr/bin/env python # Copyright (c) Facebook, Inc. and its affiliates. import argparse import json import os from collections import defaultdict from tqdm import tqdm import numpy as np import torch from detectron2.data import MetadataCatalog from detectron2.data.detection_utils import read_image from detectron2.u...
9,706
38.45935
166
py
FASeg
FASeg-main/tools/analyze_model.py
# -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. # Modified by Bowen Cheng from https://github.com/facebookresearch/detectron2/blob/main/tools/analyze_model.py import logging import numpy as np from collections import Counter import tqdm from fvcore.nn import flop_count_table # can also try ...
5,717
31.123596
110
py
FASeg
FASeg-main/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...
1,434
26.596154
87
py
FASeg
FASeg-main/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 ...
856
26.645161
107
py
FASeg
FASeg-main/mask2former/test_time_augmentation.py
# Copyright (c) Facebook, Inc. and its affiliates. import copy import logging from itertools import count 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 ...
7,158
36.481675
97
py
FASeg
FASeg-main/mask2former/maskformer_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...
16,903
43.367454
149
py
FASeg
FASeg-main/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...
4,625
41.833333
96
py
FASeg
FASeg-main/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...
3,897
33.803571
96
py
FASeg
FASeg-main/mask2former/data/dataset_mappers/coco_panoptic_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 detectron2.config import configurable from detectron2.data import detection_utils as utils fr...
5,810
34.006024
109
py
FASeg
FASeg-main/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...
6,873
36.156757
98
py
FASeg
FASeg-main/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...
6,230
36.536145
98
py
FASeg
FASeg-main/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...
6,595
35.441989
97
py
FASeg
FASeg-main/mask2former/data/dataset_mappers/coco_instance_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 detectron2.config import configurable from detectron2.data import detection_utils as utils fr...
7,203
36.915789
119
py
FASeg
FASeg-main/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...
7,564
38.196891
115
py
FASeg
FASeg-main/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 logging import torch import torch.nn.functional as F from torch import nn from detectron2.utils.comm import get_world_size from det...
18,407
40.553047
108
py
FASeg
FASeg-main/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...
27,476
34.638132
157
py
FASeg
FASeg-main/mask2former/modeling/meta_arch/mask_former_head.py
# Copyright (c) Facebook, Inc. and its affiliates. # Modifications copyright (c) 2022 ZIP Group, Haoyu He import logging from typing import Dict from torch import nn from detectron2.config import configurable from detectron2.layers import ShapeSpec from detectron2.modeling import SEM_SEG_HEADS_REGISTRY from ..tran...
10,822
42.119522
134
py
FASeg
FASeg-main/mask2former/modeling/meta_arch/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...
9,433
37.663934
102
py
FASeg
FASeg-main/mask2former/modeling/transformer_decoder/mask2former_transformer_decoder.py
# Copyright (c) Facebook, Inc. and its affiliates. # Modified by Bowen Cheng from: https://github.com/facebookresearch/detr/blob/master/models/detr.py # Modifications copyright (c) 2022 ZIP Group Group, Haoyu He from: https://github.com/facebookresearch/detr/blob/master/models/detr.py import logging import fvcore.nn.w...
26,031
40.059937
150
py
FASeg
FASeg-main/mask2former/modeling/transformer_decoder/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): """...
2,517
38.34375
114
py
FASeg
FASeg-main/mask2former/modeling/transformer_decoder/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...
11,943
31.281081
106
py
FASeg
FASeg-main/mask2former/modeling/transformer_decoder/maskformer_transformer_decoder.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...
7,065
36.386243
99
py
FASeg
FASeg-main/mask2former/modeling/pixel_decoder/msdeformattn.py
# Copyright (c) Facebook, Inc. and its affiliates. # Modifications copyright (c) 2022 ZIP Group, Haoyu He 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....
24,875
41.668954
132
py
FASeg
FASeg-main/mask2former/modeling/pixel_decoder/fpn.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...
12,411
38.654952
122
py
FASeg
FASeg-main/mask2former/modeling/pixel_decoder/ops/test.py
# ------------------------------------------------------------------------------------------------ # Deformable DETR # Copyright (c) 2020 SenseTime. All Rights Reserved. # Licensed under the Apache License, Version 2.0 [see LICENSE for details] # -------------------------------------------------------------------------...
4,223
44.419355
172
py
FASeg
FASeg-main/mask2former/modeling/pixel_decoder/ops/setup.py
# ------------------------------------------------------------------------------------------------ # Deformable DETR # Copyright (c) 2020 SenseTime. All Rights Reserved. # Licensed under the Apache License, Version 2.0 [see LICENSE for details] # -------------------------------------------------------------------------...
3,038
37.468354
139
py
FASeg
FASeg-main/mask2former/modeling/pixel_decoder/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] # -------------------------------------------------------------------------...
3,728
50.082192
138
py
FASeg
FASeg-main/mask2former/modeling/pixel_decoder/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] # -------------------------------------------------------------------------...
734
51.5
98
py
FASeg
FASeg-main/mask2former/modeling/pixel_decoder/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] # -------------------------------------------------------------------------...
720
54.461538
98
py
FASeg
FASeg-main/mask2former/modeling/pixel_decoder/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] # -------------------------------------------------------------------------...
6,633
53.377049
153
py
FASeg
FASeg-main/demo/predictor.py
# Copyright (c) Facebook, Inc. and its affiliates. # Copied from: https://github.com/facebookresearch/detectron2/blob/master/demo/predictor.py import atexit import bisect import multiprocessing as mp from collections import deque import cv2 import torch from detectron2.data import MetadataCatalog from detectron2.engi...
16,801
36.927765
96
py
semisup-adv
semisup-adv-master/tinyimages_prediction.py
""" Select unlabeled data from TinyImages using the trained data sourcing model """ import torch.backends.cudnn as cudnn cudnn.benchmark = True import logging import os import pickle from utils import get_model, load_cifar10_keywords import argparse import numpy as np from torchvision import transforms import t...
7,189
33.238095
107
py
semisup-adv
semisup-adv-master/losses.py
""" Robust training losses. Based on code from https://github.com/yaodongyu/TRADES """ import contextlib import torch import torch.nn as nn import torch.nn.functional as F from torch.autograd import Variable import numpy as np import pdb def entropy_loss(unlabeled_logits): unlabeled_probs = F.softmax(unlabeled...
3,853
32.513043
78
py
semisup-adv
semisup-adv-master/tinyimages_preliminaries.py
""" Preliminary computations for sourcing unlabeled data: 1) Compute the l2 distance between every image in TinyImages and its nearest neighbor in the CIFAR-10 test set. We will use this later to make sure that none of our unlabeled data appears in the test set. 2) Select 1.01M TinyImages with keywords that don't appea...
8,906
36.902128
97
py
semisup-adv
semisup-adv-master/generate_pseudolabels.py
""" Code for running a generating pseudolabels for unlabeled TinyImages data """ import torch.backends.cudnn as cudnn cudnn.benchmark = True import logging import os import pickle import argparse import numpy as np from torchvision import transforms import torch from torch import nn from torch.nn import DataParal...
3,627
32.906542
97
py
semisup-adv
semisup-adv-master/attack_pgd.py
### PGD implementation import numpy as np import torch import torch.nn as nn import torch.nn.functional as F import torchvision from torch.autograd import Variable import torch.optim as optim import logging def pgd(model, X, y, epsilon=8 / 255, num_steps=20, step_size=0.01, ...
1,582
28.314815
80
py
semisup-adv
semisup-adv-master/dataloader.py
""" Based on code from https://github.com/hysts/pytorch_shake_shake """ import numpy as np import torch import torchvision import os import pickle from torch.utils import data import pdb def get_loader(batch_size, num_workers, use_gpu): mean = np.array([0.4914, 0.4822, 0.4465]) std = np.array([0.2470, 0.2435,...
6,434
35.5625
80
py
semisup-adv
semisup-adv-master/utils.py
""" Utilities. Partially based on code from https://github.com/modestyachts/CIFAR-10.1 """ import io import json import os import pickle import numpy as np import pathlib from models.wideresnet import WideResNet from models.shake_shake import ShakeNet from models.cifar_resnet import ResNet import torch from torch.nn...
6,705
36.674157
98
py
semisup-adv
semisup-adv-master/robust_self_training.py
""" Main robust self-training script. Based loosely on code from https://github.com/yaodongyu/TRADES """ import os import sys import argparse import torch import torch.nn.functional as F import torch.optim as optim from torchvision import transforms import torch.backends.cudnn as cudnn from torch.utils.data import D...
20,304
41.214137
81
py
semisup-adv
semisup-adv-master/train_cifar10_vs_ti.py
""" Train data sourcing model. Based on code from https://github.com/hysts/pytorch_shake_shake """ import argparse from collections import OrderedDict import importlib import json import logging import pathlib import random import time import numpy as np import torch import torch.nn as nn import torchvision from util...
11,652
28.879487
78
py
semisup-adv
semisup-adv-master/smoothing_evaluation.py
""" Run randomized certification on the test set. Loosely based on code from https://github.com/locuslab/smoothing """ import argparse import os from time import time import datetime from utils import get_model import logging import pandas as pd import torch import torch.nn import torch.nn.functional as F from data...
6,566
38.8
79
py
semisup-adv
semisup-adv-master/cutout.py
""" Cutout augmentation implementation. Code taken from https://github.com/uoguelph-mlrg/Cutout/blob/master/util/cutout.py """ import torch import numpy as np # TODO: add credit class Cutout(object): """Randomly mask out one or more patches from an image. Args: n_holes (int): Number of patches to c...
1,320
24.901961
82
py
semisup-adv
semisup-adv-master/datasets.py
""" Datasets with unlabeled (or pseudo-labeled) data """ from torchvision.datasets import CIFAR10, SVHN from torch.utils.data import Sampler, Dataset import torch import numpy as np import os import pickle import logging DATASETS = ['cifar10', 'svhn'] class SemiSupervisedDataset(Dataset): def __init__(self, ...
8,369
38.481132
118
py
semisup-adv
semisup-adv-master/attack_evaluation.py
""" Evaluate robustness against specific attack. Loosely based on code from https://github.com/yaodongyu/TRADES """ import os import json import numpy as np import re import argparse import logging import torch import torch.nn as nn import torch.nn.functional as F import torchvision from torch.autograd import Variable...
10,798
42.898374
80
py
semisup-adv
semisup-adv-master/smoothing.py
""" Randomized smooothing certification. Based on code from https://github.com/locuslab/smoothing """ import torch import torch.nn import torch.nn.functional as F import numpy as np from scipy.stats import norm, binom_test from statsmodels.stats.proportion import proportion_confint from math import ceil def quick_...
6,745
40.641975
119
py
semisup-adv
semisup-adv-master/models/shake_shake.py
import torch import torch.nn as nn import torch.nn.functional as F from .shake_shake_function import get_alpha_beta, shake_function """ Based on code from https://github.com/hysts/pytorch_shake_shake """ def initialize_weights(module): if isinstance(module, nn.Conv2d): nn.init.kaiming_normal_(module.weig...
6,108
29.393035
79
py
semisup-adv
semisup-adv-master/models/cifar_resnet.py
from __future__ import absolute_import ''' This file is from: https://raw.githubusercontent.com/bearpaw/pytorch-classification/master/models/cifar/resnet.py by Wei Yang ''' import torch.nn as nn import math # __all__ = ['resnet'] def conv3x3(in_planes, out_planes, stride=1): "3x3 convolution with padding" r...
5,054
30.01227
116
py
semisup-adv
semisup-adv-master/models/shake_shake_function.py
""" Based on code from https://github.com/hysts/pytorch_shake_shake """ import torch from torch.autograd import Function class ShakeFunction(Function): @staticmethod def forward(ctx, x1, x2, alpha, beta): ctx.save_for_backward(x1, x2, alpha, beta) y = x1 * alpha + x2 * (1 - alpha) re...
1,402
24.981481
64
py
semisup-adv
semisup-adv-master/models/wideresnet.py
"""Based on code from https://github.com/yaodongyu/TRADES""" import math import torch import torch.nn as nn import torch.nn.functional as F class BasicBlock(nn.Module): def __init__(self, in_planes, out_planes, stride, dropRate=0.0): super(BasicBlock, self).__init__() self.bn1 = nn.BatchNorm2d(in...
4,067
40.090909
116
py
muzero-general
muzero-general-master/self_play.py
import math import time import numpy import ray import torch import models @ray.remote class SelfPlay: """ Class which run in a dedicated thread to play games and save them to the replay-buffer. """ def __init__(self, initial_checkpoint, Game, config, seed): self.config = config sel...
21,137
36.019264
180
py
muzero-general
muzero-general-master/diagnose_model.py
import matplotlib.pyplot as plt import numpy import seaborn import torch import models from self_play import MCTS, Node, SelfPlay class DiagnoseModel: """ Tools to understand the learned model. Args: weights: weights for the model to diagnose. config: configuration class instance relate...
13,660
35.822102
154
py
muzero-general
muzero-general-master/muzero.py
import copy import importlib import json import math import pathlib import pickle import sys import time import nevergrad import numpy import ray import torch from torch.utils.tensorboard import SummaryWriter import diagnose_model import models import replay_buffer import self_play import shared_storage import traine...
26,493
36.158485
211
py
muzero-general
muzero-general-master/models.py
import math from abc import ABC, abstractmethod import torch class MuZeroNetwork: def __new__(cls, config): if config.network == "fullyconnected": return MuZeroFullyConnectedNetwork( config.observation_shape, config.stacked_observations, len(con...
22,899
32.188406
115
py
muzero-general
muzero-general-master/replay_buffer.py
import copy import time import numpy import ray import torch import models @ray.remote class ReplayBuffer: """ Class which run in a dedicated thread to store played games and generate batch. """ def __init__(self, initial_checkpoint, initial_buffer, config): self.config = config sel...
14,754
38.451872
113
py
muzero-general
muzero-general-master/shared_storage.py
import copy import ray import torch @ray.remote class SharedStorage: """ Class which run in a dedicated thread to store the network weights and some information. """ def __init__(self, checkpoint, config): self.config = config self.current_checkpoint = copy.deepcopy(checkpoint) ...
1,124
26.439024
92
py
muzero-general
muzero-general-master/trainer.py
import copy import time import numpy import ray import torch import models @ray.remote class Trainer: """ Class which run in a dedicated thread to train a neural network and save it in the shared storage. """ def __init__(self, initial_checkpoint, config): self.config = config ...
11,315
36.594684
119
py
muzero-general
muzero-general-master/games/cartpole.py
import datetime import pathlib import gym import numpy import torch from .abstract_game import AbstractGame class MuZeroConfig: def __init__(self): # fmt: off # More information is available here: https://github.com/werner-duvaud/muzero-general/wiki/Hyperparameter-Optimization self.seed...
9,175
43.980392
226
py
muzero-general
muzero-general-master/games/spiel.py
import datetime import pathlib import numpy import torch from .abstract_game import AbstractGame # This is a Game wrapper for open_spiel games. It allows you to run any game in the open_spiel library. try: import pyspiel except ImportError: import sys sys.exit( "You need to install open_spiel...
11,728
38.35906
226
py
muzero-general
muzero-general-master/games/lunarlander.py
import datetime import pathlib import gym import numpy import torch from .abstract_game import AbstractGame class MuZeroConfig: def __init__(self): # fmt: off # More information is available here: https://github.com/werner-duvaud/muzero-general/wiki/Hyperparameter-Optimization self.seed...
25,665
38.365031
259
py
muzero-general
muzero-general-master/games/gomoku.py
import datetime import math import pathlib import numpy import torch from .abstract_game import AbstractGame class MuZeroConfig: def __init__(self): # fmt: off # More information is available here: https://github.com/werner-duvaud/muzero-general/wiki/Hyperparameter-Optimization self.see...
13,433
39.709091
226
py
muzero-general
muzero-general-master/games/connect4.py
import datetime import pathlib import numpy import torch from .abstract_game import AbstractGame class MuZeroConfig: def __init__(self): # fmt: off # More information is available here: https://github.com/werner-duvaud/muzero-general/wiki/Hyperparameter-Optimization self.seed = 0 # See...
14,244
40.051873
226
py
muzero-general
muzero-general-master/games/tictactoe.py
import datetime import pathlib import numpy import torch from .abstract_game import AbstractGame class MuZeroConfig: def __init__(self): # fmt: off # More information is available here: https://github.com/werner-duvaud/muzero-general/wiki/Hyperparameter-Optimization self.seed = 0 # See...
13,847
38.340909
226
py
muzero-general
muzero-general-master/games/gridworld.py
import datetime import pathlib import gym import numpy import torch from .abstract_game import AbstractGame try: import gym_minigrid except ModuleNotFoundError: raise ModuleNotFoundError('Please run "pip install gym_minigrid"') class MuZeroConfig: def __init__(self): # fmt: off # More i...
9,532
43.546729
226
py
muzero-general
muzero-general-master/games/simple_grid.py
import datetime import pathlib import numpy import torch from .abstract_game import AbstractGame class MuZeroConfig: def __init__(self): # fmt: off # More information is available here: https://github.com/werner-duvaud/muzero-general/wiki/Hyperparameter-Optimization self.seed = 0 # See...
9,933
42.191304
226
py
muzero-general
muzero-general-master/games/atari.py
import datetime import pathlib import gym import numpy import torch from .abstract_game import AbstractGame try: import cv2 except ModuleNotFoundError: raise ModuleNotFoundError('\nPlease run "pip install gym[atari]"') class MuZeroConfig: def __init__(self): # fmt: off # More informatio...
9,281
45.41
226
py
muzero-general
muzero-general-master/games/twentyone.py
""" This is a very simple form of twenty one. Ace only counts as value 1 not 1 or 11 for simplicity. This means that there is no such thing as a natural or two card 21. This is a good example of showing how it can provide a good solution to even luck based games. """ import datetime import pathlib import numpy import...
12,031
37.938511
226
py
muzero-general
muzero-general-master/games/breakout.py
import datetime import pathlib import gym import numpy import torch from .abstract_game import AbstractGame try: import cv2 except ModuleNotFoundError: raise ModuleNotFoundError('Please run "pip install gym[atari]"') class MuZeroConfig: def __init__(self): # fmt: off # More information ...
9,242
45.215
226
py
Probe-Ably
Probe-Ably-master/probe_ably/core/models/abstract_model.py
from abc import ABC, abstractmethod from typing import Dict from torch import Tensor from torch.nn import Module class AbstractModel(Module, ABC): subclasses = {} def __init_subclass__(cls, **kwargs): super().__init_subclass__(**kwargs) name = cls.__module__ + "." + cls.__qualname__ ...
1,831
28.079365
113
py
Probe-Ably
Probe-Ably-master/probe_ably/core/models/mlp.py
## ADAPTED FROM https://github.com/rycolab/pareto-probing/blob/master/src/h02_learn/model/mlp.py from typing import Dict import numpy as np import torch from probe_ably.core.models import AbstractModel from torch import Tensor, nn class MLPModel(AbstractModel): def __init__( self, params: Dict ): #...
3,240
33.115789
97
py
Probe-Ably
Probe-Ably-master/probe_ably/core/models/linear.py
### ADAPTED FROM https://github.com/rycolab/pareto-probing/blob/master/src/h02_learn/model/linear.py from typing import Dict import math import numpy as np import torch from probe_ably.core.models import AbstractModel from torch import Tensor, nn class LinearModel(AbstractModel): def __init__(self, params: Dict):...
2,718
32.567901
100
py
Probe-Ably
Probe-Ably-master/probe_ably/core/tasks/probing/prepare_data_for_probing_task.py
from overrides import overrides from prefect import Task from loguru import logger import sklearn from sklearn.model_selection import train_test_split from typing import Dict import torch from torch.utils.data import Dataset import numpy as np class PrepareDataForProbingTask(Task): @staticmethod def prepare_en...
5,938
36.588608
113
py
Probe-Ably
Probe-Ably-master/probe_ably/core/tasks/probing/deprobe_task.py
import random from typing import Dict, List from copy import copy, deepcopy import numpy as np import torch from loguru import logger from overrides import overrides from prefect import Task from probe_ably.core.metrics import AbstractIntraModelMetric from probe_ably.core.models import LinearModel from probe_ably.core....
12,158
33.347458
88
py
Probe-Ably
Probe-Ably-master/probe_ably/core/tasks/probing/train_probing_task.py
import random from typing import Dict from copy import copy, deepcopy import numpy as np import torch from loguru import logger from overrides import overrides from prefect import Task from probe_ably.core.metrics import AbstractIntraModelMetric from probe_ably.core.models import LinearModel from probe_ably.core.utils ...
12,280
33.594366
96
py
trac-trunk
trac-trunk/trac/web/chrome.py
# -*- coding: utf-8 -*- # # Copyright (C) 2005-2023 Edgewall Software # Copyright (C) 2005-2006 Christopher Lenz <cmlenz@gmx.de> # All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms # are also available at https:/...
63,552
39.274398
93
py
mtl-segmentation-mtl
mtl-segmentation-mtl/train_multi.py
""" training code """ from __future__ import absolute_import from __future__ import division import argparse import logging import os import torch from apex import amp from config import cfg, assert_and_infer_cfg from utils.misc import AverageMeter, prep_experiment, evaluate_eval_multi, fast_hist import datasets impor...
16,378
42.794118
123
py
mtl-segmentation-mtl
mtl-segmentation-mtl/demo_folder.py
import os import sys import time import argparse from PIL import Image import numpy as np import cv2 import torch from torch.backends import cudnn import torchvision.transforms as transforms import network from optimizer import restore_snapshot from datasets import cityscapes from config import assert_and_infer_cfg ...
3,199
36.209302
162
py
mtl-segmentation-mtl
mtl-segmentation-mtl/loss.py
""" Loss.py """ import logging import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from config import cfg def get_loss(args, tasks=None): """ Get the criterion based on the loss function args: commandline arguments return: criterion, criterion_val """ criter...
7,375
35.88
99
py
mtl-segmentation-mtl
mtl-segmentation-mtl/config.py
""" # Code adapted from: # https://github.com/facebookresearch/Detectron/blob/master/detectron/core/config.py Source License # Copyright (c) 2017-present, Facebook, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obta...
4,586
33.75
115
py
mtl-segmentation-mtl
mtl-segmentation-mtl/demo.py
import os import sys import argparse from PIL import Image import numpy as np import cv2 import torch from torch.backends import cudnn import torchvision.transforms as transforms import network from optimizer import restore_snapshot from datasets import cityscapes from config import assert_and_infer_cfg parser = arg...
2,091
32.741935
140
py
mtl-segmentation-mtl
mtl-segmentation-mtl/eval.py
""" Evaluation Script Support Two Modes: Pooling based inference and sliding based inference Pooling based inference is simply whole image inference. """ import os import logging import sys import argparse import re import queue import threading from math import ceil from datetime import datetime from tqdm import tqdm ...
22,353
35.171521
94
py
mtl-segmentation-mtl
mtl-segmentation-mtl/eval_multi.py
""" Evaluation Script Support Two Modes: Pooling based inference and sliding based inference Pooling based inference is simply whole image inference. """ import os import logging import sys import argparse import re import queue import threading from math import ceil from datetime import datetime from tqdm import tqdm ...
22,816
35.448882
94
py
mtl-segmentation-mtl
mtl-segmentation-mtl/train_multi_gradnorm.py
""" training code """ from __future__ import absolute_import from __future__ import division import argparse import logging import os import torch from apex import amp from config import cfg, assert_and_infer_cfg from utils.misc import AverageMeter, prep_experiment, evaluate_eval_multi, fast_hist import datasets impor...
18,734
43.395735
151
py
mtl-segmentation-mtl
mtl-segmentation-mtl/train.py
""" training code """ from __future__ import absolute_import from __future__ import division import argparse import logging import os import torch from apex import amp from config import cfg, assert_and_infer_cfg from utils.misc import AverageMeter, prep_experiment, evaluate_eval, fast_hist import datasets import loss...
13,258
39.547401
100
py
mtl-segmentation-mtl
mtl-segmentation-mtl/optimizer.py
""" Pytorch Optimizer and Scheduler Related Task """ import math import logging import torch from torch import optim from config import cfg def get_optimizer(args, net): """ Decide Optimizer (Adam or SGD) """ param_groups = net.parameters() if args.sgd: optimizer = optim.SGD(param_groups,...
4,514
38.26087
92
py
mtl-segmentation-mtl
mtl-segmentation-mtl/datasets/kitti.py
""" KITTI Dataset Loader http://www.cvlibs.net/datasets/kitti/eval_semseg.php?benchmark=semantics2015 """ import os import sys import numpy as np from PIL import Image from torch.utils import data import logging import datasets.uniform as uniform import datasets.cityscapes_labels as cityscapes_labels import json from ...
9,775
34.809524
133
py
mtl-segmentation-mtl
mtl-segmentation-mtl/datasets/sampler.py
""" # Code adapted from: # https://github.com/pytorch/pytorch/blob/master/torch/utils/data/distributed.py # # BSD 3-Clause License # # Copyright (c) 2017, # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions ar...
4,347
38.527273
118
py
mtl-segmentation-mtl
mtl-segmentation-mtl/datasets/tartanair_multi.py
""" TartanAir Multi Dataset Loader http://www.cvlibs.net/datasets/kitti/eval_semseg.php?benchmark=semantics2015 """ import os import sys import numpy as np from PIL import Image from torch.utils import data import logging import datasets.uniform as uniform import datasets.tartanair_labels as tartanair_labels import js...
13,150
38.139881
145
py
mtl-segmentation-mtl
mtl-segmentation-mtl/datasets/cityscapes.py
""" Cityscapes Dataset Loader """ import logging import json import os import numpy as np from PIL import Image from torch.utils import data import torchvision.transforms as transforms import datasets.uniform as uniform import datasets.cityscapes_labels as cityscapes_labels from config import cfg trainid_to_name = c...
19,309
38.488753
100
py