id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
29,255 | import random
import numpy as np
from PIL import Image, ImageEnhance, ImageOps
class SubPolicy:
"""Subpolicy
Read augment name and magnitude, apply augment with probability
Args:
op_name: str, augment operation name
prob: float, if prob > random prob, apply augment
magnitude: int, in... | 25 types of augment policies in original paper |
29,256 | import random
import numpy as np
from PIL import Image, ImageEnhance, ImageOps
class SubPolicy:
"""Subpolicy
Read augment name and magnitude, apply augment with probability
Args:
op_name: str, augment operation name
prob: float, if prob > random prob, apply augment
magnitude: int, in... | Rand augment policy: default rand-m9-mstd0.5-inc1 |
29,257 | import random
import numpy as np
from PIL import Image, ImageEnhance, ImageOps
LEVEL_DENOM = 10
def randomly_negate(value):
"""negate the value with 0.5 prob"""
return -value if random.random() > 0.5 else value
def shear_level_to_arg(level):
# range [-0.3, 0.3]
level = (level / LEVEL_DENOM) * 0.3
l... | null |
29,258 | import random
import numpy as np
from PIL import Image, ImageEnhance, ImageOps
LEVEL_DENOM = 10
def randomly_negate(value):
"""negate the value with 0.5 prob"""
return -value if random.random() > 0.5 else value
def translate_absolute_level_to_arg(level):
# translate const = 100
level = (level / LEVEL_D... | null |
29,259 | import random
import numpy as np
from PIL import Image, ImageEnhance, ImageOps
LEVEL_DENOM = 10
def randomly_negate(value):
"""negate the value with 0.5 prob"""
return -value if random.random() > 0.5 else value
def translate_relative_level_to_arg(level):
# range [-0.45, 0.45]
level = (level / LEVEL_DEN... | null |
29,260 | import random
import numpy as np
from PIL import Image, ImageEnhance, ImageOps
LEVEL_DENOM = 10
def randomly_negate(value):
"""negate the value with 0.5 prob"""
return -value if random.random() > 0.5 else value
def rotate_level_to_arg(level):
# range [-30, 30]
level = (level / LEVEL_DENOM) * 30.
le... | null |
29,261 | import random
import numpy as np
from PIL import Image, ImageEnhance, ImageOps
LEVEL_DENOM = 10
def solarize_level_to_arg(level):
# range [0, 256]
# intensity/severity of augmentation decreases with level
return int((level / LEVEL_DENOM) * 256), | null |
29,262 | import random
import numpy as np
from PIL import Image, ImageEnhance, ImageOps
LEVEL_DENOM = 10
def solarize_increasing_level_to_arg(level):
# range [0, 256]
# intensity/severity of augmentation increases with level
return 256 - int((level / LEVEL_DENOM) * 256), | null |
29,263 | import random
import numpy as np
from PIL import Image, ImageEnhance, ImageOps
LEVEL_DENOM = 10
def solarize_add_level_to_arg(level):
# range [0, 110]
return int((level / LEVEL_DENOM) * 110), | null |
29,264 | import random
import numpy as np
from PIL import Image, ImageEnhance, ImageOps
LEVEL_DENOM = 10
def posterize_level_to_arg(level):
# range [0, 4]
# intensity/severity of augmentation decreases with level
return int((level / LEVEL_DENOM) * 4), | null |
29,265 | import random
import numpy as np
from PIL import Image, ImageEnhance, ImageOps
LEVEL_DENOM = 10
def posterize_increasing_level_to_arg(level):
# range [4, 0]
# intensity/severity of augmentation increases with level
return 4 - int((level / LEVEL_DENOM) * 4), | null |
29,266 | import random
import numpy as np
from PIL import Image, ImageEnhance, ImageOps
LEVEL_DENOM = 10
def posterize_original_level_to_arg(level):
# range [4, 8]
# intensity/severity of augmentation decreases with level
return int((level / LEVEL_DENOM) * 4) + 4, | null |
29,267 | import random
import numpy as np
from PIL import Image, ImageEnhance, ImageOps
LEVEL_DENOM = 10
def enhance_level_to_arg(level):
# range [0.1, 1.9]
return (level / LEVEL_DENOM) * 1.8 + 0.1, | null |
29,268 | import random
import numpy as np
from PIL import Image, ImageEnhance, ImageOps
LEVEL_DENOM = 10
def randomly_negate(value):
def enhance_increasing_level_to_arg(level):
# range [0.1, 1.9]
level = (level / LEVEL_DENOM) * 0.9
level = max(0.1, 1.0 + randomly_negate(level))
return level, | null |
29,287 | import numpy as np
import paddle
The provided code snippet includes necessary dependencies for implementing the `fold` function. Write a Python function `def fold(inputs, output_size, kernel_size, padding, stride)` to solve the following problem:
Args: x: Tensor, input tensor, only support 3D tensor, [Batch, C * kerne... | Args: x: Tensor, input tensor, only support 3D tensor, [Batch, C * kernel_size * kernel_size, L] output_size, Tuple/List, contains the height and width of the output tensor, len = 2 kernel_size: int, kernel size padding: int, num of pad around the input stride: int, stride for sliding window |
29,292 | import math
import copy
import numpy as np
import paddle
import paddle.nn as nn
from droppath import DropPath
from fold import fold
The provided code snippet includes necessary dependencies for implementing the `rand_bbox` function. Write a Python function `def rand_bbox(size, lam, scale=1)` to solve the following pro... | get bounding box as token labeling (https://github.com/zihangJiang/TokenLabeling) return: bounding box |
29,293 | import math
import copy
import numpy as np
import paddle
import paddle.nn as nn
from droppath import DropPath
from fold import fold
class VOLO(nn.Layer):
def __init__(self,
layers,
image_size=224,
in_channels=3,
num_classes=1000,
patch_size=... | build volo model using config |
29,294 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | return argumeents, this will overwrite the config by (1) yaml file (2) argument values |
29,295 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | main method for each process |
29,300 | import os
from yacs.config import CfgNode as CN
import yaml
_C = CN()
_C.BASE = ['']
_C.DATA = CN()
_C.DATA.BATCH_SIZE = 256
_C.DATA.BATCH_SIZE_EVAL = None
_C.DATA.DATA_PATH = '/dataset/imagenet/'
_C.DATA.DATASET = 'imagenet2012'
_C.DATA.IMAGE_SIZE = 224
_C.DATA.IMAGE_CHANNELS = 3
_C.DATA.CROP_PCT = 0.875
_C.DAT... | Return a clone of config and optionally overwrite it from yaml file |
29,309 | import random
import numpy as np
from PIL import Image, ImageEnhance, ImageOps
LEVEL_DENOM = 10
def randomly_negate(value):
"""negate the value with 0.5 prob"""
return -value if random.random() > 0.5 else value
def translate_absolute_level_to_arg(level):
# translate const = 100
level = (level / LEVEL_D... | null |
29,310 | import random
import numpy as np
from PIL import Image, ImageEnhance, ImageOps
LEVEL_DENOM = 10
def randomly_negate(value):
"""negate the value with 0.5 prob"""
return -value if random.random() > 0.5 else value
def translate_relative_level_to_arg(level):
# range [-0.45, 0.45]
level = (level / LEVEL_DEN... | null |
29,319 | import random
import numpy as np
from PIL import Image, ImageEnhance, ImageOps
LEVEL_DENOM = 10
def randomly_negate(value):
def enhance_increasing_level_to_arg(level):
# range [0.1, 1.9]
level = (level / LEVEL_DENOM) * 0.9
level = max(0.1, 1.0 + randomly_negate(level))
return (level,) | null |
29,342 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | return argumeents, this will overwrite the config by (1) yaml file (2) argument values |
29,343 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | main method for each process |
29,344 | import os
import math
from paddle.io import Dataset
from paddle.io import DataLoader
from paddle.io import DistributedBatchSampler
from paddle.vision import transforms
from paddle.vision import image_load
from augment import auto_augment_policy_original
from augment import AutoAugment
from augment import rand_augment_p... | Get full training transforms For training, a RandomResizedCrop is applied with random mirror, then RandAug, AutoAug or ColorJitter is applied, then normalization is applied with mean and std, and RandomErase is applied. The input pixel values must be rescaled to [0, 1.]. Outputs is converted to tensor. Args: config: co... |
29,345 | import os
import math
from paddle.io import Dataset
from paddle.io import DataLoader
from paddle.io import DistributedBatchSampler
from paddle.vision import transforms
from paddle.vision import image_load
from augment import auto_augment_policy_original
from augment import AutoAugment
from augment import rand_augment_p... | Get dataset from config and mode (train/val) Returns the related dataset object according to configs and mode(train/val) Args: config: configs contains dataset related settings. see config.py for details is_train: bool, set True to use training set, otherwise val set. Default: True Returns: dataset: dataset object |
29,346 | import os
import math
from paddle.io import Dataset
from paddle.io import DataLoader
from paddle.io import DistributedBatchSampler
from paddle.vision import transforms
from paddle.vision import image_load
from augment import auto_augment_policy_original
from augment import AutoAugment
from augment import rand_augment_p... | Get dataloader from dataset, allows multiGPU settings. Multi-GPU loader is implements as distributedBatchSampler. Args: config: see config.py for details dataset: paddle.io.dataset object is_train: bool, when False, shuffle is off and BATCH_SIZE_EVAL is used, default: True use_dist_sampler: if True, DistributedBatchSam... |
29,347 | import copy
import numpy as np
import paddle
import paddle.nn as nn
class MobileOne(nn.Layer):
def __init__(self,
num_blocks,
num_branches,
channels,
strides,
expansions,
num_classes=1000,
use_se=F... | null |
29,348 | import copy
import numpy as np
import paddle
import paddle.nn as nn
class MobileOne(nn.Layer):
def __init__(self,
num_blocks,
num_branches,
channels,
strides,
expansions,
num_classes=1000,
use_se=F... | Build MobileOne by reading options in config object Args: config: config instance contains setting options Returns: model: MobileOne model |
29,349 | import os
from yacs.config import CfgNode as CN
import yaml
def _update_config_from_file(config, cfg_file):
"""Load cfg file (.yaml) and update config object
Args:
config: config object
cfg_file: config file (.yaml)
Return:
None
"""
config.defrost()
with open(cfg_file, 'r... | Update config by ArgumentParser Configs that are often used can be updated from arguments Args: args: ArgumentParser contains options Return: config: updated config |
29,350 | import os
from yacs.config import CfgNode as CN
import yaml
_C = CN()
_C.BASE = ['']
_C.DATA = CN()
_C.DATA.BATCH_SIZE = 256
_C.DATA.BATCH_SIZE_EVAL = None
_C.DATA.DATA_PATH = '/dataset/imagenet/'
_C.DATA.DATASET = 'imagenet2012'
_C.DATA.IMAGE_SIZE = 224
_C.DATA.IMAGE_CHANNELS = 3
_C.DATA.CROP_PCT = 0.875
_C.DAT... | Return a clone of config and optionally overwrite it from yaml file |
29,351 | import os
import numpy as np
import paddle
import torch
from mobileone import build_mobileone as build_model
from mobileone import model_convert
from config import get_config
from pth_mobileone import mobileone as mobileone_pytorch
from pth_mobileone import reparameterize_model
def print_model_named_params(model):
... | null |
29,352 | import os
import numpy as np
import paddle
import torch
from mobileone import build_mobileone as build_model
from mobileone import model_convert
from config import get_config
from pth_mobileone import mobileone as mobileone_pytorch
from pth_mobileone import reparameterize_model
def print_model_named_buffers(model):
... | null |
29,353 | import os
import numpy as np
import paddle
import torch
from mobileone import build_mobileone as build_model
from mobileone import model_convert
from config import get_config
from pth_mobileone import mobileone as mobileone_pytorch
from pth_mobileone import reparameterize_model
def torch_to_paddle_mapping(model_name, c... | null |
29,354 | import os
import glob
import paddle
from config import get_config
from mobileone import build_mobileone as build_model
def count_gelu(layer, inputs, output):
activation_flops = 8
x = inputs[0]
num = x.numel()
layer.total_ops += num * activation_flops | null |
29,355 | import os
import glob
import paddle
from config import get_config
from mobileone import build_mobileone as build_model
def count_softmax(layer, inputs, output):
softmax_flops = 5 # max/substract, exp, sum, divide
x = inputs[0]
num = x.numel()
layer.total_ops += num * softmax_flops | null |
29,356 | import os
import glob
import paddle
from config import get_config
from mobileone import build_mobileone as build_model
def count_layernorm(layer, inputs, output):
layer_norm_flops = 5 # get mean (sum), get variance (square and sum), scale(multiply)
x = inputs[0]
num = x.numel()
layer.total_ops += num *... | null |
29,398 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | return argumeents, this will overwrite the config by (1) yaml file (2) argument values |
29,399 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | main method for each process |
29,404 | import os
from yacs.config import CfgNode as CN
import yaml
_C = CN()
_C.BASE = ['']
_C.DATA = CN()
_C.DATA.BATCH_SIZE = 256
_C.DATA.BATCH_SIZE_EVAL = None
_C.DATA.DATA_PATH = '/dataset/imagenet/'
_C.DATA.DATASET = 'imagenet2012'
_C.DATA.IMAGE_SIZE = 224
_C.DATA.IMAGE_CHANNELS = 3
_C.DATA.CROP_PCT = 0.875
_C.DAT... | Return a clone of config and optionally overwrite it from yaml file |
29,442 | import math
import copy
import paddle
import paddle.nn as nn
from droppath import DropPath
class HVT(nn.Layer):
def __init__(self,
image_size=224,
in_channels=3,
num_classes=1000,
patch_size=16,
embed_dim=384,
num_... | build hvt model using config |
29,447 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | return argumeents, this will overwrite the config by (1) yaml file (2) argument values |
29,448 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | main method for each process |
29,453 | import os
from yacs.config import CfgNode as CN
import yaml
_C = CN()
_C.BASE = ['']
_C.DATA = CN()
_C.DATA.BATCH_SIZE = 256
_C.DATA.BATCH_SIZE_EVAL = None
_C.DATA.DATA_PATH = '/dataset/imagenet/'
_C.DATA.DATASET = 'imagenet2012'
_C.DATA.IMAGE_SIZE = 224
_C.DATA.IMAGE_CHANNELS = 3
_C.DATA.CROP_PCT = 0.875
_C.DAT... | Return a clone of config and optionally overwrite it from yaml file |
29,454 | import os
import numpy as np
import paddle
import torch
import timm
from convmlp import build_convmlp as build_model
from config import get_config
from convmlp_torch import convmlp_s
from convmlp_torch import convmlp_m
from convmlp_torch import convmlp_l
def print_model_named_params(model):
print('----------------... | null |
29,455 | import os
import numpy as np
import paddle
import torch
import timm
from convmlp import build_convmlp as build_model
from config import get_config
from convmlp_torch import convmlp_s
from convmlp_torch import convmlp_m
from convmlp_torch import convmlp_l
def print_model_named_buffers(model):
print('---------------... | null |
29,456 | import os
import numpy as np
import paddle
import torch
import timm
from convmlp import build_convmlp as build_model
from config import get_config
from convmlp_torch import convmlp_s
from convmlp_torch import convmlp_m
from convmlp_torch import convmlp_l
def torch_to_paddle_mapping(model_name, config):
mapping = [
... | null |
29,457 | import paddle
import paddle.nn as nn
from droppath import DropPath
class ConvMLP(nn.Layer):
def __init__(self,
blocks,
dims,
mlp_ratios,
channels=64,
n_conv_blocks=3,
classifier_head=True,
... | null |
29,458 | import paddle
import paddle.nn as nn
from droppath import DropPath
class ConvMLP(nn.Layer):
def __init__(self,
blocks,
dims,
mlp_ratios,
channels=64,
n_conv_blocks=3,
classifier_head=True,
num_clas... | null |
29,459 | import paddle
import paddle.nn as nn
from droppath import DropPath
class ConvMLP(nn.Layer):
def __init__(self,
blocks,
dims,
mlp_ratios,
channels=64,
n_conv_blocks=3,
classifier_head=True,
num_clas... | null |
29,467 | import random
import numpy as np
from PIL import Image, ImageEnhance, ImageOps
LEVEL_DENOM = 10
def randomly_negate(value):
def shear_level_to_arg(level):
# range [-0.3, 0.3]
level = (level / LEVEL_DENOM) * 0.3
level = randomly_negate(level)
return (level,) | null |
29,470 | import random
import numpy as np
from PIL import Image, ImageEnhance, ImageOps
LEVEL_DENOM = 10
def randomly_negate(value):
def rotate_level_to_arg(level):
# range [-30, 30]
level = (level / LEVEL_DENOM) * 30.
level = randomly_negate(level)
return (level,) | null |
29,501 | import paddle
The provided code snippet includes necessary dependencies for implementing the `interpolate_position_embedding` function. Write a Python function `def interpolate_position_embedding(model, state_dict)` to solve the following problem:
interpolate pos embed from model state for new model
Here is the funct... | interpolate pos embed from model state for new model |
29,505 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | return argumeents, this will overwrite the config by (1) yaml file (2) argument values |
29,506 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | main method for each process |
29,507 | import os
from yacs.config import CfgNode as CN
import yaml
def _update_config_from_file(config, cfg_file):
"""Load cfg file (.yaml) and update config object
Args:
config: config object
cfg_file: config file (.yaml)
Return:
None
"""
config.defrost()
with open(cfg_file, 'r... | Update config by ArgumentParser Configs that are often used can be updated from arguments Args: args: ArgumentParser contains options Return: config: updated config |
29,508 | import os
from yacs.config import CfgNode as CN
import yaml
_C = CN()
_C.BASE = ['']
_C.DATA = CN()
_C.DATA.BATCH_SIZE = 256
_C.DATA.BATCH_SIZE_EVAL = None
_C.DATA.DATA_PATH = '/dataset/imagenet/'
_C.DATA.DATASET = 'imagenet2012'
_C.DATA.IMAGE_SIZE = 224
_C.DATA.IMAGE_CHANNELS = 3
_C.DATA.CROP_PCT = 0.875
_C.DAT... | Return a clone of config and optionally overwrite it from yaml file |
29,509 | import os
import numpy as np
import paddle
import torch
import timm
from deit import build_vit, build_deit
from config import get_config
def print_model_named_params(model):
print('----------------------------------')
for name, param in model.named_parameters():
print(name, param.shape)
print('----... | null |
29,510 | import os
import numpy as np
import paddle
import torch
import timm
from deit import build_vit, build_deit
from config import get_config
def print_model_named_buffers(model):
print('----------------------------------')
for name, param in model.named_buffers():
print(name, param.shape)
print('------... | null |
29,511 | import os
import numpy as np
import paddle
import torch
import timm
from deit import build_vit, build_deit
from config import get_config
def torch_to_paddle_mapping(model_name):
mapping = [
('cls_token', 'cls_token'),
('dist_token', 'dist_token'),
('pos_embed', 'position_embedding'),
... | null |
29,512 | import paddle
import paddle.nn as nn
from droppath import DropPath
class VisionTransformer(nn.Layer):
"""ViT transformer
ViT Transformer, classifier is a single Linear layer for finetune,
For training from scratch, two layer mlp should be used.
Classification is done using cls_token.
Args:
i... | build vit model from config, this is same as ViT |
29,513 | import paddle
import paddle.nn as nn
from droppath import DropPath
class DistilledVisionTransformer(VisionTransformer):
"""Distilled ViT transformer (DeiT)
Args:
image_size: int, input image size, default: 224
patch_size: int, patch size, default: 16
in_channels: int, input image channel... | build deit model from config |
29,551 | import copy
import numpy as np
import paddle.nn as nn
class RegNet(nn.Layer):
"""RegNet Model"""
def __init__(self, cfg):
super().__init__()
num_classes = cfg['num_classes']
stem_width = cfg['stem_width']
# Stem layers
self.stem = nn.Sequential(
nn.Conv2D(in_c... | build regnet model using dict as config |
29,552 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | return argumeents, this will overwrite the config by (1) yaml file (2) argument values |
29,553 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | main method for each process |
29,558 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | return argumeents, this will overwrite the config by (1) yaml file (2) argument values |
29,559 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | main method for each process |
29,560 | import paddle
from paddle import nn
The provided code snippet includes necessary dependencies for implementing the `make_divisible` function. Write a Python function `def make_divisible(v, divisor=8, min_value=None, round_limit=.9)` to solve the following problem:
calculate new vector dim according to input vector dim... | calculate new vector dim according to input vector dim |
29,561 | import paddle
from paddle import nn
The provided code snippet includes necessary dependencies for implementing the `init_weights` function. Write a Python function `def init_weights()` to solve the following problem:
init Linear weight
Here is the function:
def init_weights():
""" init Linear weight
"""
... | init Linear weight |
29,562 | import paddle
from paddle import nn
The provided code snippet includes necessary dependencies for implementing the `rel_logits_1d` function. Write a Python function `def rel_logits_1d(q, rel_k, permute_mask)` to solve the following problem:
Compute relative logits along one dimension :param q: [batch,H,W,dim] :param r... | Compute relative logits along one dimension :param q: [batch,H,W,dim] :param rel_k: [2*window-1,dim] :param permute_mask: permute output axis according to this |
29,563 | import paddle
from paddle import nn
class HaloNet(nn.Layer):
""" Define main structure of HaloNet: stem - blocks - head
"""
def __init__(self,
depth_list,
block_size,
halo_size,
stage1_block,
stage2_block,
... | Build HaloNet by reading options in config object :param config: config instance contains setting options :return: HaloNet model |
29,568 | import os
from yacs.config import CfgNode as CN
import yaml
_C = CN()
_C.BASE = ['']
_C.DATA = CN()
_C.DATA.BATCH_SIZE = 256
_C.DATA.BATCH_SIZE_EVAL = None
_C.DATA.DATA_PATH = '/dataset/imagenet/'
_C.DATA.DATASET = 'imagenet2012'
_C.DATA.IMAGE_SIZE = 256
_C.DATA.IMAGE_CHANNELS = 3
_C.DATA.CROP_PCT = 0.95
_C.DATA... | Return a clone of config and optionally overwrite it from yaml file |
29,569 | import os
import numpy as np
import paddle
import torch
import timm
from halonet import build_halonet as build_model
from config import get_config
def print_model_named_params(model):
print('----------------------------------')
for name, param in model.named_parameters():
print(name, param.shape)
p... | null |
29,570 | import os
import numpy as np
import paddle
import torch
import timm
from halonet import build_halonet as build_model
from config import get_config
def print_model_named_buffers(model):
print('----------------------------------')
for name, param in model.named_buffers():
print(name, param.shape)
pri... | null |
29,571 | import os
import numpy as np
import paddle
import torch
import timm
from halonet import build_halonet as build_model
from config import get_config
def torch_to_paddle_mapping(model_name, config):
mapping = [
('stem.conv1.conv', 'stem.conv1.conv'),
('stem.conv1.bn', 'stem.conv1.bn'),
('stem.c... | null |
29,613 | import numpy as np
import paddle
import paddle.nn as nn
from droppath import DropPath
The provided code snippet includes necessary dependencies for implementing the `img2windows` function. Write a Python function `def img2windows(img, h_split, w_split)` to solve the following problem:
Convert input tensor into split s... | Convert input tensor into split stripes Args: img: tensor, image tensor with shape [B, C, H, W] h_split: int, splits width in height direction w_split: int, splits width in width direction Returns: out: tensor, splitted image |
29,614 | import numpy as np
import paddle
import paddle.nn as nn
from droppath import DropPath
The provided code snippet includes necessary dependencies for implementing the `windows2img` function. Write a Python function `def windows2img(img_splits, h_split, w_split, img_h, img_w)` to solve the following problem:
Convert spli... | Convert splitted stripes back Args: img_splits: tensor, image tensor with shape [B, C, H, W] h_split: int, splits width in height direction w_split: int, splits width in width direction img_h: int, original tensor height img_w: int, original tensor width Returns: img: tensor, original tensor |
29,615 | import numpy as np
import paddle
import paddle.nn as nn
from droppath import DropPath
class CSwinTransformer(nn.Layer):
"""CSwin Transformer class
Args:
image_size: int, input image size, default: 224
patch_stride: int, stride for patch embedding, default: 4
in_channels: int, num of chan... | build cswin transformer model using config |
29,616 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | return argumeents, this will overwrite the config by (1) yaml file (2) argument values |
29,617 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | main method for each process |
29,622 | import os
from yacs.config import CfgNode as CN
import yaml
_C = CN()
_C.BASE = ['']
_C.DATA = CN()
_C.DATA.BATCH_SIZE = 256
_C.DATA.BATCH_SIZE_EVAL = None
_C.DATA.DATA_PATH = '/dataset/imagenet/'
_C.DATA.DATASET = 'imagenet2012'
_C.DATA.IMAGE_SIZE = 224
_C.DATA.IMAGE_CHANNELS = 3
_C.DATA.CROP_PCT = 0.875
_C.DAT... | Return a clone of config and optionally overwrite it from yaml file |
29,623 | import os
import numpy as np
import paddle
import torch
import timm
from cswin import build_cswin as build_model
from config import get_config
from cswin_pytorch.CSWin_Transformer.models import cswin as pytorch_cswin
def print_model_named_params(model):
print('----------------------------------')
for name, par... | null |
29,624 | import os
import numpy as np
import paddle
import torch
import timm
from cswin import build_cswin as build_model
from config import get_config
from cswin_pytorch.CSWin_Transformer.models import cswin as pytorch_cswin
def print_model_named_buffers(model):
print('----------------------------------')
for name, pa... | null |
29,625 | import os
import numpy as np
import paddle
import torch
import timm
from cswin import build_cswin as build_model
from config import get_config
from cswin_pytorch.CSWin_Transformer.models import cswin as pytorch_cswin
def torch_to_paddle_mapping(model_name, config):
mapping = [
('stage1_conv_embed.0', 'patch... | null |
29,667 | import paddle
import paddle.nn as nn
import numpy as np
import os
from droppath import DropPath
class MlpMixer(nn.Layer):
"""MlpMixer model
Args:
num_classes: int, num of image classes, default: 1000
image_size: int, input image size, default: 224
in_channels: int, input image channels, ... | Build mlp mixer by reading options in config object Args: config: config instance contains setting options Returns: model: MlpMixer model |
29,668 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | return argumeents, this will overwrite the config by (1) yaml file (2) argument values |
29,669 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | main method for each process |
29,674 | import os
from yacs.config import CfgNode as CN
import yaml
_C = CN()
_C.BASE = ['']
_C.DATA = CN()
_C.DATA.BATCH_SIZE = 256
_C.DATA.BATCH_SIZE_EVAL = None
_C.DATA.DATA_PATH = '/dataset/imagenet/'
_C.DATA.DATASET = 'imagenet2012'
_C.DATA.IMAGE_SIZE = 224
_C.DATA.IMAGE_CHANNELS = 3
_C.DATA.CROP_PCT = 0.875
_C.DAT... | Return a clone of config and optionally overwrite it from yaml file |
29,675 | import os
import numpy as np
import paddle
import torch
import timm
from mlp_mixer import build_mlp_mixer as build_model
from config import get_config
def print_model_named_params(model):
print('----------------------------------')
for name, param in model.named_parameters():
print(name, param.shape)
... | null |
29,676 | import os
import numpy as np
import paddle
import torch
import timm
from mlp_mixer import build_mlp_mixer as build_model
from config import get_config
def print_model_named_buffers(model):
print('----------------------------------')
for name, param in model.named_buffers():
print(name, param.shape)
... | null |
29,677 | import os
import numpy as np
import paddle
import torch
import timm
from mlp_mixer import build_mlp_mixer as build_model
from config import get_config
def torch_to_paddle_mapping(model_name, config):
mapping = [
('stem.proj', 'patch_embed.patch_embed'),
]
for stage_idx in range(config.MODEL.MIXER.DE... | null |
29,719 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | return argumeents, this will overwrite the config by (1) yaml file (2) argument values |
29,720 | import sys
import os
import time
import argparse
import random
import math
import numpy as np
import paddle
from datasets import get_dataloader
from datasets import get_dataset
from config import get_config
from config import update_config
from utils import AverageMeter
from utils import get_logger
from utils import wr... | main method for each process |
29,725 | import os
from yacs.config import CfgNode as CN
import yaml
_C = CN()
_C.BASE = ['']
_C.DATA = CN()
_C.DATA.BATCH_SIZE = 256
_C.DATA.BATCH_SIZE_EVAL = None
_C.DATA.DATA_PATH = '/dataset/imagenet/'
_C.DATA.DATASET = 'imagenet2012'
_C.DATA.IMAGE_SIZE = 224
_C.DATA.IMAGE_CHANNELS = 3
_C.DATA.CROP_PCT = 0.875
_C.DAT... | Return a clone of config and optionally overwrite it from yaml file |
29,726 | from functools import partial
import paddle
import paddle.nn as nn
from droppath import DropPath
class ConvNeXt(nn.Layer):
def __init__(self,
in_channels=3,
num_classes=1000,
global_pool=True,
output_stride=32,
patch_size=4,
... | build convnext model from config |
29,727 | import os
import numpy as np
import paddle
import torch
import timm
from convnext import build_convnext as build_model
from config import get_config
def print_model_named_params(model):
print('----------------------------------')
for name, param in model.named_parameters():
print(name, param.shape)
... | null |
29,728 | import os
import numpy as np
import paddle
import torch
import timm
from convnext import build_convnext as build_model
from config import get_config
def print_model_named_buffers(model):
print('----------------------------------')
for name, param in model.named_buffers():
print(name, param.shape)
p... | null |
29,729 | import os
import numpy as np
import paddle
import torch
import timm
from convnext import build_convnext as build_model
from config import get_config
def torch_to_paddle_mapping(model_name, config):
mapping = [
('stem.0', 'stem.0'),
('stem.1', 'stem.1'),
]
for stage_idx, stage_depth in enumer... | null |
29,740 | import random
import numpy as np
from PIL import Image, ImageEnhance, ImageOps
LEVEL_DENOM = 10
def randomly_negate(value):
def rotate_level_to_arg(level):
# range [-30, 30]
level = (level / LEVEL_DENOM) * 30.
level = randomly_negate(level)
return level, | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.