inputs
stringlengths
312
52k
targets
stringlengths
1
3.1k
block_type
stringclasses
11 values
scenario
stringclasses
7 values
<filename>tanuki_py/src/tanuki/validator.py<fim_prefix>""" Here are some snippets of code retrieved from other files in this repository that may help you: # tanuki_py/src/tanuki/trackers/dataset_worker.py def log_symbolic_patch(self, func_hash, example): """ Save the example to the patch dataset f...
for item in data: # For each item, validate and instantiate it instantiated_item = self.instantiate(item, item_type[0]) instantiated_items.add(instantiated_item) # If the instantiated item does not match the expected type, ...
FOR
prefix_suffix_full_complete_current_block_with_repo_rag_oracle
<filename>tanuki_py/src/tanuki/validator.py<fim_prefix>""" Here are some snippets of code retrieved from other files in this repository that may help you: # tanuki_py/src/tanuki/trackers/dataset_worker.py def log_symbolic_patch(self, func_hash, example): """ Save the example to the patch dataset f...
for i, item in enumerate(data): # For each item, validate and instantiate it instantiated_item = self.instantiate(item, item_types[i]) instantiated_items.append(instantiated_item) # If the instantiated item does not match t...
FOR
prefix_suffix_full_complete_current_block_with_repo_rag_oracle
<filename>tanuki_py/src/tanuki/validator.py<fim_prefix>""" Here are some snippets of code retrieved from other files in this repository that may help you: # tanuki_py/src/tanuki/trackers/dataset_worker.py def log_symbolic_patch(self, func_hash, example): """ Save the example to the patch dataset f...
for item in data: # For each item, validate and instantiate it try: instantiated_item = self.instantiate(item, item_type) except ValueError: raise TypeError( f"...
FOR
prefix_suffix_full_complete_current_block_with_repo_rag_oracle
<filename>tanuki_py/src/tanuki/validator.py<fim_prefix>""" Here are some snippets of code retrieved from other files in this repository that may help you: # tanuki_py/src/tanuki/register.py def get_class_definition(class_type): """Helper function to get class definition source if not a built-in ty...
for base in target_type.__orig_bases__: if get_args(base): return base, get_args(base)
FOR
prefix_suffix_full_complete_current_block_with_repo_rag_oracle
<filename>tanuki_py/src/tanuki/language_models/openai_api.py<fim_prefix>""" Here are some snippets of code retrieved from other files in this repository that may help you: # tanuki_py/src/tanuki/language_models/anyscale_api.py def generate(self, model, system_message, prompt, **kwargs): """ The ma...
while counter <= 5: try: openai_headers = { "Authorization": f"Bearer {self.api_key}", "Content-Type": "application/json", } response = requests.post( OPENAI_URL, headers=openai_headers, json=params, ...
WHILE
prefix_suffix_full_complete_current_block_with_repo_rag_oracle
<filename>UHGEval/uhgeval/dataset/truthfulqa.py<fim_prefix># @Author : YeZhaohui Wang # @Email : wyzh0912@126.com import csv import json import os import random from uhgeval.dataset.base import BaseDataset class TruthfunQAGeneration(BaseDataset): def __init__(self, path: str, shuffle: bool = False, seed: int =...
= []
STATEMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UHGEval/uhgeval/metric/common.py<fim_prefix># @Author : Shichao Song # @Email : song.shichao@outlook.com from typing import Callable import evaluate import jieba from loguru import logger from text2vec import Similarity def catch_all_exceptions(func): def wrapper(*args, **kwargs): try: ...
accuracy, precision, recall, f1
STATEMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UHGEval/uhgeval/metric/common.py<fim_prefix># @Author : Shichao Song # @Email : song.shichao@outlook.com from typing import Callable import evaluate import jieba from loguru import logger from text2vec import Similarity def catch_all_exceptions(func): def wrapper(*args, **kwargs): try: ...
= 2 * (precision * recall) / (precision + recall)
STATEMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UHGEval/uhgeval/metric/common.py<fim_prefix># @Author : Shichao Song # @Email : song.shichao@outlook.com from typing import Callable import evaluate import jieba from loguru import logger from text2vec import Similarity def catch_all_exceptions(func): def wrapper(*args, **kwargs): try: ...
null
STATEMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UHGEval/uhgeval/metric/common.py<fim_prefix># @Author : Shichao Song # @Email : song.shichao@outlook.com from typing import Callable import evaluate import jieba from loguru import logger from text2vec import Similarity def catch_all_exceptions(func): def wrapper(*args, **kwargs): try: ...
= sum(1 for a, b in zip(references, predictions) if a == 0 and b == 1)
STATEMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UHGEval/uhgeval/metric/common.py<fim_prefix># @Author : Shichao Song # @Email : song.shichao@outlook.com from typing import Callable import evaluate import jieba from loguru import logger from text2vec import Similarity def catch_all_exceptions(func): def wrapper(*args, **kwargs): try: ...
= sum(1 for a, b in zip(references, predictions) if a == b) / len(predictions) if len(predictions) > 0 else 0
STATEMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UHGEval/uhgeval/metric/common.py<fim_prefix># @Author : Shichao Song # @Email : song.shichao@outlook.com from typing import Callable import evaluate import jieba from loguru import logger from text2vec import Similarity def catch_all_exceptions(func): def wrapper(*args, **kwargs): try: ...
= sum(1 for a, b in zip(references, predictions) if a == 1 and b == 1)
STATEMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UHGEval/uhgeval/metric/common.py<fim_prefix># @Author : Shichao Song # @Email : song.shichao@outlook.com from typing import Callable import evaluate import jieba from loguru import logger from text2vec import Similarity def catch_all_exceptions(func): def wrapper(*args, **kwargs): try: ...
= true_positive / (true_positive + false_positive) if (true_positive + false_positive) > 0 else 0
STATEMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UHGEval/uhgeval/dataset/truthfulqa.py<fim_prefix># @Author : YeZhaohui Wang # @Email : wyzh0912@126.com import csv import json import os import random from uhgeval.dataset.base import BaseDataset class TruthfunQAGeneration(BaseDataset): def __init__(self, path: str, shuffle: bool = False, seed: int =...
self.data[:]
STATEMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UHGEval/uhgeval/metric/common.py<fim_prefix># @Author : Shichao Song # @Email : song.shichao@outlook.com from typing import Callable import evaluate import jieba from loguru import logger from text2vec import Similarity def catch_all_exceptions(func): def wrapper(*args, **kwargs): try: ...
result
STATEMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UHGEval/uhgeval/metric/common.py<fim_prefix># @Author : Shichao Song # @Email : song.shichao@outlook.com from typing import Callable import evaluate import jieba from loguru import logger from text2vec import Similarity def catch_all_exceptions(func): def wrapper(*args, **kwargs): try: ...
precision + recall == 0: f1 = 0 else: f1 = 2 * (precision * recall) / (precision + recall)
IF
prefix_suffix_full_complete_current_block_with_evidence
<filename>UHGEval/uhgeval/metric/common.py<fim_prefix># @Author : Shichao Song # @Email : song.shichao@outlook.com from typing import Callable import evaluate import jieba from loguru import logger from text2vec import Similarity def catch_all_exceptions(func): def wrapper(*args, **kwargs): try:<fim_s...
result = func(*args, **kwargs) return result
TRY
prefix_suffix_full_complete_current_block_with_evidence
<filename>UHGEval/uhgeval/metric/common.py<fim_prefix># @Author : Shichao Song # @Email : song.shichao@outlook.com from typing import Callable import evaluate import jieba from loguru import logger from text2vec import Similarity def catch_all_exceptions(func): def wrapper(*args, **kwargs): try: ...
Exception as e: logger.warning(repr(e))
CATCH
prefix_suffix_full_complete_current_block_with_evidence
<filename>UHGEval/uhgeval/metric/common.py<fim_prefix># @Author : Shichao Song # @Email : song.shichao@outlook.com from typing import Callable import evaluate import jieba from loguru import logger from text2vec import Similarity def catch_all_exceptions(func): def wrapper(*args, **kwargs): try: ...
Calculate accuracy, precision, recall, and F1 in a binary classification problem. Args: predictions (list[bool]): List of predicted values (0 or 1). references (list[bool]): List of true values (0 or 1). Returns: tuple: Accuracy, precision, recall, and F1 scores. """
BLOCK_COMMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/structures/image_list.py<fim_prefix># Copyright (c) Facebook, Inc. and its affiliates. from __future__ import division from typing import Any, List, Tuple import torch from torch import device from torch.nn import functional as F from detectron2.layers.wrappers import shapes_to_tensor cla...
Access the individual image in its original size. Args: idx: int or slice Returns: Tensor: an image of shape (H, W) or (C_1, ..., C_K, H, W) where K >= 1 """
BLOCK_COMMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/solver/build.py<fim_prefix># Copyright (c) Facebook, Inc. and its affiliates. import copy import itertools import logging from collections import defaultdict from enum import Enum from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Type, Union import torch from fvcore.comm...
Build a LR scheduler from config. """
BLOCK_COMMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/tracking/bbox_iou_tracker.py<fim_prefix>#!/usr/bin/env python3 # Copyright 2004-present Facebook. All Rights Reserved. import copy from typing import List import numpy as np import torch from detectron2.config import configurable from detectron2.structures import Boxes, Instances from detec...
For each untracked instance, assign a new id Args: instances: D2 Instances, for predictions of the current frame Return: D2 Instances with new ID assigned """
BLOCK_COMMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/structures/masks.py<fim_prefix># Copyright (c) Facebook, Inc. and its affiliates. import copy import itertools import numpy as np from typing import Any, Iterator, List, Union import pycocotools.mask as mask_util import torch from torch import device from detectron2.layers.roi_align import ...
Returns: Boxes: tight bounding boxes around bitmasks. If a mask is empty, it's bounding box will be all zero. """
BLOCK_COMMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/tracking/bbox_iou_tracker.py<fim_prefix>#!/usr/bin/env python3 # Copyright 2004-present Facebook. All Rights Reserved. import copy from typing import List import numpy as np import torch from detectron2.config import configurable from detectron2.structures import Boxes, Instances from detec...
Before each uodate call, reset fields first """
BLOCK_COMMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/structures/boxes.py<fim_prefix># Copyright (c) Facebook, Inc. and its affiliates. import math import numpy as np from enum import IntEnum, unique from typing import List, Tuple, Union import torch from torch import device _RawBoxType = Union[List[float], Tuple[float, ...], torch.Tensor, np....
Args: item: int, slice, or a BoolTensor Returns: Boxes: Create a new :class:`Boxes` by indexing. The following usage are allowed: 1. `new_boxes = boxes[3]`: return a `Boxes` which contains only one box. 2. `new_boxes = boxes[2:10]`: return a slice of b...
BLOCK_COMMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/structures/instances.py<fim_prefix># Copyright (c) Facebook, Inc. and its affiliates. import itertools from typing import Any, Dict, List, Tuple, Union import torch class Instances: """ This class represents a list of instances in an image. It stores the attributes of instances...
Args: image_size (height, width): the spatial size of the image. kwargs: fields to add to this `Instances`. """
BLOCK_COMMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/structures/masks.py<fim_prefix># Copyright (c) Facebook, Inc. and its affiliates. import copy import itertools import numpy as np from typing import Any, Iterator, List, Union import pycocotools.mask as mask_util import torch from torch import device from detectron2.layers.roi_align import ...
Arguments: polygons (list[list[np.ndarray]]): The first level of the list correspond to individual instances, the second level to all the polygons that compose the instance, and the third level to the polygon coordinates. The third lev...
BLOCK_COMMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/config/instantiate.py<fim_prefix># Copyright (c) Facebook, Inc. and its affiliates. import dataclasses import logging from collections import abc from typing import Any from detectron2.utils.registry import _convert_target_to_string, locate __all__ = ["dump_dataclass", "instantiate"] def...
Recursively instantiate objects defined in dictionaries by "_target_" and arguments. Args: cfg: a dict-like object with "_target_" that defines the caller, and other keys that define the arguments Returns: object instantiated by cfg """
BLOCK_COMMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/tracking/bbox_iou_tracker.py<fim_prefix>#!/usr/bin/env python3 # Copyright 2004-present Facebook. All Rights Reserved. import copy from typing import List import numpy as np import torch from detectron2.config import configurable from detectron2.structures import Boxes, Instances from detec...
If input instances don't have ID, ID_period, lost_frame_count fields, this method is used to initialize these fields. Args: instances: D2 Instances, for predictions of the current frame Return: D2 Instances with extra fields added """
BLOCK_COMMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/tracking/bbox_iou_tracker.py<fim_prefix>#!/usr/bin/env python3 # Copyright 2004-present Facebook. All Rights Reserved. import copy from typing import List import numpy as np import torch from detectron2.config import configurable from detectron2.structures import Boxes, Instances from detec...
+= len(instances)
STATEMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/external/davis2017-evaluation/davis2017/metrics.py<fim_prefix>import math import numpy as np import cv2 def db_eval_iou(annotation, segmentation, void_pixels=None): """ Compute region similarity as the Jaccard Index. Arguments: annotation (ndarray): binary annotation map. ...
= np.sum((segmentation & annotation) & np.logical_not(void_pixels), axis=(-2, -1))
STATEMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/layers/losses.py<fim_prefix>import math import torch def diou_loss( boxes1: torch.Tensor, boxes2: torch.Tensor, reduction: str = "none", eps: float = 1e-7, ) -> torch.Tensor: """ Distance Intersection over Union Loss (Zhaohui Zheng et. al) https://arxiv.org/abs/...
= (xkis2[mask] - xkis1[mask]) * (ykis2[mask] - ykis1[mask])
STATEMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/layers/losses.py<fim_prefix>import math import torch def diou_loss( boxes1: torch.Tensor, boxes2: torch.Tensor, reduction: str = "none", eps: float = 1e-7, ) -> torch.Tensor: """ Distance Intersection over Union Loss (Zhaohui Zheng et. al) https://arxiv.org/abs/...
= torch.min(x1, x1g)
STATEMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/tracking/hungarian_tracker.py<fim_prefix>#!/usr/bin/env python3 # Copyright 2004-present Facebook. All Rights Reserved. import copy import numpy as np import torch from detectron2.structures import Boxes, Instances from .base_tracker import BaseTracker from scipy.optimize import linear_sum...
= torch.IntTensor(untracked_instances.pred_classes)
STATEMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/checkpoint/c2_model_loading.py<fim_prefix># Copyright (c) Facebook, Inc. and its affiliates. import copy import logging import re from typing import Dict, List import torch from tabulate import tabulate def convert_basic_c2_names(original_keys): """ Apply some basic name conversion...
m2 = min(names), max(names)
STATEMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/structures/masks.py<fim_prefix># Copyright (c) Facebook, Inc. and its affiliates. import copy import itertools import numpy as np from typing import Any, Iterator, List, Union import pycocotools.mask as mask_util import torch from torch import device from detectron2.layers.roi_align import ...
mask_util.decode(rle).astype(np.bool)
STATEMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/structures/masks.py<fim_prefix># Copyright (c) Facebook, Inc. and its affiliates. import copy import itertools import numpy as np from typing import Any, Iterator, List, Union import pycocotools.mask as mask_util import torch from torch import device from detectron2.layers.roi_align import ...
2:] = maxxy
STATEMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/layers/losses.py<fim_prefix>import math import torch def diou_loss( boxes1: torch.Tensor, boxes2: torch.Tensor, reduction: str = "none", eps: float = 1e-7, ) -> torch.Tensor: """ Distance Intersection over Union Loss (Zhaohui Zheng et. al) https://arxiv.org/abs/...
= (x1g + x2g) / 2
STATEMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/tracking/hungarian_tracker.py<fim_prefix>#!/usr/bin/env python3 # Copyright 2004-present Facebook. All Rights Reserved. import copy import numpy as np import torch from detectron2.structures import Boxes, Instances from .base_tracker import BaseTracker from scipy.optimize import linear_sum...
null
STATEMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/tracking/hungarian_tracker.py<fim_prefix>#!/usr/bin/env python3 # Copyright 2004-present Facebook. All Rights Reserved. import copy import numpy as np import torch from detectron2.structures import Boxes, Instances from .base_tracker import BaseTracker from scipy.optimize import linear_sum...
not instances.has("lost_frame_count"): instances.set("lost_frame_count", [None] * len(instances))
IF
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/external/davis2017-evaluation/davis2017/metrics.py<fim_prefix>import math import numpy as np import cv2 def db_eval_iou(annotation, segmentation, void_pixels=None): """ Compute region similarity as the Jaccard Index. Arguments: annotation (ndarray): binary annotation map. ...
precision + recall == 0: F = 0 else: F = 2 * precision * recall / (precision + recall)
IF
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/config/config.py<fim_prefix># -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. import functools import inspect import logging from fvcore.common.config import CfgNode as _CfgNode from detectron2.utils.file_io import PathManager class CfgNode(_CfgNode): """ ...
support_var_arg: # forward all arguments to from_config, if from_config accepts them ret = from_config_func(*args, **kwargs) else: # forward supported arguments to from_config supported_arg_names = set(signature.parameters.keys()) extra_kwargs = {} for name in list(kwargs.k...
IF
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/tracking/bbox_iou_tracker.py<fim_prefix>#!/usr/bin/env python3 # Copyright 2004-present Facebook. All Rights Reserved. import copy from typing import List import numpy as np import torch from detectron2.config import configurable from detectron2.structures import Boxes, Instances from detec...
not instances.has("ID_period"): instances.set("ID_period", [None] * len(instances))
IF
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/config/instantiate.py<fim_prefix># Copyright (c) Facebook, Inc. and its affiliates. import dataclasses import logging from collections import abc from typing import Any from detectron2.utils.registry import _convert_target_to_string, locate __all__ = ["dump_dataclass", "instantiate"] def...
isinstance(cls, str): cls_name = cls cls = locate(cls_name) assert cls is not None, cls_name else: try: cls_name = cls.__module__ + "." + cls.__qualname__ except Exception: # target could be anything, so the above could...
IF
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/tracking/bbox_iou_tracker.py<fim_prefix>#!/usr/bin/env python3 # Copyright 2004-present Facebook. All Rights Reserved. import copy from typing import List import numpy as np import torch from detectron2.config import configurable from detectron2.structures import Boxes, Instances from detec...
not instances.has("ID"): instances.set("ID", [None] * len(instances))
IF
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/structures/instances.py<fim_prefix># Copyright (c) Facebook, Inc. and its affiliates. import itertools from typing import Any, Dict, List, Tuple, Union import torch class Instances: """ This class represents a list of instances in an image. It stores the attributes of instances...
name == "_fields" or name not in self._fields: raise AttributeError("Cannot find field '{}' in the given Instances!".format(name))
IF
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/tracking/bbox_iou_tracker.py<fim_prefix>#!/usr/bin/env python3 # Copyright 2004-present Facebook. All Rights Reserved. import copy from typing import List import numpy as np import torch from detectron2.config import configurable from detectron2.structures import Boxes, Instances from detec...
not instances.has("lost_frame_count"): instances.set("lost_frame_count", [None] * len(instances))
IF
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/tracking/bbox_iou_tracker.py<fim_prefix>#!/usr/bin/env python3 # Copyright 2004-present Facebook. All Rights Reserved. import copy from typing import List import numpy as np import torch from detectron2.config import configurable from detectron2.structures import Boxes, Instances from detec...
self._prev_instances is None: instances.ID = list(range(len(instances))) self._id_count += len(instances) instances.ID_period = [1] * len(instances) instances.lost_frame_count = [0] * len(instances)
IF
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/tracking/hungarian_tracker.py<fim_prefix>#!/usr/bin/env python3 # Copyright 2004-present Facebook. All Rights Reserved. import copy import numpy as np import torch from detectron2.structures import Boxes, Instances from .base_tracker import BaseTracker from scipy.optimize import linear_sum...
instances.has("pred_masks"): untracked_instances.pred_masks.append(prev_masks[idx].numpy().astype(np.uint8))
IF
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/structures/boxes.py<fim_prefix># Copyright (c) Facebook, Inc. and its affiliates. import math import numpy as np from enum import IntEnum, unique from typing import List, Tuple, Union import torch from torch import device _RawBoxType = Union[List[float], Tuple[float, ...], torch.Tensor, np....
[M]
LINE_COMMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/structures/boxes.py<fim_prefix># Copyright (c) Facebook, Inc. and its affiliates. import math import numpy as np from enum import IntEnum, unique from typing import List, Tuple, Union import torch from torch import device _RawBoxType = Union[List[float], Tuple[float, ...], torch.Tensor, np....
the inputs (and consequently confuses jit)
LINE_COMMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/checkpoint/c2_model_loading.py<fim_prefix># Copyright (c) Facebook, Inc. and its affiliates. import copy import logging import re from typing import Dict, List import torch from tabulate import tabulate def convert_basic_c2_names(original_keys): """ Apply some basic name conversion...
RPN hidden representation conv
LINE_COMMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/external/davis2017-evaluation/davis2017/metrics.py<fim_prefix>import math import numpy as np import cv2 def db_eval_iou(annotation, segmentation, void_pixels=None): """ Compute region similarity as the Jaccard Index. Arguments: annotation (ndarray): binary annotation map. ...
Get the pixel boundaries of both masks
LINE_COMMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/checkpoint/c2_model_loading.py<fim_prefix># Copyright (c) Facebook, Inc. and its affiliates. import copy import logging import re from typing import Dict, List import torch from tabulate import tabulate def convert_basic_c2_names(original_keys): """ Apply some basic name conversion...
ckpt_key string, if it matches
LINE_COMMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/tracking/iou_weighted_hungarian_bbox_iou_tracker.py<fim_prefix>#!/usr/bin/env python3 # Copyright 2004-present Facebook. All Rights Reserved. from typing import List import numpy as np from .base_tracker import TRACKER_HEADS_REGISTRY from .vanilla_hungarian_bbox_iou_tracker import Vanilla...
assign (-1 * IoU) for above threshold pairs, algorithms will minimize cost
LINE_COMMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/external/davis2017-evaluation/davis2017/metrics.py<fim_prefix>import math import numpy as np import cv2 def db_eval_iou(annotation, segmentation, void_pixels=None): """ Compute region similarity as the Jaccard Index. Arguments: annotation (ndarray): binary annotation map. ...
Intersection between all sets
LINE_COMMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/checkpoint/c2_model_loading.py<fim_prefix># Copyright (c) Facebook, Inc. and its affiliates. import copy import logging import re from typing import Dict, List import torch from tabulate import tabulate def convert_basic_c2_names(original_keys): """ Apply some basic name conversion...
remove the meaningless prediction weight for background class
LINE_COMMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/config/instantiate.py<fim_prefix># Copyright (c) Facebook, Inc. and its affiliates. import dataclasses import logging from collections import abc from typing import Any from detectron2.utils.registry import _convert_target_to_string, locate __all__ = ["dump_dataclass", "instantiate"] def...
return as-is if don't know what to do
LINE_COMMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/checkpoint/c2_model_loading.py<fim_prefix># Copyright (c) Facebook, Inc. and its affiliates. import copy import logging import re from typing import Dict, List import torch from tabulate import tabulate def convert_basic_c2_names(original_keys): """ Apply some basic name conversion...
--------------------------------------------------------------------------
LINE_COMMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/structures/masks.py<fim_prefix># Copyright (c) Facebook, Inc. and its affiliates. import copy import itertools import numpy as np from typing import Any, Iterator, List, Union import pycocotools.mask as mask_util import torch from torch import device from detectron2.layers.roi_align import ...
idx, polygons_per_instance in enumerate(self.polygons): minxy = torch.as_tensor([float("inf"), float("inf")], dtype=torch.float32) maxxy = torch.zeros(2, dtype=torch.float32) for polygon in polygons_per_instance: coords = torch.from_numpy(polygon).view(-1, 2).to(dtyp...
FOR
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/checkpoint/c2_model_loading.py<fim_prefix># Copyright (c) Facebook, Inc. and its affiliates. import copy import logging import re from typing import Dict, List import torch from tabulate import tabulate def convert_basic_c2_names(original_keys): """ Apply some basic name conversion...
idx_model, idx_ckpt in enumerate(idxs.tolist()): if idx_ckpt == -1: continue key_model = model_keys[idx_model] key_ckpt = ckpt_keys[idx_ckpt] value_ckpt = ckpt_state_dict[key_ckpt] shape_in_model = model_state_dict[key_model].shape if shape_in_model != value...
FOR
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/structures/masks.py<fim_prefix># Copyright (c) Facebook, Inc. and its affiliates. import copy import itertools import numpy as np from typing import Any, Iterator, List, Union import pycocotools.mask as mask_util import torch from torch import device from detectron2.layers.roi_align import ...
idx in range(self.tensor.shape[0]): x = torch.where(x_any[idx, :])[0] y = torch.where(y_any[idx, :])[0] if len(x) > 0 and len(y) > 0: boxes[idx, :] = torch.as_tensor( [x[0], y[0], x[-1] + 1, y[-1] + 1], dtype=torch.float32 )
FOR
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/tracking/utils.py<fim_prefix>#!/usr/bin/env python3 from detectron2.structures import Instances import numpy as np from typing import List def create_prediction_pairs( instances: Instances, prev_instances: Instances, iou_all: np.ndarray, threshold: float = 0.5, ) -> List: ...
j in range(len(prev_instances)): if iou_all[i, j] < threshold: continue bbox_pairs.append( { "idx": i, "prev_idx": j, "prev_id": prev_instances.ID[j], "IoU": iou_all[i, j], ...
FOR
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/tracking/bbox_iou_tracker.py<fim_prefix>#!/usr/bin/env python3 # Copyright 2004-present Facebook. All Rights Reserved. import copy from typing import List import numpy as np import torch from detectron2.config import configurable from detectron2.structures import Boxes, Instances from detec...
j in range(len(self._prev_instances)): bbox_pairs.append( { "idx": i, "prev_idx": j, "prev_id": self._prev_instances.ID[j], "IoU": iou_all[i, j], "prev_period": se...
FOR
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/tracking/bbox_iou_tracker.py<fim_prefix>#!/usr/bin/env python3 # Copyright 2004-present Facebook. All Rights Reserved. import copy from typing import List import numpy as np import torch from detectron2.config import configurable from detectron2.structures import Boxes, Instances from detec...
bbox_pair in bbox_pairs: idx = bbox_pair["idx"] prev_id = bbox_pair["prev_id"] if idx in self._matched_idx \ or prev_id in self._matched_ID \ or bbox_pair["IoU"] < self._track_iou_threshold: continue ...
FOR
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/tracking/hungarian_tracker.py<fim_prefix>#!/usr/bin/env python3 # Copyright 2004-present Facebook. All Rights Reserved. import copy import numpy as np import torch from detectron2.structures import Boxes, Instances from .base_tracker import BaseTracker from scipy.optimize import linear_sum...
i in range(matched_idx.size): instances.ID[matched_idx[i]] = self._prev_instances.ID[matched_prev_idx[i]] instances.ID_period[matched_idx[i]] = \ self._prev_instances.ID_period[matched_prev_idx[i]] + 1 instances.lost_frame_count[matched_idx[i]] = 0
FOR
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/tracking/bbox_iou_tracker.py<fim_prefix>#!/usr/bin/env python3 # Copyright 2004-present Facebook. All Rights Reserved. import copy from typing import List import numpy as np import torch from detectron2.config import configurable from detectron2.structures import Boxes, Instances from detec...
i in range(len(instances)): for j in range(len(self._prev_instances)): bbox_pairs.append( { "idx": i, "prev_idx": j, "prev_id": self._prev_instances.ID[j], "IoU": iou_all[i, j...
FOR
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/tracking/hungarian_tracker.py<fim_prefix>#!/usr/bin/env python3 # Copyright 2004-present Facebook. All Rights Reserved. import copy import numpy as np import torch from detectron2.structures import Boxes, Instances from .base_tracker import BaseTracker from scipy.optimize import linear_sum...
idx in untracked_idx: instances.ID[idx] = self._id_count self._id_count += 1 instances.ID_period[idx] = 1 instances.lost_frame_count[idx] = 0
FOR
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/external/davis2017-evaluation/davis2017/metrics.py<fim_prefix>import math import numpy as np import cv2 def db_eval_iou(annotation, segmentation, void_pixels=None): """ Compute region similarity as the Jaccard Index. Arguments: annotation (ndarray): binary annotation map. ...
y in range(h): if b[y, x]: j = 1 + math.floor((y - 1) + height / h) i = 1 + math.floor((x - 1) + width / h) bmap[j, i] = 1
FOR
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/config/instantiate.py<fim_prefix># Copyright (c) Facebook, Inc. and its affiliates. import dataclasses import logging from collections import abc from typing import Any from detectron2.utils.registry import _convert_target_to_string, locate __all__ = ["dump_dataclass", "instantiate"] def...
omegaconf import ListConfig
IMPORT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/layers/roi_align.py<fim_prefix># Copyright (c) Facebook, Inc. and its affiliates. from torch import nn from torchvision.ops import roi_align # NOTE: torchvision's RoIAlign has a different default aligned=False class ROIAlign(nn.Module): def __init__(self, output_size, spatial_scale, sa...
torchvision import __version__
IMPORT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/external/davis2017-evaluation/davis2017/metrics.py<fim_prefix>import math import numpy as np import cv2 def db_eval_iou(annotation, segmentation, void_pixels=None): """ Compute region similarity as the Jaccard Index. Arguments: annotation (ndarray): binary annotation map. ...
skimage.morphology import disk
IMPORT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/utils/registry.py<fim_prefix># Copyright (c) Facebook, Inc. and its affiliates. from typing import Any import pydoc from fvcore.common.registry import Registry # for backward compatibility. """ ``Registry`` and `locate` provide ways to map a string (typically found in config files) to cal...
hydra.utils import _locate
IMPORT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/config/config.py<fim_prefix># -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. import functools import inspect import logging from fvcore.common.config import CfgNode as _CfgNode from detectron2.utils.file_io import PathManager class CfgNode(_CfgNode): """ ...
.defaults import _C
IMPORT
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/checkpoint/c2_model_loading.py<fim_prefix># Copyright (c) Facebook, Inc. and its affiliates. import copy import logging import re from typing import Dict, List import torch from tabulate import tabulate def convert_basic_c2_names(original_keys): """ Apply some basic name conversion...
match(a, b): # Matched ckpt_key should be a complete (starts with '.') suffix. # For example, roi_heads.mesh_head.whatever_conv1 does not match conv1, # but matches whatever_conv1 or mesh_head.whatever_conv1. return a == b or a.endswith("." + b)
METHOD
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/structures/masks.py<fim_prefix># Copyright (c) Facebook, Inc. and its affiliates. import copy import itertools import numpy as np from typing import Any, Iterator, List, Union import pycocotools.mask as mask_util import torch from torch import device from detectron2.layers.roi_align import ...
process_polygons( polygons_per_instance: List[Union[torch.Tensor, np.ndarray]] ) -> List[np.ndarray]: if not isinstance(polygons_per_instance, list): raise ValueError( "Cannot create polygons: Expect a list of polygons per instance. " ...
METHOD
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/checkpoint/c2_model_loading.py<fim_prefix># Copyright (c) Facebook, Inc. and its affiliates. import copy import logging import re from typing import Dict, List import torch from tabulate import tabulate def convert_basic_c2_names(original_keys): """ Apply some basic name conversion...
fpn_map(name): """ Look for keys with the following patterns: 1) Starts with "fpn.inner." Example: "fpn.inner.res2.2.sum.lateral.weight" Meaning: These are lateral pathway convolutions 2) Starts with "fpn.res" Example: "fpn.res2.2.sum.weight" ...
METHOD
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/checkpoint/c2_model_loading.py<fim_prefix># Copyright (c) Facebook, Inc. and its affiliates. import copy import logging import re from typing import Dict, List import torch from tabulate import tabulate def convert_basic_c2_names(original_keys): """ Apply some basic name conversion...
_submodule_name(key): pos = key.rfind(".") if pos < 0: return None prefix = key[: pos + 1] return prefix
METHOD
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/config/config.py<fim_prefix># -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. import functools import inspect import logging from fvcore.common.config import CfgNode as _CfgNode from detectron2.utils.file_io import PathManager class CfgNode(_CfgNode): """ ...
wrapped(self, *args, **kwargs): try: from_config_func = type(self).from_config except AttributeError as e: raise AttributeError( "Class with @configurable must have a 'from_config' classmethod." ) from e if not insp...
METHOD
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/structures/masks.py<fim_prefix># Copyright (c) Facebook, Inc. and its affiliates. import copy import itertools import numpy as np from typing import Any, Iterator, List, Union import pycocotools.mask as mask_util import torch from torch import device from detectron2.layers.roi_align import ...
_make_array(t: Union[torch.Tensor, np.ndarray]) -> np.ndarray: # Use float64 for higher precision, because why not? # Always put polygons on CPU (self.to is a no-op) since they # are supposed to be small tensors. # May need to change this assumption if GPU placement beco...
METHOD
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/config/config.py<fim_prefix># -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. import functools import inspect import logging from fvcore.common.config import CfgNode as _CfgNode from detectron2.utils.file_io import PathManager class CfgNode(_CfgNode): """ ...
wrapped(*args, **kwargs): if _called_with_cfg(*args, **kwargs): explicit_args = _get_args_from_config(from_config, *args, **kwargs) return orig_func(**explicit_args) else: return orig_func(*args, **kwargs)
METHOD
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/utils/registry.py<fim_prefix># Copyright (c) Facebook, Inc. and its affiliates. from typing import Any import pydoc from fvcore.common.registry import Registry # for backward compatibility. """ ``Registry`` and `locate` provide ways to map a string (typically found in config files) to cal...
# from hydra.utils import get_method - will print many errors from hydra.utils import _locate
TRY
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/config/instantiate.py<fim_prefix># Copyright (c) Facebook, Inc. and its affiliates. import dataclasses import logging from collections import abc from typing import Any from detectron2.utils.registry import _convert_target_to_string, locate __all__ = ["dump_dataclass", "instantiate"] def...
return cls(**cfg)
TRY
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/config/instantiate.py<fim_prefix># Copyright (c) Facebook, Inc. and its affiliates. import dataclasses import logging from collections import abc from typing import Any from detectron2.utils.registry import _convert_target_to_string, locate __all__ = ["dump_dataclass", "instantiate"] def...
cls_name = cls.__module__ + "." + cls.__qualname__
TRY
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/config/config.py<fim_prefix># -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. import functools import inspect import logging from fvcore.common.config import CfgNode as _CfgNode from detectron2.utils.file_io import PathManager class CfgNode(_CfgNode): """ ...
from_config_func = type(self).from_config
TRY
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/config/instantiate.py<fim_prefix># Copyright (c) Facebook, Inc. and its affiliates. import dataclasses import logging from collections import abc from typing import Any from detectron2.utils.registry import _convert_target_to_string, locate __all__ = ["dump_dataclass", "instantiate"] def...
Exception: # target could be anything, so the above could fail cls_name = str(cls)
CATCH
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/utils/registry.py<fim_prefix># Copyright (c) Facebook, Inc. and its affiliates. from typing import Any import pydoc from fvcore.common.registry import Registry # for backward compatibility. """ ``Registry`` and `locate` provide ways to map a string (typically found in config files) to cal...
ImportError as e: raise ImportError(f"Cannot dynamically locate object {name}!") from e
CATCH
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/config/config.py<fim_prefix># -*- coding: utf-8 -*- # Copyright (c) Facebook, Inc. and its affiliates. import functools import inspect import logging from fvcore.common.config import CfgNode as _CfgNode from detectron2.utils.file_io import PathManager class CfgNode(_CfgNode): """ ...
AttributeError as e: raise AttributeError( "Class with @configurable must have a 'from_config' classmethod." ) from e
CATCH
prefix_suffix_full_complete_current_block_with_evidence
<filename>UniRef/detectron2/config/instantiate.py<fim_prefix># Copyright (c) Facebook, Inc. and its affiliates. import dataclasses import logging from collections import abc from typing import Any from detectron2.utils.registry import _convert_target_to_string, locate __all__ = ["dump_dataclass", "instantiate"] def...
TypeError: logger = logging.getLogger(__name__) logger.error(f"Error when instantiating {cls_name}!") raise
CATCH
prefix_suffix_full_complete_current_block_with_evidence
<filename>camp_zipnerf/internal/spin_math.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache....
the input according to the generalized bias and gain function. References: https://arxiv.org/abs/2010.09714 Args: x: The inputs array with values in [0, 1] to map. slope: The slope parameter of the curve which controls the slope of the curve at the threshold. threshold: The value at which `...
BLOCK_COMMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>camp_zipnerf/internal/stepfun.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.or...
the cumulative sum of w, assuming all weight vectors sum to 1. The output's size on the last dimension is one greater than that of the input, because we're computing the integral corresponding to the endpoints of a step function, not the integral of the interior/bin values. Args: w: Tensor, which will be...
BLOCK_COMMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>camp_zipnerf/internal/render.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org...
intervals along a conical frustum into means and variances."""
BLOCK_COMMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>camp_zipnerf/internal/math.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/l...
with clipped inputs."""
BLOCK_COMMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>camp_zipnerf/internal/linspline.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache....
a linear spline into a piecewise quadratic spline."""
BLOCK_COMMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>camp_zipnerf/internal/ref_utils.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache....
spherical harmonic coefficients."""
BLOCK_COMMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>camp_zipnerf/internal/math.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/l...
using the gradient and clipped inputs."""
BLOCK_COMMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>camp_zipnerf/internal/render.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org...
a cylinder as a Gaussian distribution (mean+cov). Assumes the ray is originating from the origin, and radius is the radius. Does not renormalize `d`. Args: d: jnp.float32 3-vector, the axis of the cylinder t0: float, the starting distance of the cylinder. t1: float, the ending distance of the cylin...
BLOCK_COMMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>camp_zipnerf/internal/coord.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/...
the mean of sin(x), x ~ N(mean, var)."""
BLOCK_COMMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>camp_zipnerf/internal/math.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/l...
`x` from below to be positive."""
BLOCK_COMMENT
prefix_suffix_full_complete_current_block_with_evidence
<filename>camp_zipnerf/internal/stepfun.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.or...
deterministic_center: pad = 1 / (2 * num_samples) u = jnp.linspace(pad, 1.0 - pad - eps, num_samples) else: u = jnp.linspace(0, 1.0 - eps, num_samples)
IF
prefix_suffix_full_complete_current_block_with_evidence