id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
26,392
import importlib import argparse import gc import math import os import sys import random import time import json from multiprocessing import Value from tqdm import tqdm import torch from accelerate.utils import set_seed from diffusers import DDPMScheduler from library import model_util import library.train_util as tra...
null
26,393
import os, sys import argparse import torch from torch import load, save from safetensors import safe_open from safetensors.torch import save_file def get_args(): parser = argparse.ArgumentParser() parser.add_argument( "lora_model", help="The model you want to pack embeddings into it.", ...
null
26,394
import os, sys import argparse import torch from torch import load, save from safetensors import safe_open from safetensors.torch import save_file def load_state_dict(file_path): is_safetensors = file_path.rsplit(".", 1)[-1] == "safetensors" if is_safetensors: state_dict = {} with safe_open(fil...
null
26,395
import os, sys import argparse from lycoris.utils import merge from lycoris.kohya.model_utils import ( load_models_from_stable_diffusion_checkpoint, save_stable_diffusion_checkpoint, load_file, ) from lycoris.kohya.sdxl_model_util import ( load_models_from_sdxl_checkpoint, save_stable_diffusion_chec...
null
26,396
import os, sys import argparse from lycoris.utils import extract_diff from lycoris.kohya.model_utils import load_models_from_stable_diffusion_checkpoint from lycoris.kohya.sdxl_model_util import load_models_from_sdxl_checkpoint import torch from safetensors.torch import save_file def get_args(): parser = argparse....
null
26,397
import os import argparse import warnings from typing import List from collections import defaultdict import torch from torch import load, save from safetensors import safe_open from safetensors.torch import save_file def load_state_dict(file_path): is_safetensors = file_path.rsplit(".", 1)[-1] == "safetensors" ...
null
26,398
import os import argparse import warnings from typing import List from collections import defaultdict import torch from torch import load, save from safetensors import safe_open from safetensors.torch import save_file def save_state_dict(state, output_path): if output_path.endswith(".safetensors"): save_fi...
null
26,399
import os import argparse import warnings from typing import List from collections import defaultdict import torch from torch import load, save from safetensors import safe_open from safetensors.torch import save_file def pack_bundle(lora, emb_dict, verbose=False): for emb, emb_sd in emb_dict.items(): for ...
null
26,400
import os import argparse import warnings from typing import List from collections import defaultdict import torch from torch import load, save from safetensors import safe_open from safetensors.torch import save_file def print_emb_information(emb_dict): for emb, emb_sd in emb_dict.items(): print(emb) ...
null
26,401
import os import argparse import warnings from typing import List from collections import defaultdict import torch from torch import load, save from safetensors import safe_open from safetensors.torch import save_file The provided code snippet includes necessary dependencies for implementing the `gather_files_from_lis...
Gather files from given paths based on specific extensions. Args: paths (List[str]): A list of paths which can be files or directories. extensions (List[str]): A list of file extensions to filter by. recursive (bool): If True, search for files recursively in directories. Returns: List[str]: A list of file paths that ma...
26,402
import os import argparse import warnings from typing import List from collections import defaultdict import torch from torch import load, save from safetensors import safe_open from safetensors.torch import save_file def extract_step(file_path): filename = os.path.splitext(os.path.basename(file_path))[0] step ...
Associate LoRA model files with embedding files based on their step count. This function takes in lists of LoRA file paths and embedding file paths, extracts their step counts, and associates them based on matching steps. If a file's step count cannot be determined, it uses the key 'none'. Args: lora_files (List[str]):...
26,403
import os import argparse import warnings from typing import List from collections import defaultdict import torch from torch import load, save from safetensors import safe_open from safetensors.torch import save_file def extract_step(file_path): def convert_lora_name(network_path, dst_dir, to_bundle): name, step ...
null
26,404
import os import sys import math import argparse import warnings from typing import List, Dict from collections import defaultdict import torch from safetensors.torch import load_file from hcpdiff.ckpt_manager import auto_manager The provided code snippet includes necessary dependencies for implementing the `gather_fi...
Gather files from given paths based on specific extensions. Args: paths (List[str]): A list of paths which can be files or directories. extensions (List[str]): A list of file extensions to filter by. recursive (bool): If True, search for files recursively in directories. Returns: List[str]: A list of file paths that ma...
26,405
import os import sys import math import argparse import warnings from typing import List, Dict from collections import defaultdict import torch from safetensors.torch import load_file from hcpdiff.ckpt_manager import auto_manager The provided code snippet includes necessary dependencies for implementing the `get_unet_...
Get unet and text encoder pairs from a list of files. Args: files (List[str]): A list of candidate file paths. Returns: Dict[str, Dict[str, str]]: A dictionary where keys are file names and values are dictionaries containing paths to unet and text encoder files. Raises: ValueError: If muliple unet or text encoder files...
26,406
import os import sys import math import argparse import warnings from typing import List, Dict from collections import defaultdict import torch from safetensors.torch import load_file from hcpdiff.ckpt_manager import auto_manager def save_and_print_path(sd, path): try: # Old HCP ckpt_manager = auto...
null
26,407
import os import sys import math import argparse import warnings from typing import List, Dict from collections import defaultdict import torch from safetensors.torch import load_file from hcpdiff.ckpt_manager import auto_manager def get_network_types(sd_unet, sd_te): network_types = [] for network_type in ["l...
null
26,408
import os, sys import argparse from lycoris.kohya.model_utils import load_file, load_models_from_stable_diffusion_checkpoint from lycoris.kohya import create_hypernetwork import torch import torch.nn as nn from torchvision.transforms.functional import resize, to_tensor from PIL import Image from safetensors.torch impor...
null
26,409
from typing import List, Dict, Any, Callable, Type, TypeVar, Union from .dataexchange import Response from .datatypes import DataType, Integer, Real T = TypeVar("T") The provided code snippet includes necessary dependencies for implementing the `number_square_function_body` function. Write a Python function `def numbe...
Body for integer/float square
26,410
from typing import List, Dict, Any, Callable, Type, TypeVar, Union from .dataexchange import Response from .datatypes import DataType, Integer, Real The provided code snippet includes necessary dependencies for implementing the `value_count_function_body` function. Write a Python function `def value_count_function_bod...
Note: count(*) counts every row (not supported in learndb) count(column) should only count non-null columns
26,411
from typing import List, Dict, Any, Callable, Type, TypeVar, Union from .dataexchange import Response from .datatypes import DataType, Integer, Real _SCALAR_FUNCTION_REGISTRY = { "square": integer_square_function, "square_float": float_square_function, } The provided code snippet includes necessary dependencie...
Return list of all scalar function names
26,412
from typing import List, Dict, Any, Callable, Type, TypeVar, Union from .dataexchange import Response from .datatypes import DataType, Integer, Real _AGGREGATE_FUNCTION_REGISTRY = {"count": count_function} The provided code snippet includes necessary dependencies for implementing the `get_aggregate_functions_names` fu...
Return list of all aggregate function names
26,413
from typing import List, Dict, Any, Callable, Type, TypeVar, Union from .dataexchange import Response from .datatypes import DataType, Integer, Real def resolve_function_name(name: str) -> FunctionDefinition: """ Resolve function name, i.e. lookup name in registry. In the future this could be extended to su...
null
26,414
from typing import List, Dict, Any, Callable, Type, TypeVar, Union from .dataexchange import Response from .datatypes import DataType, Integer, Real def resolve_function_name(name: str) -> FunctionDefinition: """ Resolve function name, i.e. lookup name in registry. In the future this could be extended to su...
null
26,415
from enum import Enum from typing import Type from .constants import CELL_KEY_SIZE_SIZE, CELL_DATA_SIZE_SIZE, INTEGER_SIZE from .datatypes import DataType, Null, Integer, Text, Blob, Real from .dataexchange import Response from .schema import SimpleSchema from .record_utils import SimpleRecord class SerialType(Enum): ...
Serialize an entire record and return the bytes corresponding to a cell. For now, serialize each value and concatenate the resulting bytes. If this is not performant, consider using struct.pack See docs/file-format.txt for complete details; the following are the key details of a node: - (low address) header, cell point...
26,416
from enum import Enum from typing import Type from .constants import CELL_KEY_SIZE_SIZE, CELL_DATA_SIZE_SIZE, INTEGER_SIZE from .datatypes import DataType, Null, Integer, Text, Blob, Real from .dataexchange import Response from .schema import SimpleSchema from .record_utils import SimpleRecord class SerialType(Enum): ...
deserialize cell corresponding to schema :param cell: :param schema: :return: Response[Record]
26,417
from enum import Enum from typing import Type from .constants import CELL_KEY_SIZE_SIZE, CELL_DATA_SIZE_SIZE, INTEGER_SIZE from .datatypes import DataType, Null, Integer, Text, Blob, Real from .dataexchange import Response from .schema import SimpleSchema from .record_utils import SimpleRecord def get_cell_key_in_page(...
:param cell: :return:
26,418
from enum import Enum from typing import Type from .constants import CELL_KEY_SIZE_SIZE, CELL_DATA_SIZE_SIZE, INTEGER_SIZE from .datatypes import DataType, Null, Integer, Text, Blob, Real from .dataexchange import Response from .schema import SimpleSchema from .record_utils import SimpleRecord CELL_KEY_SIZE_SIZE = WOR...
null
26,419
from enum import Enum, auto from typing import Type from .datatypes import DataType, Integer, Real, Blob, Text from .lang_parser.symbols import SymbolicDataType class DataType: """ This is a datatype of a value in the database. This provides an interface to provide serde of implemented type and detail...
Convert symbols.DataType to datatypes.DataType
26,420
from __future__ import annotations from copy import copy from typing import List, Optional, Union from .datatypes import DataType, Integer, Text, Blob, Real from .dataexchange import Response from .lang_parser.symbols import TableName, SymbolicDataType, ColumnName class SimpleSchema(AbstractSchema): """ Represe...
convert a schema to canonical ddl parser rule: create_stmnt -> "create" "table" table_name "(" column_def_list ")" e.g. ddl create table catalog ( pkey int primary key type text, name text, tbl_name text, rootpage integer, sql text ) :return:
26,421
from __future__ import annotations from copy import copy from typing import List, Optional, Union from .datatypes import DataType, Integer, Text, Blob, Real from .dataexchange import Response from .lang_parser.symbols import TableName, SymbolicDataType, ColumnName class Column: """ Represents a column in a sche...
Generate schema from a create stmnt. There is a very thin layer of translation between the stmnt and the schema object. But I want to distinguish the (create) stmnt from the schema. Note if the operation is successful, a valid schema was read. :param create_stmnt: :return:
26,422
from __future__ import annotations from copy import copy from typing import List, Optional, Union from .datatypes import DataType, Integer, Text, Blob, Real from .dataexchange import Response from .lang_parser.symbols import TableName, SymbolicDataType, ColumnName class Column: """ Represents a column in a sche...
Generate an unvalidated schema with argument `columns`. This is used for output schema, which doesn't have primary key. NOTE: `unvalidated` means we don't run any validations, e.g. generated schema must have a primary key. TODO: apply any validations that do hold, e.g. column name uniqueness?
26,423
from __future__ import annotations from copy import copy from typing import List, Optional, Union from .datatypes import DataType, Integer, Text, Blob, Real from .dataexchange import Response from .lang_parser.symbols import TableName, SymbolicDataType, ColumnName class GroupedSchema(AbstractSchema): """ Repres...
Generate a grouped schema from a non-grouped schema. How will this handle both simple, and multi-schema
26,424
from __future__ import annotations from typing import Any, List, Optional, Union, Tuple from .dataexchange import Response from .lang_parser.symbols import ColumnName, ColumnNameList, ValueList, Literal from .schema import SimpleSchema, ScopedSchema, GroupedSchema class SimpleRecord(AbstractRecord): """ Represe...
TODO: remove if unused join records and return a multi-record left_, right_empty are used to handle left, right outer joined records :return:
26,425
from __future__ import annotations from typing import Any, List, Optional, Union, Tuple from .dataexchange import Response from .lang_parser.symbols import ColumnName, ColumnNameList, ValueList, Literal from .schema import SimpleSchema, ScopedSchema, GroupedSchema class SimpleRecord(AbstractRecord): """ Represe...
given a `schema` return a record with the given schema and all fields set to null :param schema: :return:
26,426
from __future__ import annotations from typing import Any, List, Optional, Union, Tuple from .dataexchange import Response from .lang_parser.symbols import ColumnName, ColumnNameList, ValueList, Literal from .schema import SimpleSchema, ScopedSchema, GroupedSchema class SimpleRecord(AbstractRecord): """ Represe...
Needed for creating final output recordset; Uses raw values, i.e. unboxed values # TODO: refactor to remove `column_names` which can be derived from schema, like: [col.name for col schema.columns]
26,427
from __future__ import annotations from typing import Any, List, Optional, Union, Tuple from .dataexchange import Response from .lang_parser.symbols import ColumnName, ColumnNameList, ValueList, Literal from .schema import SimpleSchema, ScopedSchema, GroupedSchema def create_record( column_name_list: ColumnNameList...
Create a catalog record. NOTE: This must produce a type identical output to parser :param pkey: :param table_name: :param root_page_num: :param sql_text: :param catalog_schema: :return:
26,428
import re The provided code snippet includes necessary dependencies for implementing the `camel_to_snake` function. Write a Python function `def camel_to_snake(name: str) -> str` to solve the following problem: change casing abcdXyz -> abcd_xyz Here is the function: def camel_to_snake(name: str) -> str: """ ...
change casing abcdXyz -> abcd_xyz
26,429
import re The provided code snippet includes necessary dependencies for implementing the `pascal_to_snake` function. Write a Python function `def pascal_to_snake(name) -> str` to solve the following problem: convert case HelloWorld -> hello_world :return: Here is the function: def pascal_to_snake(name) -> str: "...
convert case HelloWorld -> hello_world :return:
26,430
import sys import struct from abc import ABCMeta from typing import Any, Type from .constants import INTEGER_SIZE, REAL_SIZE class DataType: """ This is a datatype of a value in the database. This provides an interface to provide serde of implemented type and details of underlying encoding. Note: Th...
Return True, if term is valid for given datatype
26,431
from __future__ import annotations import os import os.path import sys import logging from typing import List from .constants import DB_FILE, USAGE, EXIT_SUCCESS from .lang_parser.sqlhandler import SqlFrontEnd from .lang_parser.symbols import Program from .dataexchange import Response, MetaCommandResult from .pipe impo...
null
26,432
from __future__ import annotations import os import os.path import sys import logging from typing import List from .constants import DB_FILE, USAGE, EXIT_SUCCESS from .lang_parser.sqlhandler import SqlFrontEnd from .lang_parser.symbols import Program from .dataexchange import Response, MetaCommandResult from .pipe impo...
parse args and starts :return:
26,433
import os import cv2 import torch import numpy as np from math import factorial from pyquaternion import Quaternion import mmcv from mmdet.datasets import DATASETS from mmdet3d.datasets import Custom3DDataset from openlanev2.dataset import Collection from openlanev2.evaluation import evaluate as openlanev2_evaluate fro...
null
26,434
import os import cv2 import torch import numpy as np from math import factorial from pyquaternion import Quaternion import mmcv from mmdet.datasets import DATASETS from mmdet3d.datasets import Custom3DDataset from openlanev2.dataset import Collection from openlanev2.evaluation import evaluate as openlanev2_evaluate fro...
null
26,435
import os import cv2 import torch import numpy as np from math import factorial from pyquaternion import Quaternion import mmcv from mmdet.datasets import DATASETS from mmdet3d.datasets import Custom3DDataset from openlanev2.dataset import Collection from openlanev2.evaluation import evaluate as openlanev2_evaluate fro...
null
26,436
from cmath import pi from mmcv.ops.multi_scale_deform_attn import multi_scale_deformable_attn_pytorch import mmcv import cv2 as cv import copy import warnings from matplotlib import pyplot as plt import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from mmcv.cnn import xavier_init, cons...
Inverse function of sigmoid. Args: x (Tensor): The tensor to do the inverse. eps (float): EPS avoid numerical overflow. Defaults 1e-5. Returns: Tensor: The x has passed the inverse function of sigmoid, has same shape with input.
26,437
import copy import math import torch import torch.nn as nn import torch.nn.functional as F from mmcv.runner import BaseModule from mmdet3d.models import NECKS The provided code snippet includes necessary dependencies for implementing the `get_campos` function. Write a Python function `def get_campos(reference_points, ...
Find the each refence point's corresponding pixel in each camera Args: reference_points: [B, num_query, 3] ego2cam: (B, num_cam, 4, 4) Outs: reference_points_cam: (B*num_cam, num_query, 2) mask: (B, num_cam, num_query) num_query == W*H
26,438
import copy import math import torch import torch.nn as nn import torch.nn.functional as F from mmcv.runner import BaseModule from mmdet3d.models import NECKS The provided code snippet includes necessary dependencies for implementing the `construct_plane_grid` function. Write a Python function `def construct_plane_gri...
Returns: plane: H, W, 3
26,439
import torch import torch.nn as nn from collections import OrderedDict import torch.utils.checkpoint as checkpoint from timm.models.layers import trunc_normal_, DropPath from mmcv.runner import _load_checkpoint from mmcv.cnn import constant_init, trunc_normal_init from mmdet.utils import get_root_logger from mmdet.mode...
null
26,440
import torch import torch.nn as nn from collections import OrderedDict import torch.utils.checkpoint as checkpoint from timm.models.layers import trunc_normal_, DropPath from mmcv.runner import _load_checkpoint from mmcv.cnn import constant_init, trunc_normal_init from mmdet.utils import get_root_logger from mmdet.mode...
null
26,441
from __future__ import absolute_import from __future__ import print_function from __future__ import division import warnings import torch from torch import nn import torch.nn.functional as F from torch.nn.init import xavier_uniform_, constant_ from ..functions import DCNv3Function, dcnv3_core_pytorch class to_channels_...
null
26,442
from __future__ import absolute_import from __future__ import print_function from __future__ import division import warnings import torch from torch import nn import torch.nn.functional as F from torch.nn.init import xavier_uniform_, constant_ from ..functions import DCNv3Function, dcnv3_core_pytorch def build_act_lay...
null
26,443
from __future__ import absolute_import from __future__ import print_function from __future__ import division import warnings import torch from torch import nn import torch.nn.functional as F from torch.nn.init import xavier_uniform_, constant_ from ..functions import DCNv3Function, dcnv3_core_pytorch def _is_power_of_...
null
26,444
import os import glob import torch from torch.utils.cpp_extension import CUDA_HOME from torch.utils.cpp_extension import CppExtension from torch.utils.cpp_extension import CUDAExtension from setuptools import find_packages from setuptools import setup def get_extensions(): this_dir = os.path.dirname(os.path.abspat...
null
26,445
from __future__ import absolute_import from __future__ import print_function from __future__ import division import torch import torch.nn.functional as F from torch.autograd import Function from torch.autograd.function import once_differentiable from torch.cuda.amp import custom_bwd, custom_fwd import DCNv3 def _get_re...
null
26,446
def format_metric(metric): for key, val in metric.items(): print(f'{key} - {val["score"]}') for k, v in val.items(): if 'score' not in k: print(f' {k} - {v}')
null
26,447
import cv2 import numpy as np from .utils import THICKNESS, COLOR_DEFAULT, COLOR_DICT, interp_arc def _draw_traffic_element(image, traffic_element): top_left = ( int(traffic_element['points'][0][0]), int(traffic_element['points'][0][1]), ) bottom_right = ( int(traffic_element['points...
null
26,448
import numpy as np def assign_attribute(annotation): topology_lcte = np.array(annotation['topology_lcte'], dtype=bool) for i in range(len(annotation['lane_centerline'])): annotation['lane_centerline'][i]['attributes'] = \ set([ts['attribute'] for j, ts in enumerate(annotation['traffic_eleme...
null
26,449
import numpy as np def assign_topology(annotation): topology_lcte = np.array(annotation['topology_lcte'], dtype=bool) annotation['topology'] = [] for i in range(topology_lcte.shape[0]): for j in range(topology_lcte.shape[1]): if topology_lcte[i][j]: annotation['topology'...
null
26,450
import cv2 import numpy as np from .utils import THICKNESS, COLOR_DEFAULT, COLOR_DICT, interp_arc BEV_SCALE = 10 BEV_RANGE = [-50, 50, -25, 25] def _draw_lane_centerline(image, lane_centerline, with_attribute): def _draw_vertex(image, lane_centerline): def draw_annotation_bev(annotation, with_attribute): image = n...
null
26,451
import numpy as np from scipy.interpolate import interp1d from ortools.graph import pywrapgraph The provided code snippet includes necessary dependencies for implementing the `resample_laneline_in_x` function. Write a Python function `def resample_laneline_in_x(input_lane, steps, out_vis=False)` to solve the following...
Interpolate y, z values at each anchor grid, including those beyond the range of input lnae x range :param input_lane: N x 2 or N x 3 ndarray, one row for a point (x, y, z-optional). It requires y values of input lane in ascending order :param steps: a vector of steps :param out_vis: whether to output visibility indica...
26,452
import numpy as np from scipy.interpolate import interp1d from ortools.graph import pywrapgraph The provided code snippet includes necessary dependencies for implementing the `SolveMinCostFlow` function. Write a Python function `def SolveMinCostFlow(adj_mat, cost_mat)` to solve the following problem: Solving an Assign...
Solving an Assignment Problem with MinCostFlow" :param adj_mat: adjacency matrix with binary values indicating possible matchings between two sets :param cost_mat: cost matrix recording the matching cost of every possible pair of items from two sets :return:
26,453
import numpy as np from tqdm import tqdm from .f_score import f1 from .distance import pairwise, chamfer_distance, frechet_distance, iou_distance from ..io import io from ..preprocessing import check_results from ..utils import TRAFFIC_ELEMENT_ATTRIBUTE THRESHOLDS_FRECHET = [1.0, 2.0, 3.0] THRESHOLDS_IOU = [0.75] def _...
r""" Evaluate the road structure cognition task. Parameters ---------- ground_truth : str / dict Dict of ground truth of path to pickle file storing the dict. predictions : str / dict Dict of predictions of path to pickle file storing the dict. Returns ------- dict A dict containing all defined metrics. Notes ----- One...
26,454
import numpy as np from iso3166 import countries from functools import reduce The provided code snippet includes necessary dependencies for implementing the `check_results` function. Write a Python function `def check_results(results : dict) -> None` to solve the following problem: r""" Check format of results. Parame...
r""" Check format of results. Parameters ---------- results : dcit Dict storing predicted results.
26,455
import numpy as np from tqdm import tqdm from ..io import io io = IO() The provided code snippet includes necessary dependencies for implementing the `collect` function. Write a Python function `def collect(root_path : str, data_dict : dict, collection : str, point_interval : int = 1) -> None` to solve the following ...
r""" Load meta data of data in data_dict, and store in a .pkl with split as file name. Parameters ---------- root_path : str data_dict : dict A dict contains ids of data to be preprocessed. collection : str Name of the collection. point_interval : int Interval for subsampling points of lane centerlines, not subsampling...
26,456
from __future__ import division import argparse import copy import os import time import warnings from os import path as osp import mmcv import torch import torch.distributed as dist from mmcv import Config, DictAction from mmcv.runner import get_dist_info, init_dist from mmdet import __version__ as mmdet_version from ...
null
26,457
import argparse from os import path as osp from tools.data_converter import indoor_converter as indoor from tools.data_converter import kitti_converter as kitti from tools.data_converter import lyft_converter as lyft_converter from tools.data_converter import nuscenes_converter as nuscenes_converter from tools.data_con...
Prepare data related to Kitti dataset. Related data consists of '.pkl' files recording basic infos, 2D annotations and groundtruth database. Args: root_path (str): Path of dataset root. info_prefix (str): The prefix of info filenames. version (str): Dataset version. out_dir (str): Output directory of the groundtruth da...
26,458
import argparse from os import path as osp from tools.data_converter import indoor_converter as indoor from tools.data_converter import kitti_converter as kitti from tools.data_converter import lyft_converter as lyft_converter from tools.data_converter import nuscenes_converter as nuscenes_converter from tools.data_con...
Prepare data related to nuScenes dataset. Related data consists of '.pkl' files recording basic infos, 2D annotations and groundtruth database. Args: root_path (str): Path of dataset root. info_prefix (str): The prefix of info filenames. version (str): Dataset version. dataset_name (str): The dataset class name. out_di...
26,459
import argparse from os import path as osp from tools.data_converter import indoor_converter as indoor from tools.data_converter import kitti_converter as kitti from tools.data_converter import lyft_converter as lyft_converter from tools.data_converter import nuscenes_converter as nuscenes_converter from tools.data_con...
Prepare data related to Lyft dataset. Related data consists of '.pkl' files recording basic infos. Although the ground truth database and 2D annotations are not used in Lyft, it can also be generated like nuScenes. Args: root_path (str): Path of dataset root. info_prefix (str): The prefix of info filenames. version (st...
26,460
import argparse from os import path as osp from tools.data_converter import indoor_converter as indoor from tools.data_converter import kitti_converter as kitti from tools.data_converter import lyft_converter as lyft_converter from tools.data_converter import nuscenes_converter as nuscenes_converter from tools.data_con...
Prepare the info file for scannet dataset. Args: root_path (str): Path of dataset root. info_prefix (str): The prefix of info filenames. out_dir (str): Output directory of the generated info file. workers (int): Number of threads to be used.
26,461
import argparse from os import path as osp from tools.data_converter import indoor_converter as indoor from tools.data_converter import kitti_converter as kitti from tools.data_converter import lyft_converter as lyft_converter from tools.data_converter import nuscenes_converter as nuscenes_converter from tools.data_con...
Prepare the info file for s3dis dataset. Args: root_path (str): Path of dataset root. info_prefix (str): The prefix of info filenames. out_dir (str): Output directory of the generated info file. workers (int): Number of threads to be used.
26,462
import argparse from os import path as osp from tools.data_converter import indoor_converter as indoor from tools.data_converter import kitti_converter as kitti from tools.data_converter import lyft_converter as lyft_converter from tools.data_converter import nuscenes_converter as nuscenes_converter from tools.data_con...
Prepare the info file for sunrgbd dataset. Args: root_path (str): Path of dataset root. info_prefix (str): The prefix of info filenames. out_dir (str): Output directory of the generated info file. workers (int): Number of threads to be used.
26,463
import argparse from os import path as osp from tools.data_converter import indoor_converter as indoor from tools.data_converter import kitti_converter as kitti from tools.data_converter import lyft_converter as lyft_converter from tools.data_converter import nuscenes_converter as nuscenes_converter from tools.data_con...
Prepare the info file for waymo dataset. Args: root_path (str): Path of dataset root. info_prefix (str): The prefix of info filenames. out_dir (str): Output directory of the generated info file. workers (int): Number of threads to be used. max_sweeps (int, optional): Number of input consecutive frames. Default: 5. Here...
26,464
import argparse import torch from mmcv import Config, DictAction from mmdet3d.models import build_model def parse_args(): parser = argparse.ArgumentParser(description='Train a detector') parser.add_argument('config', help='train config file path') parser.add_argument( '--shape', type=int, ...
null
26,465
import argparse import json from collections import defaultdict import numpy as np import seaborn as sns from matplotlib import pyplot as plt def cal_train_time(log_dicts, args): for i, log_dict in enumerate(log_dicts): print(f'{"-" * 5}Analyze train time of {args.json_logs[i]}{"-" * 5}') all_times...
null
26,466
import argparse import json from collections import defaultdict import numpy as np import seaborn as sns from matplotlib import pyplot as plt def plot_curve(log_dicts, args): if args.backend is not None: plt.switch_backend(args.backend) sns.set_style(args.style) # if legend is None, use {filename}_...
null
26,467
import argparse import json from collections import defaultdict import numpy as np import seaborn as sns from matplotlib import pyplot as plt def add_plot_parser(subparsers): parser_plt = subparsers.add_parser( 'plot_curve', help='parser for plotting curves') parser_plt.add_argument( 'json_logs'...
null
26,468
import argparse import json from collections import defaultdict import numpy as np import seaborn as sns from matplotlib import pyplot as plt def load_json_logs(json_logs): # load and convert json_logs to log_dict, key is epoch, value is a sub dict # keys of sub dict is different metrics, e.g. memory, bbox_mAP...
null
26,469
import argparse import time import torch from mmcv import Config from mmcv.parallel import MMDataParallel from mmcv.runner import load_checkpoint, wrap_fp16_model from mmdet3d.datasets import build_dataloader, build_dataset from mmdet3d.models import build_detector from tools.misc.fuse_conv_bn import fuse_module def p...
null
26,470
import argparse import tempfile import torch from mmcv import Config from mmcv.runner import load_state_dict from mmdet3d.models import build_detector def parse_args(): parser = argparse.ArgumentParser( description='MMDet3D upgrade model version(before v0.6.0) of VoteNet') parser.add_argument('checkpoi...
null
26,471
import argparse import tempfile import torch from mmcv import Config from mmcv.runner import load_state_dict from mmdet3d.models import build_detector The provided code snippet includes necessary dependencies for implementing the `parse_config` function. Write a Python function `def parse_config(config_strings)` to so...
Parse config from strings. Args: config_strings (string): strings of model config. Returns: Config: model config
26,472
import argparse import tempfile import torch from mmcv import Config from mmcv.runner import load_state_dict from mmdet3d.models import build_detector def parse_args(): parser = argparse.ArgumentParser( description='MMDet3D upgrade model version(before v0.6.0) of H3DNet') parser.add_argument('checkpoin...
null
26,473
import argparse import tempfile import torch from mmcv import Config from mmcv.runner import load_state_dict from mmdet3d.models import build_detector The provided code snippet includes necessary dependencies for implementing the `parse_config` function. Write a Python function `def parse_config(config_strings)` to so...
Parse config from strings. Args: config_strings (string): strings of model config. Returns: Config: model config
26,475
import argparse import subprocess import torch def parse_args(): parser = argparse.ArgumentParser( description='Process a checkpoint to be published') parser.add_argument('in_file', help='input checkpoint filename') parser.add_argument('out_file', help='output checkpoint filename') args = parse...
null
26,476
import argparse import subprocess import torch def process_checkpoint(in_file, out_file): checkpoint = torch.load(in_file, map_location='cpu') # remove optimizer for smaller file size if 'optimizer' in checkpoint: del checkpoint['optimizer'] # if it is necessary to remove some sensitive data in...
null
26,477
import argparse import base64 from os import path as osp import mmcv import numpy as np from nuimages import NuImages from nuimages.utils.utils import mask_decode, name_to_index_mapping def parse_args(): parser = argparse.ArgumentParser(description='Data converter arg parser') parser.add_argument( '--d...
null
26,478
import argparse import base64 from os import path as osp import mmcv import numpy as np from nuimages import NuImages from nuimages.utils.utils import mask_decode, name_to_index_mapping nus_categories = ('car', 'truck', 'trailer', 'bus', 'construction_vehicle', 'bicycle', 'motorcycle', 'pedestrian', '...
null
26,479
import pickle from os import path as osp import mmcv import numpy as np from mmcv import track_iter_progress from mmcv.ops import roi_align from pycocotools import mask as maskUtils from pycocotools.coco import COCO from mmdet3d.core.bbox import box_np_ops as box_np_ops from mmdet3d.datasets import build_dataset from m...
null
26,480
from collections import OrderedDict from concurrent import futures as futures from os import path as osp from pathlib import Path import mmcv import numpy as np from PIL import Image from skimage import io def get_kitti_info_path(idx, prefix, info_type='image_2', ...
null
26,481
from collections import OrderedDict from concurrent import futures as futures from os import path as osp from pathlib import Path import mmcv import numpy as np from PIL import Image from skimage import io def get_kitti_info_path(idx, prefix, info_type='image_2', ...
null
26,482
from collections import OrderedDict from concurrent import futures as futures from os import path as osp from pathlib import Path import mmcv import numpy as np from PIL import Image from skimage import io def get_image_index_str(img_idx, use_prefix_id=False): if use_prefix_id: return '{:07d}'.format(img_id...
null
26,483
from collections import OrderedDict from pathlib import Path import mmcv import numpy as np from nuscenes.utils.geometry_utils import view_points from mmdet3d.core.bbox import box_np_ops, points_cam2img from .kitti_data_utils import WaymoInfoGatherer, get_kitti_image_info from .nuscenes_converter import post_process_co...
convert kitti info v1 to v2 if possible. Args: info (dict): Info of the input kitti data. - image (dict): image info - calib (dict): calibration info - point_cloud (dict): point cloud info
26,484
from concurrent import futures as futures from os import path as osp import mmcv import numpy as np from scipy import io as sio The provided code snippet includes necessary dependencies for implementing the `random_sampling` function. Write a Python function `def random_sampling(points, num_points, replace=None)` to s...
Random sampling. Sampling point cloud to a certain number of points. Args: points (ndarray): Point cloud. num_points (int): The number of samples. replace (bool): Whether the sample is with or without replacement. Returns: points (ndarray): Point cloud after sampling.
26,485
import argparse import os import numpy as np def fix_lyft(root_folder='./data/lyft', version='v1.01'): # refer to https://www.kaggle.com/c/3d-object-detection-for-autonomous-vehicles/discussion/110000 # noqa lidar_path = 'lidar/host-a011_lidar1_1233090652702363606.bin' root_folder = os.path.join(root_fold...
null
26,486
import argparse import warnings from os import path as osp from pathlib import Path import mmcv import numpy as np from mmcv import Config, DictAction, mkdir_or_exist from mmdet3d.core.bbox import (Box3DMode, CameraInstance3DBoxes, Coord3DMode, DepthInstance3DBoxes, LiDARInstance3DBoxes) ...
null
26,487
import argparse import warnings from os import path as osp from pathlib import Path import mmcv import numpy as np from mmcv import Config, DictAction, mkdir_or_exist from mmdet3d.core.bbox import (Box3DMode, CameraInstance3DBoxes, Coord3DMode, DepthInstance3DBoxes, LiDARInstance3DBoxes) ...
Build data config for loading visualization data.
26,488
import argparse import warnings from os import path as osp from pathlib import Path import mmcv import numpy as np from mmcv import Config, DictAction, mkdir_or_exist from mmdet3d.core.bbox import (Box3DMode, CameraInstance3DBoxes, Coord3DMode, DepthInstance3DBoxes, LiDARInstance3DBoxes) ...
Visualize 3D point cloud and 3D bboxes.
26,489
import argparse import warnings from os import path as osp from pathlib import Path import mmcv import numpy as np from mmcv import Config, DictAction, mkdir_or_exist from mmdet3d.core.bbox import (Box3DMode, CameraInstance3DBoxes, Coord3DMode, DepthInstance3DBoxes, LiDARInstance3DBoxes) ...
Visualize 3D point cloud and segmentation mask.
26,490
import argparse import warnings from os import path as osp from pathlib import Path import mmcv import numpy as np from mmcv import Config, DictAction, mkdir_or_exist from mmdet3d.core.bbox import (Box3DMode, CameraInstance3DBoxes, Coord3DMode, DepthInstance3DBoxes, LiDARInstance3DBoxes) ...
Visualize 3D bboxes on 2D image by projection.
26,491
import argparse import mmcv from mmcv import Config from mmdet3d.datasets import build_dataset def parse_args(): parser = argparse.ArgumentParser( description='MMDet3D visualize the results') parser.add_argument('config', help='test config file path') parser.add_argument('--result', help='results f...
null
26,492
import argparse import torch from mmcv.runner import save_checkpoint from torch import nn as nn from mmdet3d.apis import init_model def fuse_conv_bn(conv, bn): """During inference, the functionary of batch norm layers is turned off but only the mean and var alone channels are used, which exposes the chance to ...
null