python_code
stringlengths
0
456k
#!/usr/bin/env python ''' example to detect upright people in images using HOG features ''' # Python 2/3 compatibility from __future__ import print_function import numpy as np import cv2 as cv def inside(r, q): rx, ry, rw, rh = r qx, qy, qw, qh = q return rx > qx and ry > qy and rx + rw < qx + qw and r...
#!/usr/bin/env python ''' face detection using haar cascades ''' # Python 2/3 compatibility from __future__ import print_function import numpy as np import cv2 as cv def detect(img, cascade): rects = cascade.detectMultiScale(img, scaleFactor=1.275, minNeighbors=4, minSize=(30, 30), ...
#!/usr/bin/env python ''' =============================================================================== QR code detect and decode pipeline. =============================================================================== ''' import os import numpy as np import cv2 as cv from tests_common import NewOpenCVTests class ...
############################################################################### # # IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. # # By downloading, copying, installing or using the software you agree to this license. # If you do not agree to this license, do not download, install, # copy or us...
############################################################################### # # IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. # # By downloading, copying, installing or using the software you agree to this license. # If you do not agree to this license, do not download, install, # copy or us...
############################################################################### # # IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. # # By downloading, copying, installing or using the software you agree to this license. # If you do not agree to this license, do not download, install, # copy or us...
#!/usr/bin/env python from __future__ import print_function import sys, os, re classes_ignore_list = ( 'OpenCV(Test)?Case', 'OpenCV(Test)?Runner', 'CvException', ) funcs_ignore_list = ( '\w+--HashCode', 'Mat--MatLong', '\w+--Equals', 'Core--MinMaxLocResult', ) class JavaParser: def _...
#!/usr/bin/env python import sys, re, os.path, errno, fnmatch import json import logging import codecs from shutil import copyfile from pprint import pformat from string import Template if sys.version_info[0] >= 3: from io import StringIO else: import io class StringIO(io.StringIO): def write(self...
#!/usr/bin/env python import cv2 as cv from tests_common import NewOpenCVTests class knearest_test(NewOpenCVTests): def test_load(self): k_nearest = cv.ml.KNearest_load(self.find_file("ml/opencv_ml_knn.xml")) self.assertFalse(k_nearest.empty()) self.assertTrue(k_nearest.isTrained()) if __...
#!/usr/bin/env python ''' SVM and KNearest digit recognition. Sample loads a dataset of handwritten digits from '../data/digits.png'. Then it trains a SVM and KNearest classifiers on it and evaluates their accuracy. Following preprocessing is applied to the dataset: - Moment-based image deskew (see deskew()) - Dig...
#!/usr/bin/env python # Python 2/3 compatibility from __future__ import print_function import cv2 as cv import numpy as np from tests_common import NewOpenCVTests class TestGoodFeaturesToTrack_test(NewOpenCVTests): def test_goodFeaturesToTrack(self): arr = self.get_sample('samples/data/lena.jpg', 0) ...
#!/usr/bin/env python ''' The sample demonstrates how to train Random Trees classifier (or Boosting classifier, or MLP, or Knearest, or Support Vector Machines) using the provided dataset. We use the sample database letter-recognition.data from UCI Repository, here is the link: Newman, D.J. & Hettich, S. & Blake, C....
# This script is used to estimate an accuracy of different face detection models. # COCO evaluation tool is used to compute an accuracy metrics (Average Precision). # Script works with different face detection datasets. import os import json from fnmatch import fnmatch from math import pi import cv2 as cv import argpar...
from __future__ import print_function import sys import argparse import cv2 as cv import tensorflow as tf import numpy as np import struct if sys.version_info > (3,): long = int from tensorflow.python.tools import optimize_for_inference_lib from tensorflow.tools.graph_transforms import TransformGraph from tensorf...
#!/usr/bin/env python import os import cv2 as cv import numpy as np from tests_common import NewOpenCVTests, unittest def normAssert(test, a, b, msg=None, lInf=1e-5): test.assertLess(np.max(np.abs(a - b)), lInf, msg) def inter_area(box1, box2): x_min, x_max = max(box1[0], box2[0]), min(box1[2], box2[2]) ...
import numpy as np import sys import os import argparse import tensorflow as tf from tensorflow.python.platform import gfile from imagenet_cls_test_alexnet import MeanValueFetch, DnnCaffeModel, Framework, ClsAccEvaluation try: import cv2 as cv except ImportError: raise ImportError('Can\'t find OpenCV Python mod...
import numpy as np import sys import os import fnmatch import argparse try: import cv2 as cv except ImportError: raise ImportError('Can\'t find OpenCV Python module. If you\'ve built it from sources without installation, ' 'configure environment variable PYTHONPATH to "opencv_build_dir/li...
import numpy as np import sys import os import argparse from imagenet_cls_test_alexnet import MeanChannelsFetch, CaffeModel, DnnCaffeModel, ClsAccEvaluation try: import caffe except ImportError: raise ImportError('Can\'t find Caffe Python module. If you\'ve built it from sources without installation, ' ...
from __future__ import print_function from abc import ABCMeta, abstractmethod import numpy as np import sys import os import argparse import time try: import caffe except ImportError: raise ImportError('Can\'t find Caffe Python module. If you\'ve built it from sources without installation, ' ...
from __future__ import print_function from abc import ABCMeta, abstractmethod import numpy as np import sys import argparse import time from imagenet_cls_test_alexnet import CaffeModel, DnnCaffeModel try: import cv2 as cv except ImportError: raise ImportError('Can\'t find OpenCV Python module. If you\'ve built...
# Iterate all GLSL shaders (with suffix '.comp') in current directory. # # Use glslangValidator to compile them to SPIR-V shaders and write them # into .cpp files as unsigned int array. # # Also generate a header file 'spv_shader.hpp' to extern declare these shaders. import re import os import sys dir = "./" license_...
#!/usr/bin/env python from __future__ import print_function import numpy as np import cv2 as cv from tests_common import NewOpenCVTests class Bindings(NewOpenCVTests): def check_name(self, name): #print(name) self.assertFalse(name == None) self.assertFalse(name == "") def test_regis...
#!/usr/bin/env python ''' Feature homography ================== Example of using features2d framework for interactive video homography matching. ORB features and FLANN matcher are used. The actual tracking is implemented by PlaneTracker class in plane_tracker.py ''' # Python 2/3 compatibility from __future__ import ...
#!/usr/bin/env python from __future__ import print_function import collections import re import os.path import sys from xml.dom.minidom import parse if sys.version_info > (3,): long = int def cmp(a, b): return (a>b)-(a<b) class TestInfo(object): def __init__(self, xmlnode): self.fixture = xmlnod...
#!/usr/bin/env python from __future__ import print_function import xml.etree.ElementTree as ET from glob import glob from pprint import PrettyPrinter as PP LONG_TESTS_DEBUG_VALGRIND = [ ('calib3d', 'Calib3d_InitUndistortRectifyMap.accuracy', 2017.22), ('dnn', 'Reproducibility*', 1000), # large DNN models ...
#!/usr/bin/env python import os import argparse import logging import datetime from run_utils import Err, CMakeCache, log, execute from run_suite import TestSuite from run_android import AndroidTestSuite epilog = ''' NOTE: Additional options starting with "--gtest_" and "--perf_" will be passed directly to the test e...
#!/usr/bin/env python import math, os, sys webcolors = { "indianred": "#cd5c5c", "lightcoral": "#f08080", "salmon": "#fa8072", "darksalmon": "#e9967a", "lightsalmon": "#ffa07a", "red": "#ff0000", "crimson": "#dc143c", "firebrick": "#b22222", "darkred": "#8b0000", "pink": "#ffc0cb", "lightpink": "#ffb6c1", "hotpink": ...
#!/usr/bin/env python from optparse import OptionParser import glob, sys, os, re if __name__ == "__main__": parser = OptionParser() parser.add_option("-o", "--output", dest="output", help="output file name", metavar="FILENAME", default=None) (options, args) = parser.parse_args() if not options.output...
#!/usr/bin/env python import testlog_parser, sys, os, xml, re from table_formatter import * from optparse import OptionParser cvsize_re = re.compile("^\d+x\d+$") cvtype_re = re.compile("^(CV_)(8U|8S|16U|16S|32S|32F|64F)(C\d{1,3})?$") def keyselector(a): if cvsize_re.match(a): size = [int(d) for d in a.sp...
#!/usr/bin/env python import sys import os import platform import re import tempfile import glob import logging import shutil from subprocess import check_call, check_output, CalledProcessError, STDOUT def initLogger(): logger = logging.getLogger("run.py") logger.setLevel(logging.DEBUG) ch = logging.Strea...
#!/usr/bin/env python import testlog_parser, sys, os, xml, glob, re from table_formatter import * from optparse import OptionParser numeric_re = re.compile("(\d+)") cvtype_re = re.compile("(8U|8S|16U|16S|32S|32F|64F)C(\d{1,3})") cvtypes = { '8U': 0, '8S': 1, '16U': 2, '16S': 3, '32S': 4, '32F': 5, '64F': 6 } convert...
#!/usr/bin/env python from __future__ import print_function import sys, re, os.path, cgi, stat, math from optparse import OptionParser from color import getColorizer, dummyColorizer class tblCell(object): def __init__(self, text, value = None, props = None): self.text = text self.value = value ...
#!/usr/bin/env python import os import re import getpass from run_utils import Err, log, execute, isColorEnabled, hostos from run_suite import TestSuite def exe(program): return program + ".exe" if hostos == 'nt' else program class ApkInfo: def __init__(self): self.pkg_name = None self.pkg_t...
#!/usr/bin/env python from __future__ import print_function import testlog_parser, sys, os, xml, glob, re from table_formatter import * from optparse import OptionParser from operator import itemgetter, attrgetter from summary import getSetName, alphanum_keyselector import re if __name__ == "__main__": usage = "%...
#!/usr/bin/env python import os import re import sys from run_utils import Err, log, execute, getPlatformVersion, isColorEnabled, TempEnvDir from run_long import LONG_TESTS_DEBUG_VALGRIND, longTestFilter class TestSuite(object): def __init__(self, options, cache, id): self.options = options self.c...
#!/usr/bin/env python """ This script can generate XLS reports from OpenCV tests' XML output files. To use it, first, create a directory for each machine you ran tests on. Each such directory will become a sheet in the report. Put each XML file into the corresponding directory. Then, create your ...
from __future__ import print_function import os import sys import csv from pprint import pprint from collections import deque try: long # Python 2 except NameError: long = int # Python 3 # trace.hpp REGION_FLAG_IMPL_MASK = 15 << 16 REGION_FLAG_IMPL_IPP = 1 << 16 REGION_FLAG_IMPL_OPENCL = 2 << 16 DEB...
#!/usr/bin/env python import testlog_parser, sys, os, xml, re, glob from table_formatter import * from optparse import OptionParser if __name__ == "__main__": parser = OptionParser() parser.add_option("-o", "--output", dest="format", help="output results in text format (can be 'txt', 'html' or 'auto' - defaul...
#!/usr/bin/env python # Python 2/3 compatibility from __future__ import print_function import numpy as np import cv2 as cv from tests_common import NewOpenCVTests class solvepnp_test(NewOpenCVTests): def test_regression_16040(self): obj_points = np.array([[0, 0, 0], [0, 1, 0], [1, 1, 0], [1, 0, 0]], dty...
#!/usr/bin/env python ''' camera calibration for distorted images with chess board samples reads distorted images, calculates the calibration and write undistorted images ''' # Python 2/3 compatibility from __future__ import print_function import numpy as np import cv2 as cv from tests_common import NewOpenCVTests ...
#!/usr/bin/python # Copyright 2016 Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list of con...
#!/usr/bin/env python # Copyright (c) 2012 Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this lis...
#!/usr/bin/env python # Copyright (c) 2012 Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this lis...
# Once for All: Train One Network and Specialize it for Efficient Deployment # Han Cai, Chuang Gan, Tianzhe Wang, Zhekai Zhang, Song Han # International Conference on Learning Representations (ICLR), 2020. import os import os.path as osp import argparse import math from tqdm import tqdm import torch.nn as nn import t...
# Once for All: Train One Network and Specialize it for Efficient Deployment # Han Cai, Chuang Gan, Tianzhe Wang, Zhekai Zhang, Song Han # International Conference on Learning Representations (ICLR), 2020. import argparse import numpy as np import os import random import horovod.torch as hvd import torch from ofa.im...
# Once for All: Train One Network and Specialize it for Efficient Deployment # Han Cai, Chuang Gan, Tianzhe Wang, Zhekai Zhang, Song Han # International Conference on Learning Representations (ICLR), 2020. import os import torch import argparse from ofa.imagenet_classification.data_providers.imagenet import ImagenetD...
#!/usr/bin/env python import os, sys import shutil import datetime from setuptools import setup, find_packages from setuptools.command.install import install # readme = open('README.md').read() readme = """ # Once for All: Train One Network and Specialize it for Efficient Deployment [[arXiv]](https://arxiv.org/abs/19...
dependencies = ['torch', 'torchvision'] from functools import partial from ofa.model_zoo import ofa_net, ofa_specialized # general model ofa_supernet_resnet50 = partial(ofa_net, net_id="ofa_resnet50", pretrained=True) ofa_supernet_mbv3_w10 = partial(ofa_net, net_id="ofa_mbv3_d234_e346_k357_w1.0", pretrained=True) ofa...
# Once for All: Train One Network and Specialize it for Efficient Deployment # Han Cai, Chuang Gan, Tianzhe Wang, Zhekai Zhang, Song Han # International Conference on Learning Representations (ICLR), 2020. import json import torch from ofa.utils import download_url from ofa.imagenet_classification.networks import get...
import yaml from ofa.utils import download_url class LatencyEstimator(object): def __init__( self, local_dir="~/.hancai/latency_tools/", url="https://hanlab.mit.edu/files/proxylessNAS/LatencyTools/mobile_trim.yaml", ): if url.startswith("http"): fname = download_url...
import copy import random from tqdm import tqdm import numpy as np __all__ = ["EvolutionFinder"] class ArchManager: def __init__(self): self.num_blocks = 20 self.num_stages = 5 self.kernel_sizes = [3, 5, 7] self.expand_ratios = [3, 4, 6] self.depths = [2, 3, 4] sel...
from .accuracy_predictor import AccuracyPredictor from .flops_table import FLOPsTable from .latency_table import LatencyTable from .evolution_finder import EvolutionFinder from .imagenet_eval_helper import evaluate_ofa_subnet, evaluate_ofa_specialized
import torch.nn as nn import torch import copy from ofa.utils import download_url # Helper for constructing the one-hot vectors. def construct_maps(keys): d = dict() keys = list(set(keys)) for k in keys: if k not in d: d[k] = len(list(d.keys())) return d ks_map = construct_maps...
import time import copy import torch import torch.nn as nn import numpy as np from ofa.utils.layers import * __all__ = ["FLOPsTable"] def rm_bn_from_net(net): for m in net.modules(): if isinstance(m, nn.BatchNorm2d) or isinstance(m, nn.BatchNorm1d): m.forward = lambda x: x class FLOPsTable:...
import os.path as osp import numpy as np import math from tqdm import tqdm import torch.nn as nn import torch.backends.cudnn as cudnn import torch.utils.data from torchvision import transforms, datasets from ofa.utils import AverageMeter, accuracy from ofa.model_zoo import ofa_specialized from ofa.imagenet_classifica...
# Once for All: Train One Network and Specialize it for Efficient Deployment # Han Cai, Chuang Gan, Tianzhe Wang, Zhekai Zhang, Song Han # International Conference on Learning Representations (ICLR), 2020. import os import copy from .latency_lookup_table import * class BaseEfficiencyModel: def __init__(self, ofa...
# Once for All: Train One Network and Specialize it for Efficient Deployment # Han Cai, Chuang Gan, Tianzhe Wang, Zhekai Zhang, Song Han # International Conference on Learning Representations (ICLR), 2020. import yaml from ofa.utils import download_url, make_divisible, MyNetwork __all__ = [ "count_conv_flop", ...
# Once for All: Train One Network and Specialize it for Efficient Deployment # Han Cai, Chuang Gan, Tianzhe Wang, Zhekai Zhang, Song Han # International Conference on Learning Representations (ICLR), 2020. import copy import random import numpy as np from tqdm import tqdm __all__ = ["EvolutionFinder"] class Evoluti...
# Once for All: Train One Network and Specialize it for Efficient Deployment # Han Cai, Chuang Gan, Tianzhe Wang, Zhekai Zhang, Song Han # International Conference on Learning Representations (ICLR), 2020. from .evolution import *
# Once for All: Train One Network and Specialize it for Efficient Deployment # Han Cai, Chuang Gan, Tianzhe Wang, Zhekai Zhang, Song Han # International Conference on Learning Representations (ICLR), 2020. from .acc_dataset import * from .acc_predictor import * from .arch_encoder import *
# Once for All: Train One Network and Specialize it for Efficient Deployment # Han Cai, Chuang Gan, Tianzhe Wang, Zhekai Zhang, Song Han # International Conference on Learning Representations (ICLR), 2020. import os import numpy as np import torch import torch.nn as nn __all__ = ["AccuracyPredictor"] class Accuracy...
# Once for All: Train One Network and Specialize it for Efficient Deployment # Han Cai, Chuang Gan, Tianzhe Wang, Zhekai Zhang, Song Han # International Conference on Learning Representations (ICLR), 2020. import os import json import numpy as np from tqdm import tqdm import torch import torch.utils.data from ofa.uti...
# Once for All: Train One Network and Specialize it for Efficient Deployment # Han Cai, Chuang Gan, Tianzhe Wang, Zhekai Zhang, Song Han # International Conference on Learning Representations (ICLR), 2020. import random import numpy as np from ofa.imagenet_classification.networks import ResNets __all__ = ["MobileNet...
# Once for All: Train One Network and Specialize it for Efficient Deployment # Han Cai, Chuang Gan, Tianzhe Wang, Zhekai Zhang, Song Han # International Conference on Learning Representations (ICLR), 2020. import math import torch.nn as nn import torch.nn.functional as F from .common_tools import min_divisible_value ...
# Once for All: Train One Network and Specialize it for Efficient Deployment # Han Cai, Chuang Gan, Tianzhe Wang, Zhekai Zhang, Song Han # International Conference on Learning Representations (ICLR), 2020. import numpy as np import os import sys import torch try: from urllib import urlretrieve except ImportError:...
# Once for All: Train One Network and Specialize it for Efficient Deployment # Han Cai, Chuang Gan, Tianzhe Wang, Zhekai Zhang, Song Han # International Conference on Learning Representations (ICLR), 2020. import math import copy import time import torch import torch.nn as nn __all__ = [ "mix_images", "mix_la...
# Once for All: Train One Network and Specialize it for Efficient Deployment # Han Cai, Chuang Gan, Tianzhe Wang, Zhekai Zhang, Song Han # International Conference on Learning Representations (ICLR), 2020. from .pytorch_modules import * from .pytorch_utils import * from .my_modules import * from .flops_counter import ...
# Once for All: Train One Network and Specialize it for Efficient Deployment # Han Cai, Chuang Gan, Tianzhe Wang, Zhekai Zhang, Song Han # International Conference on Learning Representations (ICLR), 2020. import torch import torch.nn as nn from .my_modules import MyConv2d __all__ = ["profile"] def count_convNd(m,...
# Once for All: Train One Network and Specialize it for Efficient Deployment # Han Cai, Chuang Gan, Tianzhe Wang, Zhekai Zhang, Song Han # International Conference on Learning Representations (ICLR), 2020. import torch import torch.nn as nn import torch.nn.functional as F from collections import OrderedDict from .my_m...
# Once for All: Train One Network and Specialize it for Efficient Deployment # Han Cai, Chuang Gan, Tianzhe Wang, Zhekai Zhang, Song Han # International Conference on Learning Representations (ICLR), 2020. import torch import torch.nn as nn from collections import OrderedDict from ofa.utils import get_same_padding, m...
r"""Definition of the DataLoader and associated iterators that subclass _BaseDataLoaderIter To support these two classes, in `./_utils` we define many utility methods and functions to be run in multiprocessing. E.g., the data loading worker loop is in `./_utils/worker.py`. """ import threading import itertools import...
from .my_data_loader import * from .my_data_worker import * from .my_distributed_sampler import * from .my_random_resize_crop import *
r""""Contains definitions of the methods used by the _BaseDataLoaderIter workers. These **needs** to be in global scope since Py2 doesn't support serializing static methods. """ import torch import random import os from collections import namedtuple # from torch._six import queue from torch.multiprocessing import Que...
import time import random import math import os from PIL import Image import torchvision.transforms.functional as F import torchvision.transforms as transforms __all__ = ["MyRandomResizedCrop", "MyResizeRandomCrop", "MyResize"] _pil_interpolation_to_str = { Image.NEAREST: "PIL.Image.NEAREST", Image.BILINEAR:...
import math import torch from torch.utils.data.distributed import DistributedSampler __all__ = ["MyDistributedSampler", "WeightedDistributedSampler"] class MyDistributedSampler(DistributedSampler): """Allow Subset Sampler in Distributed Training""" def __init__( self, dataset, num_replicas=None, ran...
# Once for All: Train One Network and Specialize it for Efficient Deployment # Han Cai, Chuang Gan, Tianzhe Wang, Zhekai Zhang, Song Han # International Conference on Learning Representations (ICLR), 2020. import copy import torch.nn.functional as F import torch.nn as nn import torch from ofa.utils import AverageMete...
# Once for All: Train One Network and Specialize it for Efficient Deployment # Han Cai, Chuang Gan, Tianzhe Wang, Zhekai Zhang, Song Han # International Conference on Learning Representations (ICLR), 2020. from .progressive_shrinking import *
# Once for All: Train One Network and Specialize it for Efficient Deployment # Han Cai, Chuang Gan, Tianzhe Wang, Zhekai Zhang, Song Han # International Conference on Learning Representations (ICLR), 2020. import torch.nn as nn import random import time import torch import torch.nn.functional as F from tqdm import tqd...
import random from ofa.imagenet_classification.elastic_nn.modules.dynamic_layers import ( DynamicConvLayer, DynamicLinearLayer, ) from ofa.imagenet_classification.elastic_nn.modules.dynamic_layers import ( DynamicResNetBottleneckBlock, ) from ofa.utils.layers import IdentityLayer, ResidualBlock from ofa.im...
# Once for All: Train One Network and Specialize it for Efficient Deployment # Han Cai, Chuang Gan, Tianzhe Wang, Zhekai Zhang, Song Han # International Conference on Learning Representations (ICLR), 2020. import copy import random from ofa.utils import make_divisible, val2list, MyNetwork from ofa.imagenet_classifica...
# Once for All: Train One Network and Specialize it for Efficient Deployment # Han Cai, Chuang Gan, Tianzhe Wang, Zhekai Zhang, Song Han # International Conference on Learning Representations (ICLR), 2020. from .ofa_proxyless import OFAProxylessNASNets from .ofa_mbv3 import OFAMobileNetV3 from .ofa_resnets import OFAR...
# Once for All: Train One Network and Specialize it for Efficient Deployment # Han Cai, Chuang Gan, Tianzhe Wang, Zhekai Zhang, Song Han # International Conference on Learning Representations (ICLR), 2020. import copy import random from ofa.imagenet_classification.elastic_nn.modules.dynamic_layers import ( Dynami...
# Once for All: Train One Network and Specialize it for Efficient Deployment # Han Cai, Chuang Gan, Tianzhe Wang, Zhekai Zhang, Song Han # International Conference on Learning Representations (ICLR), 2020. import copy import torch import torch.nn as nn from collections import OrderedDict from ofa.utils.layers import ...
# Once for All: Train One Network and Specialize it for Efficient Deployment # Han Cai, Chuang Gan, Tianzhe Wang, Zhekai Zhang, Song Han # International Conference on Learning Representations (ICLR), 2020. from .dynamic_layers import * from .dynamic_op import *
# Once for All: Train One Network and Specialize it for Efficient Deployment # Han Cai, Chuang Gan, Tianzhe Wang, Zhekai Zhang, Song Han # International Conference on Learning Representations (ICLR), 2020. import torch.nn.functional as F import torch.nn as nn import torch from torch.nn.parameter import Parameter from...
# Once for All: Train One Network and Specialize it for Efficient Deployment # Han Cai, Chuang Gan, Tianzhe Wang, Zhekai Zhang, Song Han # International Conference on Learning Representations (ICLR), 2020. from .run_config import * from .run_manager import * from .distributed_run_manager import *
# Once for All: Train One Network and Specialize it for Efficient Deployment # Han Cai, Chuang Gan, Tianzhe Wang, Zhekai Zhang, Song Han # International Conference on Learning Representations (ICLR), 2020. from ofa.utils import calc_learning_rate, build_optimizer from ofa.imagenet_classification.data_providers import ...
# Once for All: Train One Network and Specialize it for Efficient Deployment # Han Cai, Chuang Gan, Tianzhe Wang, Zhekai Zhang, Song Han # International Conference on Learning Representations (ICLR), 2020. import os import json import time import random import torch import torch.nn as nn import torch.nn.functional as ...
# Once for All: Train One Network and Specialize it for Efficient Deployment # Han Cai, Chuang Gan, Tianzhe Wang, Zhekai Zhang, Song Han # International Conference on Learning Representations (ICLR), 2020. import os import random import time import json import numpy as np import torch.nn as nn import torch.nn.function...
# Once for All: Train One Network and Specialize it for Efficient Deployment # Han Cai, Chuang Gan, Tianzhe Wang, Zhekai Zhang, Song Han # International Conference on Learning Representations (ICLR), 2020. from .proxyless_nets import * from .mobilenet_v3 import * from .resnets import * def get_net_by_name(name): ...
# Once for All: Train One Network and Specialize it for Efficient Deployment # Han Cai, Chuang Gan, Tianzhe Wang, Zhekai Zhang, Song Han # International Conference on Learning Representations (ICLR), 2020. import copy import torch.nn as nn from ofa.utils.layers import ( set_layer_from_config, MBConvLayer, ...
import torch.nn as nn from ofa.utils.layers import ( set_layer_from_config, ConvLayer, IdentityLayer, LinearLayer, ) from ofa.utils.layers import ResNetBottleneckBlock, ResidualBlock from ofa.utils import make_divisible, MyNetwork, MyGlobalAvgPool2d __all__ = ["ResNets", "ResNet50", "ResNet50D"] cla...
# Once for All: Train One Network and Specialize it for Efficient Deployment # Han Cai, Chuang Gan, Tianzhe Wang, Zhekai Zhang, Song Han # International Conference on Learning Representations (ICLR), 2020. import json import torch.nn as nn from ofa.utils.layers import ( set_layer_from_config, MBConvLayer, ...
# Once for All: Train One Network and Specialize it for Efficient Deployment # Han Cai, Chuang Gan, Tianzhe Wang, Zhekai Zhang, Song Han # International Conference on Learning Representations (ICLR), 2020. import numpy as np import torch __all__ = ["DataProvider"] class DataProvider: SUB_SEED = 937162211 # ran...
# Once for All: Train One Network and Specialize it for Efficient Deployment # Han Cai, Chuang Gan, Tianzhe Wang, Zhekai Zhang, Song Han # International Conference on Learning Representations (ICLR), 2020. import warnings import os import math import numpy as np import torch.utils.data import torchvision.transforms as...
# Once for All: Train One Network and Specialize it for Efficient Deployment # Han Cai, Chuang Gan, Tianzhe Wang, Zhekai Zhang, Song Han # International Conference on Learning Representations (ICLR), 2020. from .imagenet import *