id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
166,012
import os import copy import torch import torch.nn as nn import torch.nn.functional as F import math from typing import Dict import itertools import numpy as np from timm.models.layers import DropPath, trunc_normal_, to_2tuple EfficientFormer_width = { 'L': [40, 80, 192, 384], # 26m 83.3% 6attn 'S2': [32, 64, ...
null
166,013
import os import copy import torch import torch.nn as nn import torch.nn.functional as F import math from typing import Dict import itertools import numpy as np from timm.models.layers import DropPath, trunc_normal_, to_2tuple EfficientFormer_width = { 'L': [40, 80, 192, 384], # 26m 83.3% 6attn 'S2': [32, 64, ...
null
166,014
import os import copy import torch import torch.nn as nn import torch.nn.functional as F import math from typing import Dict import itertools import numpy as np from timm.models.layers import DropPath, trunc_normal_, to_2tuple EfficientFormer_width = { 'L': [40, 80, 192, 384], # 26m 83.3% 6attn 'S2': [32, 64, ...
null
166,015
import os import copy import torch import torch.nn as nn import torch.nn.functional as F import math from typing import Dict import itertools import numpy as np from timm.models.layers import DropPath, trunc_normal_, to_2tuple EfficientFormer_width = { 'L': [40, 80, 192, 384], # 26m 83.3% 6attn 'S2': [32, 64, ...
null
166,016
from functools import partial import numpy as np import torch import torch.utils.checkpoint as checkpoint from einops import rearrange from timm.models.layers import DropPath, trunc_normal_ from torch import nn def _make_divisible(v, divisor, min_value=None): if min_value is None: min_value = divisor n...
null
166,017
from functools import partial import numpy as np import torch import torch.utils.checkpoint as checkpoint from einops import rearrange from timm.models.layers import DropPath, trunc_normal_ from torch import nn class NextViT(nn.Module): def __init__(self, stem_chs, depths, path_dropout, attn_drop=0, drop=0, num_cla...
null
166,018
from functools import partial import numpy as np import torch import torch.utils.checkpoint as checkpoint from einops import rearrange from timm.models.layers import DropPath, trunc_normal_ from torch import nn class NextViT(nn.Module): def __init__(self, stem_chs, depths, path_dropout, attn_drop=0, drop=0, num_cla...
null
166,019
from functools import partial import numpy as np import torch import torch.utils.checkpoint as checkpoint from einops import rearrange from timm.models.layers import DropPath, trunc_normal_ from torch import nn class NextViT(nn.Module): def __init__(self, stem_chs, depths, path_dropout, attn_drop=0, drop=0, num_cla...
null
166,020
import torch import torch.nn as nn import torch.nn.functional as F import numpy as np from timm.models.layers import trunc_normal_, DropPath class ConvNeXtV2(nn.Module): """ ConvNeXt V2 Args: in_chans (int): Number of input image channels. Default: 3 num_classes (int): Number of classes for clas...
null
166,021
import torch import torch.nn as nn import torch.nn.functional as F import numpy as np from timm.models.layers import trunc_normal_, DropPath class ConvNeXtV2(nn.Module): """ ConvNeXt V2 Args: in_chans (int): Number of input image channels. Default: 3 num_classes (int): Number of classes for clas...
null
166,022
import torch import torch.nn as nn import torch.nn.functional as F import numpy as np from timm.models.layers import trunc_normal_, DropPath class ConvNeXtV2(nn.Module): """ ConvNeXt V2 Args: in_chans (int): Number of input image channels. Default: 3 num_classes (int): Number of classes for clas...
null
166,023
import torch import torch.nn as nn import torch.nn.functional as F import numpy as np from timm.models.layers import trunc_normal_, DropPath class ConvNeXtV2(nn.Module): def __init__(self, in_chans=3, num_classes=1000, depths=[3, 3, 9, 3], dims=[96, 192, 384, 768], drop_...
null
166,024
import torch import torch.nn as nn import torch.nn.functional as F import numpy as np from timm.models.layers import trunc_normal_, DropPath class ConvNeXtV2(nn.Module): def __init__(self, in_chans=3, num_classes=1000, depths=[3, 3, 9, 3], dims=[96, 192, 384, 768], drop_...
null
166,025
import torch import torch.nn as nn import torch.nn.functional as F import numpy as np from timm.models.layers import trunc_normal_, DropPath class ConvNeXtV2(nn.Module): """ ConvNeXt V2 Args: in_chans (int): Number of input image channels. Default: 3 num_classes (int): Number of classes for clas...
null
166,026
import torch import torch.nn as nn import torch.nn.functional as F import numpy as np from timm.models.layers import trunc_normal_, DropPath class ConvNeXtV2(nn.Module): """ ConvNeXt V2 Args: in_chans (int): Number of input image channels. Default: 3 num_classes (int): Number of classes for clas...
null
166,027
import torch import torch.nn as nn import torch.nn.functional as F import numpy as np from timm.models.layers import trunc_normal_, DropPath class ConvNeXtV2(nn.Module): """ ConvNeXt V2 Args: in_chans (int): Number of input image channels. Default: 3 num_classes (int): Number of classes for clas...
null
166,028
def parse_model(d, ch): # model_dict, input_channels(3) # Parse a YOLOv5 model.yaml dictionary LOGGER.info(f"\n{'':>3}{'from':>18}{'n':>3}{'params':>10} {'module':<40}{'arguments':<30}") anchors, nc, gd, gw, act = d['anchors'], d['nc'], d['depth_multiple'], d['width_multiple'], d.get('activation') i...
null
166,029
def _forward_once(self, x, profile=False, visualize=False): y, dt = [], [] # outputs for m in self.model: if m.f != -1: # if not from previous layer x = y[m.f] if isinstance(m.f, int) else [x if j == -1 else y[j] for j in m.f] # from earlier layers if profile: self._...
null
166,030
import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.checkpoint as checkpoint import itertools from timm.models.layers import SqueezeExcite import numpy as np import itertools def replace_batchnorm(net): class EfficientViT(torch.nn.Module): def __init__(self, img_size=400, ...
null
166,031
import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.checkpoint as checkpoint import itertools from timm.models.layers import SqueezeExcite import numpy as np import itertools def replace_batchnorm(net): for child_name, child in net.named_children(): if hasattr(child, 'fuse'...
null
166,032
import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.checkpoint as checkpoint import itertools from timm.models.layers import SqueezeExcite import numpy as np import itertools def replace_batchnorm(net): for child_name, child in net.named_children(): if hasattr(child, 'fuse'...
null
166,033
import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.checkpoint as checkpoint import itertools from timm.models.layers import SqueezeExcite import numpy as np import itertools def replace_batchnorm(net): class EfficientViT(torch.nn.Module): def __init__(self, img_size=400, ...
null
166,034
import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.checkpoint as checkpoint import itertools from timm.models.layers import SqueezeExcite import numpy as np import itertools def replace_batchnorm(net): for child_name, child in net.named_children(): if hasattr(child, 'fuse'...
null
166,035
import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.checkpoint as checkpoint import itertools from timm.models.layers import SqueezeExcite import numpy as np import itertools def replace_batchnorm(net): for child_name, child in net.named_children(): if hasattr(child, 'fuse'...
null
166,036
import torch import torch.nn as nn from torch.nn.modules.utils import _pair as to_2tuple from timm.layers import DropPath, to_2tuple from functools import partial import numpy as np class LSKNet(nn.Module): def __init__(self, img_size=224, in_chans=3, embed_dims=[64, 128, 256, 512], mlp_ratios=[8, 8...
null
166,037
import torch import torch.nn as nn from torch.nn.modules.utils import _pair as to_2tuple from timm.layers import DropPath, to_2tuple from functools import partial import numpy as np class LSKNet(nn.Module): def __init__(self, img_size=224, in_chans=3, embed_dims=[64, 128, 256, 512], mlp_ratios=[8, 8...
null
166,038
import numpy as np import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.checkpoint as checkpoint from timm.models.layers import DropPath, to_2tuple, trunc_normal_ def update_weight(model_dict, weight_dict): idx, temp_dict = 0, {} for k, v in weight_dict.items(): if k in ...
null
166,039
import numpy as np import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.checkpoint as checkpoint from timm.models.layers import DropPath, to_2tuple, trunc_normal_ def update_weight(model_dict, weight_dict): idx, temp_dict = 0, {} for k, v in weight_dict.items(): if k in ...
null
166,040
import numpy as np import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.checkpoint as checkpoint from timm.models.layers import DropPath, to_2tuple, trunc_normal_ def update_weight(model_dict, weight_dict): class FocalNet(nn.Module): def __init__(self, img_size...
null
166,041
import numpy as np import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.checkpoint as checkpoint from timm.models.layers import DropPath, to_2tuple, trunc_normal_ def update_weight(model_dict, weight_dict): idx, temp_dict = 0, {} for k, v in weight_dict.items(): if k in ...
null
166,042
import numpy as np import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.checkpoint as checkpoint from timm.models.layers import DropPath, to_2tuple, trunc_normal_ def update_weight(model_dict, weight_dict): idx, temp_dict = 0, {} for k, v in weight_dict.items(): if k in ...
null
166,043
import numpy as np import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.checkpoint as checkpoint from timm.models.layers import DropPath, to_2tuple, trunc_normal_ def update_weight(model_dict, weight_dict): idx, temp_dict = 0, {} for k, v in weight_dict.items(): if k in ...
null
166,044
import numpy as np import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.checkpoint as checkpoint from timm.models.layers import DropPath, to_2tuple, trunc_normal_ def update_weight(model_dict, weight_dict): idx, temp_dict = 0, {} for k, v in weight_dict.items(): if k in ...
null
166,045
import numpy as np import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.checkpoint as checkpoint from timm.models.layers import DropPath, to_2tuple, trunc_normal_ def update_weight(model_dict, weight_dict): idx, temp_dict = 0, {} for k, v in weight_dict.items(): if k in ...
null
166,046
import numpy as np import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.checkpoint as checkpoint from timm.models.layers import DropPath, to_2tuple, trunc_normal_ def update_weight(model_dict, weight_dict): idx, temp_dict = 0, {} for k, v in weight_dict.items(): if k in ...
null
166,047
import numpy as np import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.checkpoint as checkpoint from timm.models.layers import DropPath, to_2tuple, trunc_normal_ def update_weight(model_dict, weight_dict): idx, temp_dict = 0, {} for k, v in weight_dict.items(): if k in ...
null
166,048
import numpy as np import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.checkpoint as checkpoint from timm.models.layers import DropPath, to_2tuple, trunc_normal_ def update_weight(model_dict, weight_dict): class FocalNet(nn.Module): def __init__(self, img_size...
null
166,049
import numpy as np import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.checkpoint as checkpoint from timm.models.layers import DropPath, to_2tuple, trunc_normal_ def update_weight(model_dict, weight_dict): class FocalNet(nn.Module): def __init__(self, img_size...
null
166,050
import numpy as np import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.checkpoint as checkpoint from timm.models.layers import DropPath, to_2tuple, trunc_normal_ def update_weight(model_dict, weight_dict): idx, temp_dict = 0, {} for k, v in weight_dict.items(): if k in ...
null
166,051
import numpy as np import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.checkpoint as checkpoint from timm.models.layers import DropPath, to_2tuple, trunc_normal_ def update_weight(model_dict, weight_dict): idx, temp_dict = 0, {} for k, v in weight_dict.items(): if k in ...
null
166,052
import numpy as np import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.checkpoint as checkpoint from timm.models.layers import DropPath, to_2tuple, trunc_normal_ def update_weight(model_dict, weight_dict): idx, temp_dict = 0, {} for k, v in weight_dict.items(): if k in ...
null
166,053
import torch import torch.nn as nn import torch.nn.functional as F from timm.layers import trunc_normal_, DropPath, to_2tuple from functools import partial import torch.utils.checkpoint as checkpoint import numpy as np def get_conv2d(in_channels, out_channels, kernel_size, stride, padding, dilation, groups, bias, ...
null
166,054
import torch import torch.nn as nn import torch.nn.functional as F from timm.layers import trunc_normal_, DropPath, to_2tuple from functools import partial import torch.utils.checkpoint as checkpoint import numpy as np def get_bn(dim, use_sync_bn=False): if use_sync_bn: return nn.SyncBatchNorm(dim) els...
null
166,055
import torch import torch.nn as nn import torch.nn.functional as F from timm.layers import trunc_normal_, DropPath, to_2tuple from functools import partial import torch.utils.checkpoint as checkpoint import numpy as np def fuse_bn(conv, bn): conv_bias = 0 if conv.bias is None else conv.bias std = (bn.running_v...
null
166,056
import torch import torch.nn as nn import torch.nn.functional as F from timm.layers import trunc_normal_, DropPath, to_2tuple from functools import partial import torch.utils.checkpoint as checkpoint import numpy as np def convert_dilated_to_nondilated(kernel, dilate_rate): identity_kernel = torch.ones((1, 1, 1, 1)...
null
166,057
import torch import torch.nn as nn import torch.nn.functional as F from timm.layers import trunc_normal_, DropPath, to_2tuple from functools import partial import torch.utils.checkpoint as checkpoint import numpy as np UniRepLKNet_A_F_P_depths = (2, 2, 6, 2) class UniRepLKNet(nn.Module): r""" UniRepLKNet A ...
null
166,058
import torch import torch.nn as nn import torch.nn.functional as F from timm.layers import trunc_normal_, DropPath, to_2tuple from functools import partial import torch.utils.checkpoint as checkpoint import numpy as np UniRepLKNet_A_F_P_depths = (2, 2, 6, 2) class UniRepLKNet(nn.Module): r""" UniRepLKNet A ...
null
166,059
import torch import torch.nn as nn import torch.nn.functional as F from timm.layers import trunc_normal_, DropPath, to_2tuple from functools import partial import torch.utils.checkpoint as checkpoint import numpy as np UniRepLKNet_A_F_P_depths = (2, 2, 6, 2) class UniRepLKNet(nn.Module): r""" UniRepLKNet A ...
null
166,060
import torch import torch.nn as nn import torch.nn.functional as F from timm.layers import trunc_normal_, DropPath, to_2tuple from functools import partial import torch.utils.checkpoint as checkpoint import numpy as np UniRepLKNet_N_depths = (2, 2, 8, 2) class UniRepLKNet(nn.Module): r""" UniRepLKNet A PyTo...
null
166,061
import torch import torch.nn as nn import torch.nn.functional as F from timm.layers import trunc_normal_, DropPath, to_2tuple from functools import partial import torch.utils.checkpoint as checkpoint import numpy as np UniRepLKNet_T_depths = (3, 3, 18, 3) class UniRepLKNet(nn.Module): def __init__(self, ...
null
166,062
import torch import torch.nn as nn import torch.nn.functional as F from timm.layers import trunc_normal_, DropPath, to_2tuple from functools import partial import torch.utils.checkpoint as checkpoint import numpy as np UniRepLKNet_S_B_L_XL_depths = (3, 3, 27, 3) class UniRepLKNet(nn.Module): r""" UniRepLKNet ...
null
166,063
import torch import torch.nn as nn import torch.nn.functional as F from timm.layers import trunc_normal_, DropPath, to_2tuple from functools import partial import torch.utils.checkpoint as checkpoint import numpy as np UniRepLKNet_S_B_L_XL_depths = (3, 3, 27, 3) class UniRepLKNet(nn.Module): r""" UniRepLKNet ...
null
166,064
import torch import torch.nn as nn import torch.nn.functional as F from timm.layers import trunc_normal_, DropPath, to_2tuple from functools import partial import torch.utils.checkpoint as checkpoint import numpy as np UniRepLKNet_S_B_L_XL_depths = (3, 3, 27, 3) class UniRepLKNet(nn.Module): def __init__(self, ...
null
166,065
import torch import torch.nn as nn import torch.nn.functional as F from timm.layers import trunc_normal_, DropPath, to_2tuple from functools import partial import torch.utils.checkpoint as checkpoint import numpy as np UniRepLKNet_S_B_L_XL_depths = (3, 3, 27, 3) class UniRepLKNet(nn.Module): r""" UniRepLKNet ...
null
166,066
import warnings import cv2, os, shutil import numpy as np from ultralytics import YOLO def get_video_cfg(path): video = cv2.VideoCapture(path) size = (int(video.get(cv2.CAP_PROP_FRAME_WIDTH)), int(video.get(cv2.CAP_PROP_FRAME_HEIGHT))) fps = int(video.get(cv2.CAP_PROP_FPS)) return cv2.VideoWriter_fourc...
null
166,067
import warnings import cv2, os, shutil import numpy as np from ultralytics import YOLO def plot_and_counting(result): image_plot = result.plot() box_count = result.boxes.shape[0] cv2.putText(image_plot, f'Object Counts:{box_count}', (10, 50), cv2.FONT_HERSHEY_SIMPLEX, 1.5, (0, 0, 255), 4) return image_...
null
166,068
import warnings import torch, yaml, cv2, os, shutil import numpy as np import matplotlib.pyplot as plt from tqdm import trange from PIL import Image from models.yolo import Model from utils.datasets import letterbox from utils.general import xywh2xyxy, non_max_suppression from models.experimental import attempt_load fr...
null
166,069
import warnings import torch, yaml, cv2, os, shutil, sys import numpy as np np.random.seed(0) import matplotlib.pyplot as plt from tqdm import trange from PIL import Image from ultralytics.nn.tasks import attempt_load_weights from ultralytics.utils.torch_utils import intersect_dicts from ultralytics.utils.ops import xy...
null
166,070
import warnings import torch, yaml, cv2, os, shutil, sys import numpy as np import matplotlib.pyplot as plt from tqdm import trange from PIL import Image from ultralytics.nn.tasks import attempt_load_weights from ultralytics.utils.torch_utils import intersect_dicts from ultralytics.utils.ops import xywh2xyxy, non_max_s...
null
166,071
import warnings import torch, yaml, cv2, os, shutil import numpy as np import matplotlib.pyplot as plt from tqdm import trange from PIL import Image from models.yolo import Model from utils.augmentations import letterbox from utils.general import xywh2xyxy, non_max_suppression from models.experimental import attempt_lo...
null
166,072
import warnings import torch, yaml, cv2, os, shutil import numpy as np import matplotlib.pyplot as plt from tqdm import trange from PIL import Image from models.yolo import Model from utils.general import intersect_dicts from utils.augmentations import letterbox from utils.general import xywh2xyxy, non_max_suppression ...
null
166,073
import os import glob import json import shutil import numpy as np import xml.etree.ElementTree as ET def find_classes(path): classes = [] for i in os.listdir(path): try: in_file = open(os.path.join(path, i), encoding='utf-8') tree=ET.parse(in_file) root = tree.getro...
null
166,074
import os import glob import json import shutil import numpy as np import xml.etree.ElementTree as ET START_BOUNDING_BOX_ID = 1 def get(root, name): return root.findall(name) def get_and_check(root, name, length): vars = root.findall(name) if len(vars) == 0: raise NotImplementedError('Can not find %...
null
166,075
import numpy as np import torch from torch import nn from torch.nn import init The provided code snippet includes necessary dependencies for implementing the `autopad` function. Write a Python function `def autopad(k, p=None, d=1)` to solve the following problem: Pad to 'same' shape outputs. Here is the function: de...
Pad to 'same' shape outputs.
166,076
import numpy as np import torch from torch import nn from torch.nn import init def spatial_shift1(x): b, w, h, c = x.size() x[:, 1:, :, :c // 4] = x[:, :w - 1, :, :c // 4] x[:, :w - 1, :, c // 4:c // 2] = x[:, 1:, :, c // 4:c // 2] x[:, :, 1:, c // 2:c * 3 // 4] = x[:, :, :h - 1, c // 2:c * 3 // 4] ...
null
166,077
import numpy as np import torch from torch import nn from torch.nn import init def spatial_shift2(x): b, w, h, c = x.size() x[:, :, 1:, :c // 4] = x[:, :, :h - 1, :c // 4] x[:, :, :h - 1, c // 4:c // 2] = x[:, :, 1:, c // 4:c // 2] x[:, 1:, :, c // 2:c * 3 // 4] = x[:, :w - 1, :, c // 2:c * 3 // 4] ...
null
166,078
from typing import Tuple, Optional import torch import torch.nn as nn import torch.nn.functional as F from einops import rearrange from torch import Tensor, LongTensor def _grid2seq(x:Tensor, region_size:Tuple[int], num_heads:int): """ Args: x: BCHW tensor region size: int num_heads: num...
Args: query, key, value: (B, C, H, W) tensor scale: the scale/temperature for dot product attention region_graph: (B, nhead, h_q*w_q, topk) tensor, topk <= h_k*w_k region_size: region/window size for queries, (rh, rw) key_region_size: optional, if None, key_region_size=region_size auto_pad: required to be true if the i...
166,079
import torch, time, math, thop, tqdm, torchvision import torch.nn as nn import torch.nn.functional as F from torch.nn.modules.conv import _ConvNd from torch.nn.modules.utils import _pair from torch.nn.parameter import Parameter from prettytable import PrettyTable from ops_dcnv3.modules import DCNv3 def time_synchroniz...
null
166,080
import torch, time, math, thop, tqdm, torchvision import torch.nn as nn import torch.nn.functional as F from torch.nn.modules.conv import _ConvNd from torch.nn.modules.utils import _pair from torch.nn.parameter import Parameter from prettytable import PrettyTable from ops_dcnv3.modules import DCNv3 def autopad(k, p=No...
null
166,081
import warnings import argparse import logging import math import os import random import time import sys from copy import deepcopy from pathlib import Path from threading import Thread import numpy as np import torch.distributed as dist import torch.nn as nn import torch.nn.functional as F import torch.optim as optim ...
null
166,082
import warnings import argparse import logging import math import os import random import time import sys from copy import deepcopy from pathlib import Path from threading import Thread import numpy as np import torch.distributed as dist import torch.nn as nn import torch.nn.functional as F import torch.optim as optim ...
null
166,083
import os, cv2, tqdm, shutil import numpy as np def xywh2xyxy(box): box[:, 0] = box[:, 0] - box[:, 2] / 2 box[:, 1] = box[:, 1] - box[:, 3] / 2 box[:, 2] = box[:, 0] + box[:, 2] box[:, 3] = box[:, 1] + box[:, 3] return box
null
166,084
import os, cv2, tqdm, shutil import numpy as np def iou(box1, box2): x11, y11, x12, y12 = np.split(box1, 4, axis=1) x21, y21, x22, y22 = np.split(box2, 4, axis=1) xa = np.maximum(x11, np.transpose(x21)) xb = np.minimum(x12, np.transpose(x22)) ya = np.maximum(y11, np.transpose(y21)) yb = np.mi...
null
166,085
import os, cv2, tqdm, shutil import numpy as np def draw_box(img, box, color): cv2.rectangle(img, (int(box[0]), int(box[1])), (int(box[2]), int(box[3])), color, thickness=2) return img
null
166,086
import pkg_resources as pkg def check_version(current='0.0.0', minimum='0.0.0', name='version ', pinned=False, hard=False, verbose=False): def set_seeds(seed=0, deterministic=False): # Initialize random number generator (RNG) seeds https://pytorch.org/docs/stable/notes/randomness.html random.seed(seed) np....
null
166,087
import cv2 import numpy as np import matplotlib.pylab as plt from segment_anything import SamPredictor, sam_model_registry def show_mask(mask, ax, random_color=False): if random_color: color = np.concatenate([np.random.random(3), np.array([0.6])], axis=0) else: color = np.array([30/255, 144/255...
null
166,088
import cv2 import numpy as np import matplotlib.pylab as plt from segment_anything import SamPredictor, sam_model_registry def show_points(coords, labels, ax, marker_size=375): pos_points = coords[labels==1] neg_points = coords[labels==0] ax.scatter(pos_points[:, 0], pos_points[:, 1], color='green', marker...
null
166,089
import cv2 import numpy as np import matplotlib.pylab as plt from segment_anything import SamPredictor, sam_model_registry def show_box(box, ax): x0, y0 = box[0], box[1] w, h = box[2] - box[0], box[3] - box[1] ax.add_patch(plt.Rectangle((x0, y0), w, h, edgecolor='green', facecolor=(0,0,0,0), lw=2))
null
166,090
import os import cv2 import json from tqdm import tqdm from sklearn.model_selection import train_test_split import argparse def yolo2coco(arg): root_path = arg.root_dir print("Loading data from ",root_path) assert os.path.exists(root_path) originLabelsDir = os.path.join(root_path, 'labels/test') ...
null
166,091
The provided code snippet includes necessary dependencies for implementing the `feature_visualization` function. Write a Python function `def feature_visualization(x, module_type, stage, n=32, save_dir=Path('runs/detect/exp'))` to solve the following problem: x: Features to be visualized module_type: Module type stag...
x: Features to be visualized module_type: Module type stage: Module stage within model n: Maximum number of feature maps to plot save_dir: Directory to save results
166,092
import datetime import os from typing import List import tensorflow_model_analysis as tfma from tfx.components import CsvExampleGen from tfx.components import Evaluator from tfx.components import ExampleValidator from tfx.components import Pusher from tfx.components import SchemaGen from tfx.components import Statistic...
Implements the chicago taxi pipeline with TFX.
166,093
import argparse import base64 import csv import json import os import subprocess import tempfile from typing import List from absl import app from absl.flags import argparse_flags import requests import tensorflow_data_validation as tfdv from tensorflow_transform import coders as tft_coders from tensorflow_transform.tf...
Reads a schema from the provided location. Args: path: The location of the file holding a serialized Schema proto. Returns: An instance of Schema or None if the input argument is None
166,094
import argparse import base64 import csv import json import os import subprocess import tempfile from typing import List from absl import app from absl.flags import argparse_flags import requests import tensorflow_data_validation as tfdv from tensorflow_transform import coders as tft_coders from tensorflow_transform.tf...
Sends requests to the model and prints the results. Args: model_handle: handle to the model. This can be either "aiplatform:model:version" or "host:port" examples_file: path to csv file containing examples, with the first line assumed to have the column headers num_examples: number of requests to send to the server sch...
166,095
import argparse import base64 import csv import json import os import subprocess import tempfile from typing import List from absl import app from absl.flags import argparse_flags import requests import tensorflow_data_validation as tfdv from tensorflow_transform import coders as tft_coders from tensorflow_transform.tf...
Command lines flag parsing.
166,096
from typing import List from absl import logging import tensorflow as tf import tensorflow_transform as tft from tfx.components.trainer.fn_args_utils import DataAccessor from tfx.components.trainer.fn_args_utils import FnArgs from tfx_bsl.tfxio import dataset_options _CATEGORICAL_FEATURE_KEYS = [ 'trip_start_hour',...
tf.transform's callback function for preprocessing inputs. Args: inputs: map from feature keys to raw not-yet-transformed features. Returns: Map from string feature key to transformed feature operations.
166,097
from typing import List from absl import logging import tensorflow as tf import tensorflow_transform as tft from tfx.components.trainer.fn_args_utils import DataAccessor from tfx.components.trainer.fn_args_utils import FnArgs from tfx_bsl.tfxio import dataset_options def _get_tf_examples_serving_signature(model, tf_tra...
Train the model based on given args. Args: fn_args: Holds args used to train the model as name/value pairs.
166,098
from typing import List import tensorflow as tf from tensorflow import estimator as tf_estimator import tensorflow_model_analysis as tfma import tensorflow_transform as tft from tensorflow_transform.tf_metadata import schema_utils from tfx.components.trainer.fn_args_utils import DataAccessor from tfx_bsl.tfxio import d...
tf.transform's callback function for preprocessing inputs. Args: inputs: map from feature keys to raw not-yet-transformed features. Returns: Map from string feature key to transformed feature operations.
166,099
from typing import List import tensorflow as tf from tensorflow import estimator as tf_estimator import tensorflow_model_analysis as tfma import tensorflow_transform as tft from tensorflow_transform.tf_metadata import schema_utils from tfx.components.trainer.fn_args_utils import DataAccessor from tfx_bsl.tfxio import d...
Build the estimator using the high level API. Args: trainer_fn_args: Holds args used to train the model as name/value pairs. schema: Holds the schema of the training examples. Returns: A dict of the following: - estimator: The estimator that will be used for training and eval. - train_spec: Spec for training. - eval_sp...
166,100
import os from typing import List import absl import tensorflow_model_analysis as tfma from tfx.components import CsvExampleGen from tfx.components import Evaluator from tfx.components import ExampleValidator from tfx.components import Pusher from tfx.components import SchemaGen from tfx.components import StatisticsGen...
Implements the chicago taxi pipeline with TFX.
166,101
import os from typing import List import absl import tensorflow_model_analysis as tfma from tfx.components import CsvExampleGen from tfx.components import Evaluator from tfx.components import ExampleValidator from tfx.components import Pusher from tfx.components import SchemaGen from tfx.components import StatisticsGen...
Implements the chicago taxi pipeline with TFX.
166,102
import os from typing import List import absl import tensorflow as tf from tensorflow import keras import tensorflow_transform as tft from tfx.components.trainer.rewriting import converters from tfx.components.trainer.rewriting import rewriter from tfx.components.trainer.rewriting import rewriter_factory from tfx.dsl.i...
Callback function for preprocessing inputs. Args: inputs: map from feature keys to raw not-yet-transformed features. Returns: Map from string feature key to transformed feature operations.
166,103
import os from typing import List import absl import tensorflow as tf from tensorflow import keras import tensorflow_transform as tft from tfx.components.trainer.rewriting import converters from tfx.components.trainer.rewriting import rewriter from tfx.components.trainer.rewriting import rewriter_factory from tfx.dsl.i...
Train the model based on given args. Args: fn_args: Holds args used to train the model as name/value pairs.
166,104
import os from typing import List import absl import tensorflow_model_analysis as tfma from tfx.v1 import dsl from tfx.v1 import orchestration from tfx.v1 import proto from tfx.v1 import types from tfx.v1.components import Evaluator from tfx.v1.components import ExampleValidator from tfx.v1.components import ImportExam...
Implements the page prediction pipline with TFX.
166,105
from typing import Any, Dict, List, Union import apache_beam as beam from apache_beam.io.gcp.internal.clients import bigquery import tensorflow as tf def _sanitize_page_path(page_path: str): """Remove everything after the query.""" return page_path.split('?')[0] def create_tensorflow_example( features: Dict[str...
Converts a Google Analytics Session to Tensorflow Examples.
166,106
from typing import Any, Dict, List, Union import apache_beam as beam from apache_beam.io.gcp.internal.clients import bigquery import tensorflow as tf def is_duplicate_event(first_event: Dict[str, Any], second_event: Dict[str, Any]): return (first_event['time'] == second_event['time'] or ...
null
166,107
from typing import Any, Dict, List, Union import apache_beam as beam from apache_beam.io.gcp.internal.clients import bigquery import tensorflow as tf class ExampleGeneratingDoFn(beam.DoFn): """Creates Tensorflow Examples from the provided Google Analytics session.""" def process(self, entry: Dict[str, Any]): se...
Run the apache beam pipeline with the specified flags.
166,108
import datetime import os from typing import List from absl import logging import keras_tuner import tensorflow as tf from tensorflow import keras import tensorflow_transform as tft import tfx.v1 as tfx from tfx_bsl.public import tfxio from tensorflow_cloud.core import machine_config from tensorflow_cloud.tuner import ...
tf.transform's callback function for preprocessing inputs. Args: inputs: map from feature keys to raw not-yet-transformed features. Returns: Map from string feature key to transformed feature operations.
166,109
import datetime import os from typing import List from absl import logging import keras_tuner import tensorflow as tf from tensorflow import keras import tensorflow_transform as tft import tfx.v1 as tfx from tfx_bsl.public import tfxio from tensorflow_cloud.core import machine_config from tensorflow_cloud.tuner import ...
Build the tuner using the CloudTuner API. Args: fn_args: Holds args as name/value pairs. See https://www.tensorflow.org/tfx/api_docs/python/tfx/components/trainer/fn_args_utils/FnArgs. - transform_graph_path: optional transform graph produced by TFT. - custom_config: An optional dictionary passed to the component. In t...
166,110
import datetime import os from typing import List from absl import logging import keras_tuner import tensorflow as tf from tensorflow import keras import tensorflow_transform as tft import tfx.v1 as tfx from tfx_bsl.public import tfxio from tensorflow_cloud.core import machine_config from tensorflow_cloud.tuner import ...
Train the model based on given args. Args: fn_args: Holds args as name/value pairs. See https://www.tensorflow.org/tfx/api_docs/python/tfx/components/trainer/fn_args_utils/FnArgs. - train_files: List of file paths containing training tf.Example data. - eval_files: List of file paths containing eval tf.Example data. - d...
166,111
from typing import List from absl import logging import tensorflow as tf import tensorflow_transform as tft from tfx import v1 as tfx from tfx_bsl.public import tfxio FEATURE_KEYS = [ 'culmen_length_mm', 'culmen_depth_mm', 'flipper_length_mm', 'body_mass_g' ] _LABEL_KEY = 'species' def transformed_name(key): retu...
tf.transform's callback function for preprocessing inputs. Args: inputs: map from feature keys to raw not-yet-transformed features. Returns: Map from string feature key to transformed feature operations.