text
stringlengths
5
22M
id
stringlengths
12
177
metadata
dict
__index_level_0__
int64
0
1.37k
import logging import torch.nn as nn from ..runner import load_checkpoint class AlexNet(nn.Module): """AlexNet backbone. Args: num_classes (int): number of classes for classification. """ def __init__(self, num_classes=-1): super(AlexNet, self).__init__() self.num_classes =...
Cream/CDARTS/CDARTS_detection/mmcv/cnn/alexnet.py/0
{ "file_path": "Cream/CDARTS/CDARTS_detection/mmcv/cnn/alexnet.py", "repo_id": "Cream", "token_count": 1038 }
267
from __future__ import division import cv2 import numpy as np def imflip(img, direction='horizontal'): """Flip an image horizontally or vertically. Args: img (ndarray): Image to be flipped. direction (str): The flip direction, either "horizontal" or "vertical". Returns: ndarray:...
Cream/CDARTS/CDARTS_detection/mmcv/image/transforms/geometry.py/0
{ "file_path": "Cream/CDARTS/CDARTS_detection/mmcv/image/transforms/geometry.py", "repo_id": "Cream", "token_count": 3037 }
268
from .hook import Hook class ClosureHook(Hook): def __init__(self, fn_name, fn): assert hasattr(self, fn_name) assert callable(fn) setattr(self, fn_name, fn)
Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/closure.py/0
{ "file_path": "Cream/CDARTS/CDARTS_detection/mmcv/runner/hooks/closure.py", "repo_id": "Cream", "token_count": 85 }
269
import functools import sys import time from getpass import getuser from socket import gethostname import torch import torch.distributed as dist import mmcv def get_host_info(): return '{}@{}'.format(getuser(), gethostname()) def get_dist_info(): if torch.__version__ < '1.0': initialized = dist._i...
Cream/CDARTS/CDARTS_detection/mmcv/runner/utils.py/0
{ "file_path": "Cream/CDARTS/CDARTS_detection/mmcv/runner/utils.py", "repo_id": "Cream", "token_count": 840 }
270
import os import os.path as osp import subprocess import tempfile from mmcv.utils import requires_executable @requires_executable('ffmpeg') def convert_video(in_file, out_file, print_cmd=False, pre_options='', **kwargs): """Convert a video with ffmpeg. This provides a general api to ffmpeg...
Cream/CDARTS/CDARTS_detection/mmcv/video/processing.py/0
{ "file_path": "Cream/CDARTS/CDARTS_detection/mmcv/video/processing.py", "repo_id": "Cream", "token_count": 2503 }
271
from .anchor import * # noqa: F401, F403 from .bbox import * # noqa: F401, F403 from .evaluation import * # noqa: F401, F403 from .fp16 import * # noqa: F401, F403 from .mask import * # noqa: F401, F403 from .post_processing import * # noqa: F401, F403 from .utils import * # noqa: F401, F403
Cream/CDARTS/CDARTS_detection/mmdet/core/__init__.py/0
{ "file_path": "Cream/CDARTS/CDARTS_detection/mmdet/core/__init__.py", "repo_id": "Cream", "token_count": 118 }
272
from .base_sampler import BaseSampler from ..assign_sampling import build_sampler class CombinedSampler(BaseSampler): def __init__(self, pos_sampler, neg_sampler, **kwargs): super(CombinedSampler, self).__init__(**kwargs) self.pos_sampler = build_sampler(pos_sampler, **kwargs) self.neg_sa...
Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/combined_sampler.py/0
{ "file_path": "Cream/CDARTS/CDARTS_detection/mmdet/core/bbox/samplers/combined_sampler.py", "repo_id": "Cream", "token_count": 203 }
273
import functools from inspect import getfullargspec import torch from .utils import cast_tensor_type def auto_fp16(apply_to=None, out_fp32=False): """Decorator to enable fp16 training automatically. This decorator is useful when you write custom modules and want to support mixed precision training. If ...
Cream/CDARTS/CDARTS_detection/mmdet/core/fp16/decorators.py/0
{ "file_path": "Cream/CDARTS/CDARTS_detection/mmdet/core/fp16/decorators.py", "repo_id": "Cream", "token_count": 2998 }
274
import os.path as osp import mmcv import numpy as np from torch.utils.data import Dataset from mmdet.core import eval_map, eval_recalls from .pipelines import Compose from .registry import DATASETS @DATASETS.register_module class CustomDataset(Dataset): """Custom dataset for detection. Annotation format: ...
Cream/CDARTS/CDARTS_detection/mmdet/datasets/custom.py/0
{ "file_path": "Cream/CDARTS/CDARTS_detection/mmdet/datasets/custom.py", "repo_id": "Cream", "token_count": 3973 }
275
import os.path as osp import xml.etree.ElementTree as ET import mmcv import numpy as np from .custom import CustomDataset from .registry import DATASETS @DATASETS.register_module class XMLDataset(CustomDataset): def __init__(self, min_size=None, **kwargs): super(XMLDataset, self).__init__(**kwargs) ...
Cream/CDARTS/CDARTS_detection/mmdet/datasets/xml_style.py/0
{ "file_path": "Cream/CDARTS/CDARTS_detection/mmdet/datasets/xml_style.py", "repo_id": "Cream", "token_count": 1657 }
276
# -------------------------------------------------------- # Copyright (c) 2019 Jianyuan Guo (guojianyuan1@huawei.com) # -------------------------------------------------------- import torch import torch.nn as nn import torch.nn.functional as F from .mbblock_ops import OPS PRIMITIVES = [ 'ir_k3_e3', 'ir_k3_e6...
Cream/CDARTS/CDARTS_detection/mmdet/models/bbox_heads/auto_head/mbblock_head_search.py/0
{ "file_path": "Cream/CDARTS/CDARTS_detection/mmdet/models/bbox_heads/auto_head/mbblock_head_search.py", "repo_id": "Cream", "token_count": 747 }
277
import torch from mmdet.core import bbox2roi, build_assigner, build_sampler from .two_stage import TwoStageDetector from .. import builder from ..registry import DETECTORS @DETECTORS.register_module class MaskScoringRCNN(TwoStageDetector): """Mask Scoring RCNN. https://arxiv.org/abs/1903.00241 """ ...
Cream/CDARTS/CDARTS_detection/mmdet/models/detectors/mask_scoring_rcnn.py/0
{ "file_path": "Cream/CDARTS/CDARTS_detection/mmdet/models/detectors/mask_scoring_rcnn.py", "repo_id": "Cream", "token_count": 5128 }
278
from .fcn_mask_head import FCNMaskHead from .fused_semantic_head import FusedSemanticHead from .grid_head import GridHead from .htc_mask_head import HTCMaskHead from .maskiou_head import MaskIoUHead __all__ = [ 'FCNMaskHead', 'HTCMaskHead', 'FusedSemanticHead', 'GridHead', 'MaskIoUHead' ]
Cream/CDARTS/CDARTS_detection/mmdet/models/mask_heads/__init__.py/0
{ "file_path": "Cream/CDARTS/CDARTS_detection/mmdet/models/mask_heads/__init__.py", "repo_id": "Cream", "token_count": 113 }
279
# -------------------------------------------------------- # Copyright (c) 2019 Jianyuan Guo (guojianyuan1@huawei.com) # -------------------------------------------------------- import torch import torch.nn as nn import torch.nn.functional as F from mmcv.cnn import kaiming_init, constant_init, xavier_init from mmdet....
Cream/CDARTS/CDARTS_detection/mmdet/models/necks/search_pafpn.py/0
{ "file_path": "Cream/CDARTS/CDARTS_detection/mmdet/models/necks/search_pafpn.py", "repo_id": "Cream", "token_count": 2998 }
280
from .dcn import (DeformConv, DeformConvPack, ModulatedDeformConv, ModulatedDeformConvPack, DeformRoIPooling, DeformRoIPoolingPack, ModulatedDeformRoIPoolingPack, deform_conv, modulated_deform_conv, deform_roi_pooling) from .gcb import ContextBlock from .nms import ...
Cream/CDARTS/CDARTS_detection/mmdet/ops/__init__.py/0
{ "file_path": "Cream/CDARTS/CDARTS_detection/mmdet/ops/__init__.py", "repo_id": "Cream", "token_count": 408 }
281
#include <torch/extension.h> #include <cmath> #include <vector> int ROIPoolForwardLaucher(const at::Tensor features, const at::Tensor rois, const float spatial_scale, const int channels, const int height, const int width, const int num_rois, ...
Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_pool/src/roi_pool_cuda.cpp/0
{ "file_path": "Cream/CDARTS/CDARTS_detection/mmdet/ops/roi_pool/src/roi_pool_cuda.cpp", "repo_id": "Cream", "token_count": 1416 }
282
import inspect import mmcv class Registry(object): def __init__(self, name): self._name = name self._module_dict = dict() def __repr__(self): format_str = self.__class__.__name__ + '(name={}, items={})'.format( self._name, list(self._module_dict.keys())) return f...
Cream/CDARTS/CDARTS_detection/mmdet/utils/registry.py/0
{ "file_path": "Cream/CDARTS/CDARTS_detection/mmdet/utils/registry.py", "repo_id": "Cream", "token_count": 975 }
283
## Prerequisites - Ubuntu 16.04 - Python 3.7 - CUDA 11.1 (lower versions may work but were not tested) - NVIDIA GPU (>= 11G graphic memory) + CuDNN v7.3 This repository has been tested on RTX 3090. Configurations (e.g batch size, image patch size) may need to be changed on different platforms. ## Installation * Clone...
Cream/CDARTS/CDARTS_segmentation/README.md/0
{ "file_path": "Cream/CDARTS/CDARTS_segmentation/README.md", "repo_id": "Cream", "token_count": 670 }
284
# ------------------------------------------------------------------------------ # Loads Cityscapes panoptic dataset. # Written by Bowen Cheng (bcheng9@illinois.edu) # ------------------------------------------------------------------------------ import json import os import numpy as np from .cityscapes import Citys...
Cream/CDARTS/CDARTS_segmentation/dataloaders/segdatasets/cityscapes_panoptic.py/0
{ "file_path": "Cream/CDARTS/CDARTS_segmentation/dataloaders/segdatasets/cityscapes_panoptic.py", "repo_id": "Cream", "token_count": 2718 }
285
# ------------------------------------------------------------------------------ # Reference: https://github.com/facebookresearch/detectron2/blob/master/detectron2/evaluation/sem_seg_evaluation.py # Modified by Bowen Cheng (bcheng9@illinois.edu) # ------------------------------------------------------------------------...
Cream/CDARTS/CDARTS_segmentation/segmentation/evaluation/semantic.py/0
{ "file_path": "Cream/CDARTS/CDARTS_segmentation/segmentation/evaluation/semantic.py", "repo_id": "Cream", "token_count": 1892 }
286
# ------------------------------------------------------------------------------ # Loss functions. # Written by Bowen Cheng (bcheng9@illinois.edu) # ------------------------------------------------------------------------------ import torch import torch.nn as nn from torch.nn import functional as F class RegularCE(n...
Cream/CDARTS/CDARTS_segmentation/segmentation/model/loss/criterion.py/0
{ "file_path": "Cream/CDARTS/CDARTS_segmentation/segmentation/model/loss/criterion.py", "repo_id": "Cream", "token_count": 2230 }
287
# ------------------------------------------------------------------------------ # Saves raw outputs and targets. # Written by Bowen Cheng (bcheng9@illinois.edu) # ------------------------------------------------------------------------------ import os import numpy as np import PIL.Image as img import torch from .s...
Cream/CDARTS/CDARTS_segmentation/segmentation/utils/debug.py/0
{ "file_path": "Cream/CDARTS/CDARTS_segmentation/segmentation/utils/debug.py", "repo_id": "Cream", "token_count": 4617 }
288
from collections import namedtuple Genotype = namedtuple('Genotype', 'normal normal_concat reduce reduce_concat') PRIMITIVES = [ 'skip', 'conv', 'conv_di', 'conv_2x', 'conv_2x_di', ] NASNet = Genotype( normal = [ ('sep_conv_5x5', 1), ('sep_conv_3x3', 0), ('sep_conv_5x5', 0), ('s...
Cream/CDARTS/CDARTS_segmentation/tools/utils/genotypes.py/0
{ "file_path": "Cream/CDARTS/CDARTS_segmentation/tools/utils/genotypes.py", "repo_id": "Cream", "token_count": 1235 }
289
_BASE_: ../Cityscapes-PanopticSegmentation/Base-PanopticDeepLab-OS16.yaml MODEL: WEIGHTS: "detectron2://DeepLab/R-52.pkl" PIXEL_MEAN: [123.675, 116.280, 103.530] PIXEL_STD: [58.395, 57.120, 57.375] BACKBONE: NAME: "build_resnet_deeplab_backbone" RESNETS: DEPTH: 50 NORM: "SyncBN" RES5_MULTI_GRI...
Cream/CDARTS/CDARTS_segmentation/train/configs/ADE20K/512.yaml/0
{ "file_path": "Cream/CDARTS/CDARTS_segmentation/train/configs/ADE20K/512.yaml", "repo_id": "Cream", "token_count": 565 }
290
import numpy as np try: from utils.darts_utils import compute_latency_ms_tensorrt as compute_latency print("use TensorRT for latency test") except: from utils.darts_utils import compute_latency_ms_pytorch as compute_latency print("use PyTorch for latency test") import torch import torch.nn as nn import...
Cream/CDARTS/CDARTS_segmentation/train/seg_oprs.py/0
{ "file_path": "Cream/CDARTS/CDARTS_segmentation/train/seg_oprs.py", "repo_id": "Cream", "token_count": 11850 }
291
import math import torch import random import numpy as np import torch.distributed as dist from torch.utils.data import Sampler from PIL import Image, ImageEnhance, ImageOps class SubsetDistributedSampler(Sampler): """Sampler that restricts data loading to a subset of the dataset. It is especially useful in c...
Cream/CDARTS/benchmark201/datasets/data_utils.py/0
{ "file_path": "Cream/CDARTS/benchmark201/datasets/data_utils.py", "repo_id": "Cream", "token_count": 8183 }
292
import os import argparse parser = argparse.ArgumentParser(description='supernet training') parser.add_argument('path', type=str, default='train', help='mode') args = parser.parse_args() def main(): file_path = args.path info = {} cnt = 0 dataset_idx = 0 dataset = ['cifar10-va...
Cream/CDARTS/benchmark201/utils/get_info.py/0
{ "file_path": "Cream/CDARTS/benchmark201/utils/get_info.py", "repo_id": "Cream", "token_count": 690 }
293
import torch import torch.nn as nn import torch.nn.functional as F cos = nn.CosineSimilarity(dim=1, eps=1e-6) mse = nn.MSELoss() smooth_l1 = nn.SmoothL1Loss() class CrossEntropyLabelSmooth(nn.Module): def __init__(self, num_classes, epsilon): super(CrossEntropyLabelSmooth, self).__init__() self.n...
Cream/CDARTS/lib/models/loss.py/0
{ "file_path": "Cream/CDARTS/lib/models/loss.py", "repo_id": "Cream", "token_count": 573 }
294
import os import time import torch import torchvision from collections import OrderedDict from lib.utils.util import AverageMeter, accuracy, reduce_tensor # retrain function def train_epoch( epoch, model, loader, optimizer, loss_fn, cfg, lr_scheduler=None, saver=None, output_dir='', use_amp=False, ...
Cream/Cream/lib/core/retrain.py/0
{ "file_path": "Cream/Cream/lib/core/retrain.py", "repo_id": "Cream", "token_count": 2740 }
295
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. # Written by Hao Du and Houwen Peng # email: haodu8-c@my.cityu.edu.hk and houwen.peng@microsoft.com import sys import argparse import torch.nn as nn from torch import optim as optim from thop import profile, clever_format from timm.utils import...
Cream/Cream/lib/utils/util.py/0
{ "file_path": "Cream/Cream/lib/utils/util.py", "repo_id": "Cream", "token_count": 2691 }
296
''' Build trainining/testing datasets ''' import os import json from torchvision import datasets, transforms from torchvision.datasets.folder import ImageFolder, default_loader import torch from timm.data.constants import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD from timm.data import create_transform try: fro...
Cream/EfficientViT/classification/data/datasets.py/0
{ "file_path": "Cream/EfficientViT/classification/data/datasets.py", "repo_id": "Cream", "token_count": 2417 }
297
#!/usr/bin/env bash CONFIG=$1 GPUS=$2 PORT=${PORT:-29500} PYTHONPATH="$(dirname $0)/..":$PYTHONPATH \ python -m torch.distributed.launch --nproc_per_node=$GPUS --master_port=$PORT \ $(dirname "$0")/train.py $CONFIG --launcher pytorch ${@:3}
Cream/EfficientViT/downstream/dist_train.sh/0
{ "file_path": "Cream/EfficientViT/downstream/dist_train.sh", "repo_id": "Cream", "token_count": 108 }
298
# Mini-DeiT This repo is for MiniViT for DeiTs. ## Model Zoo Model | Params. | Input | Top-1 Acc. % | Top-5 Acc. % | Download link --- |:---:|:---:|:---:|:---:|:---: Mini-DeiT-Ti | 3M | 224x224 | 73.0 | 91.6 | [model](https://github.com/DominickZhang/MiniViT-model-zoo/releases/download/v1.0.0/mini_deit_tiny_patch16_2...
Cream/MiniViT/Mini-DeiT/README.md/0
{ "file_path": "Cream/MiniViT/Mini-DeiT/README.md", "repo_id": "Cream", "token_count": 2032 }
299
""" Misc functions, including distributed helpers. Mostly copy-paste from torchvision references. """ import io import os import time from collections import defaultdict, deque import datetime import torch import torch.distributed as dist class SmoothedValue(object): """Track a series of values and provide acce...
Cream/MiniViT/Mini-DeiT/utils.py/0
{ "file_path": "Cream/MiniViT/Mini-DeiT/utils.py", "repo_id": "Cream", "token_count": 3386 }
300
import io import os import time import torch.distributed as dist import torch.utils.data as data from PIL import Image from .zipreader import is_zip_path, ZipReader def has_file_allowed_extension(filename, extensions): """Checks if a file is an allowed extension. Args: filename (string): path to a fi...
Cream/MiniViT/Mini-Swin/data/cached_image_folder.py/0
{ "file_path": "Cream/MiniViT/Mini-Swin/data/cached_image_folder.py", "repo_id": "Cream", "token_count": 3975 }
301
import os import torch import torch.nn as nn import torch.distributed as dist import torch.nn.functional as F from timm.models.layers import DropPath, to_2tuple, trunc_normal_ try: # noinspection PyUnresolvedReferences from apex import amp except ImportError: amp = None import argparse from config import g...
Cream/MiniViT/Mini-Swin/utils.py/0
{ "file_path": "Cream/MiniViT/Mini-Swin/utils.py", "repo_id": "Cream", "token_count": 4868 }
302
import torch import torch.nn as nn from torch.nn import functional as F try: import torch.distributed.nn from torch import distributed as dist has_distributed = True except ImportError: has_distributed = False try: import horovod.torch as hvd except ImportError: hvd = None def gather_feature...
Cream/TinyCLIP/src/open_clip/loss.py/0
{ "file_path": "Cream/TinyCLIP/src/open_clip/loss.py", "repo_id": "Cream", "token_count": 3078 }
303
from typing import Optional, Sequence, Tuple import torch import torch.nn as nn import torchvision.transforms.functional as F from torchvision.transforms import Normalize, Compose, RandomResizedCrop, InterpolationMode, ToTensor, Resize, \ CenterCrop from .constants import OPENAI_DATASET_MEAN, OPENAI_DATASET_STD ...
Cream/TinyCLIP/src/open_clip/transform.py/0
{ "file_path": "Cream/TinyCLIP/src/open_clip/transform.py", "repo_id": "Cream", "token_count": 2065 }
304
import numpy as np def assign_learning_rate(optimizer, new_lr): if isinstance(optimizer, list): for opt in optimizer: assign_learning_rate(opt, new_lr) else: for param_group in optimizer.param_groups: param_group["lr"] = new_lr def _warmup_lr(base_lr, warmup_length, s...
Cream/TinyCLIP/src/training/scheduler.py/0
{ "file_path": "Cream/TinyCLIP/src/training/scheduler.py", "repo_id": "Cream", "token_count": 1286 }
305
import os # from torchvision.datasets import CIFAR100, CIFAR10, MNIST, QMNIST, KMNIST, FashionMNIST, ImageNet, ImageFolder from torchvision.datasets import CIFAR100, CIFAR10, MNIST, KMNIST, FashionMNIST, ImageFolder try: from torchvision.datasets import Places365 has_places365 = True except ImportError: ha...
Cream/TinyViT/data/augmentation/dataset_factory.py/0
{ "file_path": "Cream/TinyViT/data/augmentation/dataset_factory.py", "repo_id": "Cream", "token_count": 2475 }
306
""" Real labels evaluator for ImageNet Paper: `Are we done with ImageNet?` - https://arxiv.org/abs/2006.07159 Based on Numpy example at https://github.com/google-research/reassessed-imagenet Hacked together by / Copyright 2020 Ross Wightman """ import os import json import numpy as np class RealLabelsImagenet: ...
Cream/TinyViT/data/augmentation/real_labels.py/0
{ "file_path": "Cream/TinyViT/data/augmentation/real_labels.py", "repo_id": "Cream", "token_count": 742 }
307
# -------------------------------------------------------- # TinyViT Main (train/validate) # Copyright (c) 2022 Microsoft # Based on the code: Swin Transformer # (https://github.com/microsoft/swin-transformer) # Add distillation with saved teacher logits # -------------------------------------------------------- imp...
Cream/TinyViT/main.py/0
{ "file_path": "Cream/TinyViT/main.py", "repo_id": "Cream", "token_count": 10302 }
308
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import torch.utils.data import torchvision from .coco import build as build_coco def get_coco_api_from_dataset(dataset): for _ in range(10): # if isinstance(dataset, torchvision.datasets.CocoDetection): # break if ...
Cream/iRPE/DETR-with-iRPE/datasets/__init__.py/0
{ "file_path": "Cream/iRPE/DETR-with-iRPE/datasets/__init__.py", "repo_id": "Cream", "token_count": 365 }
309
"""Functional interface""" import warnings import math import torch from torch._C import _infer_size, _add_docstr from torch.nn import _reduction as _Reduction from torch.nn.modules import utils from torch.nn.modules.utils import _single, _pair, _triple, _list_with_default from torch.nn import grad # noqa: F401 from ...
Cream/iRPE/DETR-with-iRPE/models/rpe_attention/rpe_attention_function.py/0
{ "file_path": "Cream/iRPE/DETR-with-iRPE/models/rpe_attention/rpe_attention_function.py", "repo_id": "Cream", "token_count": 7847 }
310
Hiring research interns for neural architecture search projects: houwen.peng@microsoft.com # Rethinking and Improving Relative Position Encoding for Vision Transformer [[Paper]](https://openaccess.thecvf.com/content/ICCV2021/html/Wu_Rethinking_and_Improving_Relative_Position_Encoding_for_Vision_Transformer_ICCV_2021_...
Cream/iRPE/DeiT-with-iRPE/README.md/0
{ "file_path": "Cream/iRPE/DeiT-with-iRPE/README.md", "repo_id": "Cream", "token_count": 2509 }
311
# Copyright (c) 2015-present, Facebook, Inc. # All rights reserved. """ A script to run multinode training with submitit. """ import argparse import os import uuid from pathlib import Path import main as classification import submitit def parse_args(): classification_parser = classification.get_args_parser() ...
Cream/iRPE/DeiT-with-iRPE/run_with_submitit.py/0
{ "file_path": "Cream/iRPE/DeiT-with-iRPE/run_with_submitit.py", "repo_id": "Cream", "token_count": 1646 }
312
import torch as th import torch.nn as nn import torch.nn.functional as F def linear_combination(x, y, epsilon): return epsilon*x + (1-epsilon)*y def reduce_loss(loss, reduction='mean'): return loss.mean() if reduction == 'mean' \ else loss.sum() if reduction == 'sum' else loss class LabelS...
CvT/lib/core/loss.py/0
{ "file_path": "CvT/lib/core/loss.py", "repo_id": "CvT", "token_count": 685 }
313
import pickle import torch import torch.distributed as dist class Comm(object): def __init__(self, local_rank=0): self.local_rank = 0 @property def world_size(self): if not dist.is_available(): return 1 if not dist.is_initialized(): return 1 return...
CvT/lib/utils/comm.py/0
{ "file_path": "CvT/lib/utils/comm.py", "repo_id": "CvT", "token_count": 1625 }
314
import sys sys.path.append('../') import unittest import numpy as np import pandas as pd import shutil import os import invoker class TestErrorInput(unittest.TestCase): def setUp(self): self.__input_path = './error_test_input_file.csv' self.__detect_mode = 'AnomalyOnly' self.__timestamp_c...
anomalydetector/aml_component/tests/test_error_input.py/0
{ "file_path": "anomalydetector/aml_component/tests/test_error_input.py", "repo_id": "anomalydetector", "token_count": 4170 }
315
""" Copyright (C) Microsoft Corporation. All rights reserved.​ ​ Microsoft Corporation ("Microsoft") grants you a nonexclusive, perpetual, royalty-free right to use, copy, and modify the software code provided by us ("Software Code"). You may not sublicense the Software Code or any use of it (except to your affiliates...
anomalydetector/srcnn/net.py/0
{ "file_path": "anomalydetector/srcnn/net.py", "repo_id": "anomalydetector", "token_count": 1578 }
316
{ "python.testing.pytestArgs": [ "tests" ], "python.testing.unittestEnabled": false, "python.testing.nosetestsEnabled": false, "python.testing.pytestEnabled": true, "cmake.configureOnOpen": false }
archai/.vscode/settings.json/0
{ "file_path": "archai/.vscode/settings.json", "repo_id": "archai", "token_count": 94 }
317
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from typing import List from logging import Handler import os import time from overrides import overrides from threading import Lock class AtomicFileHandler(Handler): """ This class opens and writes entire file instead of appending one...
archai/archai/common/atomic_file_handler.py/0
{ "file_path": "archai/archai/common/atomic_file_handler.py", "repo_id": "archai", "token_count": 755 }
318
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. import argparse import os import glob import sys import logging import datetime import platform import time import numpy as np import re from torch import Tensor from azure.data.tables import TableServiceClient, UpdateMode, EntityProperty, EdmType...
archai/archai/common/store.py/0
{ "file_path": "archai/archai/common/store.py", "repo_id": "archai", "token_count": 13684 }
319
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from typing import Callable, Optional from overrides import overrides from torch.utils.data import Dataset from torchvision.datasets import KMNIST, MNIST, QMNIST, FashionMNIST from torchvision.transforms import ToTensor from archai.api.dataset_...
archai/archai/datasets/cv/mnist_dataset_provider.py/0
{ "file_path": "archai/archai/datasets/cv/mnist_dataset_provider.py", "repo_id": "archai", "token_count": 1031 }
320
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from typing import List, Optional from overrides import overrides from archai.api.dataset_provider import DatasetProvider from archai.common.distributed_utils import sync_workers from archai.datasets.nlp.nvidia_dataset_provider_utils import Cor...
archai/archai/datasets/nlp/nvidia_dataset_provider.py/0
{ "file_path": "archai/archai/datasets/nlp/nvidia_dataset_provider.py", "repo_id": "archai", "token_count": 773 }
321
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from archai.api.dataset_provider import DatasetProvider from archai.discrete_search.api.archai_model import ArchaiModel from archai.discrete_search.api.model_evaluator import ModelEvaluator, AsyncModelEvaluator from archai.discrete_search.api.pre...
archai/archai/discrete_search/api/__init__.py/0
{ "file_path": "archai/archai/discrete_search/api/__init__.py", "repo_id": "archai", "token_count": 275 }
322
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from typing import Any, Dict, List, Optional, Tuple, Union import onnxruntime as rt import torch from overrides import overrides from archai.common.timing import MeasureBlockTime from archai.discrete_search.api.archai_model import ArchaiModel f...
archai/archai/discrete_search/evaluators/onnx_model.py/0
{ "file_path": "archai/archai/discrete_search/evaluators/onnx_model.py", "repo_id": "archai", "token_count": 1514 }
323
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. import itertools from collections import OrderedDict from copy import deepcopy from functools import reduce from random import Random from typing import Any, Dict, List, Optional, Tuple from archai.discrete_search.search_spaces.config.arch_confi...
archai/archai/discrete_search/search_spaces/config/arch_param_tree.py/0
{ "file_path": "archai/archai/discrete_search/search_spaces/config/arch_param_tree.py", "repo_id": "archai", "token_count": 2712 }
324
''' Adapted from https://github.com/ctlllll/SGConv ''' import math from functools import partial import torch import torch.nn as nn import torch.nn.functional as F from transformers import PretrainedConfig from einops import rearrange import opt_einsum as oe from archai.discrete_search.search_spaces.config import...
archai/archai/discrete_search/search_spaces/nlp/tfpp/ops/sgconv.py/0
{ "file_path": "archai/archai/discrete_search/search_spaces/nlp/tfpp/ops/sgconv.py", "repo_id": "archai", "token_count": 9690 }
325
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from __future__ import annotations from typing import Any, Dict, Optional import torch import transformers from archai.quantization.quantizers import FakeDynamicQuant class FakeDynamicQuantHFConv1D(transformers.modeling_utils.Conv1D): ""...
archai/archai/quantization/nlp/modules.py/0
{ "file_path": "archai/archai/quantization/nlp/modules.py", "repo_id": "archai", "token_count": 1899 }
326
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from typing import Optional from overrides import overrides from archai.common.config import Config from archai.common.ordered_dict_logger import get_global_logger from archai.supergraph.nas.arch_trainer import ArchTrainer from archai.supergrap...
archai/archai/supergraph/algos/didarts/didarts_arch_trainer.py/0
{ "file_path": "archai/archai/supergraph/algos/didarts/didarts_arch_trainer.py", "repo_id": "archai", "token_count": 719 }
327
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. import copy from typing import List, Tuple from overrides import overrides from archai.common.config import Config from archai.supergraph.algos.gumbelsoftmax.gs_op import GsOp from archai.supergraph.nas.model_desc import ( CellType, Con...
archai/archai/supergraph/algos/gumbelsoftmax/gs_model_desc_builder.py/0
{ "file_path": "archai/archai/supergraph/algos/gumbelsoftmax/gs_model_desc_builder.py", "repo_id": "archai", "token_count": 1058 }
328
"""Model specification for module connectivity individuals. This module handles pruning the unused parts of the computation graph but should avoid creating any TensorFlow models (this is done inside model_builder.py). """ from __future__ import absolute_import, division, print_function import copy import numpy as n...
archai/archai/supergraph/algos/nasbench101/model_spec.py/0
{ "file_path": "archai/archai/supergraph/algos/nasbench101/model_spec.py", "repo_id": "archai", "token_count": 1836 }
329
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. import math as ma from typing import Optional import torch from overrides import overrides from torch import Tensor, nn from torch.optim.optimizer import Optimizer from archai.common import ml_utils from archai.common.common import get_conf fro...
archai/archai/supergraph/algos/xnas/xnas_arch_trainer.py/0
{ "file_path": "archai/archai/supergraph/algos/xnas/xnas_arch_trainer.py", "repo_id": "archai", "token_count": 3257 }
330
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. import torchvision from overrides import overrides from torchvision.transforms import transforms from archai.common import utils from archai.common.config import Config from archai.supergraph.datasets.dataset_provider import ( DatasetProvide...
archai/archai/supergraph/datasets/providers/fashion_mnist_provider.py/0
{ "file_path": "archai/archai/supergraph/datasets/providers/fashion_mnist_provider.py", "repo_id": "archai", "token_count": 784 }
331
import os import torch import torch.nn as nn __all__ = ['MobileNetV2', 'mobilenet_v2'] class ConvBNReLU(nn.Sequential): def __init__(self, in_planes, out_planes, kernel_size=3, stride=1, groups=1): padding = (kernel_size - 1) // 2 super(ConvBNReLU, self).__init__( nn.Conv2d(in_planes...
archai/archai/supergraph/models/mobilenetv2.py/0
{ "file_path": "archai/archai/supergraph/models/mobilenetv2.py", "repo_id": "archai", "token_count": 2133 }
332
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from typing import Iterable, List, Optional from overrides import EnforceOverrides, overrides from torch import nn from archai.supergraph.nas.arch_module import ArchModule from archai.supergraph.nas.dag_edge import DagEdge from archai.supergrap...
archai/archai/supergraph/nas/cell.py/0
{ "file_path": "archai/archai/supergraph/nas/cell.py", "repo_id": "archai", "token_count": 1305 }
333
import itertools import math import os from collections import OrderedDict import torch from torch import nn from torch.nn.parallel.data_parallel import DataParallel from tqdm import tqdm from archai.common import ml_utils, utils from archai.common.common import get_tb_writer from archai.common.ordered_dict_logger im...
archai/archai/supergraph/utils/augmented_trainer.py/0
{ "file_path": "archai/archai/supergraph/utils/augmented_trainer.py", "repo_id": "archai", "token_count": 5463 }
334
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. import json import math import os import time from typing import Any, Dict, Iterable, Iterator, Optional, Tuple, Union import deepspeed import mlflow import torch from deepspeed.pipe import PipelineModule from deepspeed.utils import RepeatingLoa...
archai/archai/trainers/nlp/ds_trainer.py/0
{ "file_path": "archai/archai/trainers/nlp/ds_trainer.py", "repo_id": "archai", "token_count": 6868 }
335
autoaug: model: type: shakeshake26_2x112d loader: aug: fa_reduced_cifar10 cutout: 16 batch: 512 epochs: 1800 lr_schedule: type: 'cosine' warmup: multiplier: 4 epochs: 5 optimizer: type: sgd lr: 0.01 nesterov: True decay: 0.002
archai/confs/aug/shake26_2x112d_cifar_b512.yaml/0
{ "file_path": "archai/confs/aug/shake26_2x112d_cifar_b512.yaml", "repo_id": "archai", "token_count": 150 }
336
dataset: dataroot: '$default_dataroot' # folder where directory for each dataset exist, empty string means chose default based on OS which is typically ~/dataroot # Typically, create symbolic link ~/dataroot pointing to yout dataset location # cd %USERPROFILE% # mklink /D dataroot E:\datasets dataset_eval: dataro...
archai/confs/datasets/dataroot.yaml/0
{ "file_path": "archai/confs/datasets/dataroot.yaml", "repo_id": "archai", "token_count": 128 }
337
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. # Root image to be based # Available images: https://catalog.ngc.nvidia.com/orgs/nvidia/containers/pytorch/tags FROM nvcr.io/nvidia/pytorch:22.10-py3 # Labels for the docker LABEL description="NVIDIA Docker with Archai" \ repository="archa...
archai/docker/Dockerfile/0
{ "file_path": "archai/docker/Dockerfile", "repo_id": "archai", "token_count": 302 }
338
<jupyter_start><jupyter_text>QuickStartIn this Notebook we run Archai's [Quickstart](https://microsoft.github.io/archai/getting_started/quick_start.html) example on Azure Machine Learning. Prerequisites- Python 3.7 or later- An Azure subscription- An Azure Resource Group- An Azure Machine Learning [Workspace](https://l...
archai/docs/advanced_guide/cloud/azure/notebooks/quickstart/quickstart.ipynb/0
{ "file_path": "archai/docs/advanced_guide/cloud/azure/notebooks/quickstart/quickstart.ipynb", "repo_id": "archai", "token_count": 1859 }
339
<jupyter_start><jupyter_text>Training a CV-based ModelTraining a CV-based model with PyTorch-Lightning is a simplified process, where the model architecture, loss function, and training process are defined using the `LightningModule`. Archai offers a set of dataset providers to load and pre-process the data. Additional...
archai/docs/getting_started/notebooks/cv/pl_trainer.ipynb/0
{ "file_path": "archai/docs/getting_started/notebooks/cv/pl_trainer.ipynb", "repo_id": "archai", "token_count": 1388 }
340
<jupyter_start><jupyter_text>Training NLP-based Models with NVIDIA Defining the Model<jupyter_code>from transformers import GPT2Config, GPT2LMHeadModel config = GPT2Config( vocab_size=50257, n_positions=16, n_embd=512, n_layer=4, n_head=8, embd_pdrop=0.0, attn_pdrop=0.0, use_cache=Fals...
archai/docs/getting_started/notebooks/nlp/nvidia_trainer.ipynb/0
{ "file_path": "archai/docs/getting_started/notebooks/nlp/nvidia_trainer.ipynb", "repo_id": "archai", "token_count": 983 }
341
Datasets ======== .. toctree:: :maxdepth: 2 archai.datasets.cv archai.datasets.nlp
archai/docs/reference/api/archai.datasets.rst/0
{ "file_path": "archai/docs/reference/api/archai.datasets.rst", "repo_id": "archai", "token_count": 44 }
342
Search Spaces ============= .. toctree:: :maxdepth: 2 archai.discrete_search.search_spaces.benchmark archai.discrete_search.search_spaces.config archai.discrete_search.search_spaces.cv archai.discrete_search.search_spaces.nlp
archai/docs/reference/api/archai.discrete_search.search_spaces.rst/0
{ "file_path": "archai/docs/reference/api/archai.discrete_search.search_spaces.rst", "repo_id": "archai", "token_count": 91 }
343
XNAS ==== Architecture Trainer -------------------- .. automodule:: archai.supergraph.algos.xnas.xnas_arch_trainer :members: :undoc-members: Experiment Runner ----------------- .. automodule:: archai.supergraph.algos.xnas.xnas_exp_runner :members: :undoc-members: Model Description Builder -------------...
archai/docs/reference/api/archai.supergraph.algos.xnas.rst/0
{ "file_path": "archai/docs/reference/api/archai.supergraph.algos.xnas.rst", "repo_id": "archai", "token_count": 196 }
344
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. [tool.black] line-length = 120
archai/pyproject.toml/0
{ "file_path": "archai/pyproject.toml", "repo_id": "archai", "token_count": 29 }
345
<jupyter_start><jupyter_text>How-To Evaluate a Custom Task with LM-Eval HarnessEven though `lm_eval` framework supports more than 200 tasks, one might want to implement an additional one. With that in mind, this tutorial walks through the process of creating a custom task, including it in the registry and evaluating mo...
archai/research/lm_eval_harness/tutorials/custom_task_evaluation.ipynb/0
{ "file_path": "archai/research/lm_eval_harness/tutorials/custom_task_evaluation.ipynb", "repo_id": "archai", "token_count": 1837 }
346
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. """ Script to prepare flower102 dataset for pytorch dataloader. """ import argparse import os import tempfile from collections import defaultdict from typing import Dict, List from torchvision.datasets.utils import download_and_extract_archive,...
archai/scripts/supergraph/download_datasets/flower102_install.py/0
{ "file_path": "archai/scripts/supergraph/download_datasets/flower102_install.py", "repo_id": "archai", "token_count": 2349 }
347
from archai.common.common import common_init from archai.supergraph.algos.nasbench101.nasbench101_dataset import Nasbench101Dataset from archai.supergraph.datasets import data from archai.supergraph.utils.trainer import Trainer def main(): # 6, 7, 9, 10, 16 # model = model_builder.build(model_builder.EXAMPLE...
archai/scripts/supergraph/nasbench101/pytorch_train.py/0
{ "file_path": "archai/scripts/supergraph/nasbench101/pytorch_train.py", "repo_id": "archai", "token_count": 324 }
348
# Training Models with Archai This folder contains the necessary files and instructions to train models using Archai. ## Installation Before you can start training models, you need to install Archai. To do so, you can follow these instructions: 1. Open your terminal and run the following command: ```bash p...
archai/scripts/trainers/README.md/0
{ "file_path": "archai/scripts/trainers/README.md", "repo_id": "archai", "token_count": 914 }
349
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. import os import json import sys from archai.common.store import ArchaiStore CONNECTION_NAME = 'MODEL_STORAGE_CONNECTION_STRING' def cleanup_stale_pods(store: ArchaiStore): """ This script looks for kubernetes pods that are no longer runni...
archai/tasks/face_segmentation/aml/azure/cleanup_stale_pods.py/0
{ "file_path": "archai/tasks/face_segmentation/aml/azure/cleanup_stale_pods.py", "repo_id": "archai", "token_count": 824 }
350
<# .SYNOPSIS . .DESCRIPTION This is a handy powershell script that can cleanup old images from your azure container registry. You can find the password in your Azure portal for the container registry under the tab named Access Keys. .PARAMETER password Specifies a password. #> param( [Parameter(Ma...
archai/tasks/face_segmentation/aml/docker/quantizer/cleanup.ps1/0
{ "file_path": "archai/tasks/face_segmentation/aml/docker/quantizer/cleanup.ps1", "repo_id": "archai", "token_count": 492 }
351
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. import os import json from pathlib import Path from typing import List, Optional, Union from overrides import overrides from archai.discrete_search.api.archai_model import ArchaiModel from archai.discrete_search.api.model_evaluator import AsyncMo...
archai/tasks/face_segmentation/aml/training/aml_training_evaluator.py/0
{ "file_path": "archai/tasks/face_segmentation/aml/training/aml_training_evaluator.py", "repo_id": "archai", "token_count": 2468 }
352
search: search_space: name: hgnet params: num_classes: 18 img_size: [256, 256] # (w, h) in_channels: 3 op_subset: ['conv3x3', 'conv5x5', 'conv7x7'] stem_strides: [2] # Number of downsampling blocks (without counting stem conv) num_blocks: 5 # Maxi...
archai/tasks/face_segmentation/confs/cpu_search.yaml/0
{ "file_path": "archai/tasks/face_segmentation/confs/cpu_search.yaml", "repo_id": "archai", "token_count": 393 }
353
# Text Generation At Archai, we recognize the significance of discovering the optimal neural architecture to attain the highest performance in text generation. For this purpose, we have created an advanced neural architecture search method known as the Lightweight Transformer Search (LTS). This innovative method enabl...
archai/tasks/text_generation/README.md/0
{ "file_path": "archai/tasks/text_generation/README.md", "repo_id": "archai", "token_count": 2944 }
354
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. import os from archai.common.ordered_dict_logger import OrderedDictLogger def test_ordered_dict_logger(): # Assert that the default attributes are defined logger = OrderedDictLogger(file_path="log.yaml", delay=0.0) assert logger.fi...
archai/tests/common/test_ordered_dict_logger.py/0
{ "file_path": "archai/tests/common/test_ordered_dict_logger.py", "repo_id": "archai", "token_count": 405 }
355
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. import numpy as np import pytest from overrides import overrides from archai.discrete_search.api.predictor import MeanVar, Predictor @pytest.fixture def surrogate_model(search_objectives): class DummyPredictor(Predictor): def __ini...
archai/tests/discrete_search/algos/fixtures/surrogate_model.py/0
{ "file_path": "archai/tests/discrete_search/algos/fixtures/surrogate_model.py", "repo_id": "archai", "token_count": 406 }
356
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. import pytest from archai.discrete_search.evaluators.nlp.transformer_flex_memory import ( TransformerFlexOnnxMemory, ) from archai.discrete_search.search_spaces.nlp.transformer_flex.search_space import ( TransformerFlexSearchSpace, ) @...
archai/tests/discrete_search/evaluators/nlp/test_transformer_flex_memory.py/0
{ "file_path": "archai/tests/discrete_search/evaluators/nlp/test_transformer_flex_memory.py", "repo_id": "archai", "token_count": 222 }
357
# Copyright (c) Microsoft Corporation. # Licensed under the MIT license. from archai.common import utils class A: def __init__(self): self.a1 = 3.14 class B: def __init__(self): self.a = A() self.i = 3 self.s = "eeee" self.d = {"k": {"kk": 5}} def test_state_dict()...
archai/tests/supergraph/test_state_dict.py/0
{ "file_path": "archai/tests/supergraph/test_state_dict.py", "repo_id": "archai", "token_count": 257 }
358
include LICENSE.txt
azure-devops-python-api/azure-devops/MANIFEST.in/0
{ "file_path": "azure-devops-python-api/azure-devops/MANIFEST.in", "repo_id": "azure-devops-python-api", "token_count": 6 }
359
# -------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------...
azure-devops-python-api/azure-devops/azure/devops/released/member_entitlement_management/__init__.py/0
{ "file_path": "azure-devops-python-api/azure-devops/azure/devops/released/member_entitlement_management/__init__.py", "repo_id": "azure-devops-python-api", "token_count": 493 }
360
# -------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------...
azure-devops-python-api/azure-devops/azure/devops/released/work_item_tracking/__init__.py/0
{ "file_path": "azure-devops-python-api/azure-devops/azure/devops/released/work_item_tracking/__init__.py", "repo_id": "azure-devops-python-api", "token_count": 1035 }
361
# -------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------...
azure-devops-python-api/azure-devops/azure/devops/v7_0/npm/npm_client.py/0
{ "file_path": "azure-devops-python-api/azure-devops/azure/devops/v7_0/npm/npm_client.py", "repo_id": "azure-devops-python-api", "token_count": 14386 }
362
# -------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------...
azure-devops-python-api/azure-devops/azure/devops/v7_1/client_factory.py/0
{ "file_path": "azure-devops-python-api/azure-devops/azure/devops/v7_1/client_factory.py", "repo_id": "azure-devops-python-api", "token_count": 8654 }
363
# -------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------...
azure-devops-python-api/azure-devops/azure/devops/v7_1/elastic/__init__.py/0
{ "file_path": "azure-devops-python-api/azure-devops/azure/devops/v7_1/elastic/__init__.py", "repo_id": "azure-devops-python-api", "token_count": 227 }
364
# -------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------...
azure-devops-python-api/azure-devops/azure/devops/v7_1/file_container/file_container_client.py/0
{ "file_path": "azure-devops-python-api/azure-devops/azure/devops/v7_1/file_container/file_container_client.py", "repo_id": "azure-devops-python-api", "token_count": 3019 }
365
# -------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------...
azure-devops-python-api/azure-devops/azure/devops/v7_1/location/location_client.py/0
{ "file_path": "azure-devops-python-api/azure-devops/azure/devops/v7_1/location/location_client.py", "repo_id": "azure-devops-python-api", "token_count": 4313 }
366