repo stringlengths 1 99 | file stringlengths 13 215 | code stringlengths 12 59.2M | file_length int64 12 59.2M | avg_line_length float64 3.82 1.48M | max_line_length int64 12 2.51M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/scene_graph_benchmark/relation_head/neural_motif/word_vectors.py | # Copyright (c) 2021 Microsoft Corporation. Licensed under the MIT license.
"""
Adapted from PyTorch's text library.
"""
import array
import os
import zipfile
import six
import torch
from six.moves.urllib.request import urlretrieve
from tqdm import tqdm
import sys
# tested, 7/24/2019 chuw
def obj_edge_vectors(nam... | 5,665 | 33.339394 | 96 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/scene_graph_benchmark/relation_head/reldn/reldn.py | # Copyright (c) 2021 Microsoft Corporation. Licensed under the MIT license.
import os.path as op
import numpy as np
import torch
import torch.nn as nn
from ..roi_relation_feature_extractors import make_roi_relation_feature_extractor
from ..roi_relation_predictors import make_roi_relation_predictor
from ..sparse_target... | 6,680 | 43.54 | 129 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/scene_graph_benchmark/relation_head/reldn/spatial.py | # Copyright (c) 2021 Microsoft Corporation. Licensed under the MIT license.
import torch
import torch.nn as nn
import numpy as np
def boxes_union(boxes1, boxes2):
assert boxes1.shape == boxes2.shape
xmin = np.minimum(boxes1[:, 0], boxes2[:, 0])
ymin = np.minimum(boxes1[:, 1], boxes2[:, 1])
xmax = np.... | 4,004 | 41.606383 | 142 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/scene_graph_benchmark/relation_head/msdn/msdn_base.py | # Copyright (c) 2021 Microsoft Corporation. Licensed under the MIT license.
# Reimplemtened by Jianwei Yang (jianwyan@microsoft.com)
# Adapted from https://github.com/jwyang/graph-rcnn.pytorch (Jianwei Yang) and https://github.com/yikang-li/MSDN (Yikang Li)
import numpy as np
import torch
import torch.nn as nn
import ... | 5,963 | 42.852941 | 124 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/scene_graph_benchmark/relation_head/msdn/msdn.py | # Copyright (c) 2021 Microsoft Corporation. Licensed under the MIT license.
# Reimplemtened by Jianwei Yang (jianwyan@microsoft.com)
# Adapted from https://github.com/jwyang/graph-rcnn.pytorch (Jianwei Yang) and https://github.com/yikang-li/MSDN (Yikang Li)
"""
MSDN for scene graph generation
"""
import numpy as np
i... | 5,267 | 47.330275 | 129 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/scene_graph_benchmark/relation_head/relpn/utils.py | # Copyright (c) 2021 Microsoft Corporation. Licensed under the MIT license.
# Reimplemtened by Jianwei Yang (jianwyan@microsoft.com)
# Adapted from https://github.com/jwyang/graph-rcnn.pytorch (Jianwei Yang)
import torch
def box_pos_encoder(bboxes, width, height):
"""
bounding box encoding
"""
bboxes... | 748 | 34.666667 | 105 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/scene_graph_benchmark/relation_head/relpn/relpn.py | # Copyright (c) 2021 Microsoft Corporation. Licensed under the MIT license.
# Reimplemtened by Jianwei Yang (jianwyan@microsoft.com)
# Adapted from https://github.com/jwyang/graph-rcnn.pytorch (Jianwei Yang)
import torch
import torch.nn as nn
import torch.nn.functional as F
from maskrcnn_benchmark.modeling.box_coder ... | 13,289 | 43.006623 | 136 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/scene_graph_benchmark/relation_head/relpn/relationshipness.py | # Copyright (c) 2021 Microsoft Corporation. Licensed under the MIT license.
# Reimplemtened by Jianwei Yang (jianwyan@microsoft.com)
# Adapted from https://github.com/jwyang/graph-rcnn.pytorch (Jianwei Yang)
import torch
import torch.nn as nn
from .utils import box_pos_encoder
class Relationshipness(nn.Module):
... | 1,754 | 30.909091 | 76 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/tools/test_net.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Set up custom environment before nearly anything else is imported
# NOTE: this should be the first import (no not reorder)
from maskrcnn_benchmark.utils.env import setup_environment # noqa F401 isort:skip
import argparse
import os
import torch... | 4,197 | 36.81982 | 114 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/tools/test_sg_net.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2021 Microsoft Corporation. Licensed under the MIT license.
# Set up custom environment before nearly anything else is imported
# NOTE: this should be the first import (no not reorder)
from maskrcnn_benchmark.utils.env import setup... | 8,094 | 39.678392 | 114 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/tools/train_sg_net.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2021 Microsoft Corporation. Licensed under the MIT license.
r"""
Basic training script for PyTorch
"""
# Set up custom environment before nearly anything else is imported
# NOTE: this should be the first import (no not reorder)
fr... | 7,596 | 32.615044 | 111 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/tools/train_net.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
r"""
Basic training script for PyTorch
"""
# Set up custom environment before nearly anything else is imported
# NOTE: this should be the first import (no not reorder)
from maskrcnn_benchmark.utils.env import setup_environment # noqa F401 isort:s... | 6,564 | 31.5 | 111 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/tools/demo/detect_utils.py | # Copyright (c) 2021 Microsoft Corporation. Licensed under the MIT license.
import cv2
import torch
from PIL import Image
from scene_graph_benchmark.scene_parser import SceneParser
from scene_graph_benchmark.AttrRCNN import AttrRCNN
def cv2Img_to_Image(input_img):
cv2_img = input_img.copy()
img = cv2.cvtCol... | 3,233 | 37.963855 | 111 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/solver/lr_scheduler.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from bisect import bisect_right
import torch
# FIXME ideally this would be achieved with a CombinedLRScheduler,
# separating MultiStepLR with WarmupLR
# but the current LRScheduler design doesn't allow it
class WarmupMultiStepLR(torch.optim.lr_s... | 1,817 | 33.301887 | 80 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/solver/build.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import itertools
import torch
from .lr_scheduler import WarmupMultiStepLR
def make_optimizer(cfg, model):
params = []
for key, value in model.named_parameters():
if not value.requires_grad:
continue
lr = cfg.S... | 3,247 | 34.304348 | 87 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/layers/nms.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from maskrcnn_benchmark import _C
try:
import torchvision
from torchvision.ops import nms
except:
nms = _C.nms
# nms.__doc__ = """
# This function performs Non-maximum suppresion"""
| 269 | 19.769231 | 71 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/layers/batch_norm.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from torch import nn
import torch.distributed as dist
import maskrcnn_benchmark.utils.comm as comm
from torch.autograd.function import Function
class FrozenBatchNorm2d(nn.Module):
"""
BatchNorm2d where the batch statistics an... | 4,925 | 41.102564 | 99 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/layers/roi_pool.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from torch import nn
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from torch.nn.modules.utils import _pair
from maskrcnn_benchmark import _C
class _ROIPool(Function):
@staticmethod
... | 1,855 | 28 | 74 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/layers/roi_align.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from torch import nn
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from torch.nn.modules.utils import _pair
from maskrcnn_benchmark import _C
class _ROIAlign(Function):
@staticmethod
... | 2,189 | 30.285714 | 85 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/layers/smooth_l1_loss.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2021 Microsoft Corporation. Licensed under the MIT license.
import torch
# TODO maybe push this to nn?
def smooth_l1_loss(input, target, beta=1. / 9, size_average=True):
"""
very similar to the smooth_l1_loss from pytorch... | 681 | 31.47619 | 94 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/layers/sigmoid_focal_loss.py | import torch
from torch import nn
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from maskrcnn_benchmark import _C
# TODO: Use JIT to replace CUDA implementation in the future.
class _SigmoidFocalLoss(Function):
@staticmethod
def forward(ctx, logits, targets, gamma... | 2,269 | 29.675676 | 118 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/layers/_utils.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import glob
import os.path
import torch
try:
from torch.utils.cpp_extension import load as load_ext
from torch.utils.cpp_extension import CUDA_HOME
except ImportError:
raise ImportError("The cpp layer extensions requires PyTorch 0.4 o... | 1,165 | 28.15 | 80 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/layers/misc.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""
helper class that supports empty tensors on some nn functions.
Ideally, add support directly in PyTorch to empty tensors in
those functions.
This can be removed once https://github.com/pytorch/pytorch/issues/12013
is implemented
"""
import m... | 6,661 | 31.656863 | 88 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/layers/__init__.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from .batch_norm import FrozenBatchNorm2d
from .misc import Conv2d
from .misc import DFConv2d
from .misc import ConvTranspose2d
from .misc import BatchNorm2d
from .misc import interpolate
from .nms import nms
from .roi_align import RO... | 1,327 | 26.666667 | 105 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/layers/dcn/deform_conv_func.py | import torch
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from torch.nn.modules.utils import _pair
from maskrcnn_benchmark import _C
class DeformConvFunction(Function):
@staticmethod
def forward(
ctx,
input,
offset,
weight,
... | 8,309 | 30.596958 | 83 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/layers/dcn/deform_pool_func.py | import torch
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from maskrcnn_benchmark import _C
class DeformRoIPoolingFunction(Function):
@staticmethod
def forward(
ctx,
data,
rois,
offset,
spatial_scale,
out_size,
... | 2,595 | 26.041667 | 99 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/layers/dcn/deform_pool_module.py | from torch import nn
from .deform_pool_func import deform_roi_pooling
class DeformRoIPooling(nn.Module):
def __init__(self,
spatial_scale,
out_size,
out_channels,
no_trans,
group_size=1,
part_size=None,
... | 6,307 | 40.774834 | 79 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/layers/dcn/deform_conv_module.py | import math
import torch
import torch.nn as nn
from torch.nn.modules.utils import _pair
from .deform_conv_func import deform_conv, modulated_deform_conv
class DeformConv(nn.Module):
def __init__(
self,
in_channels,
out_channels,
kernel_size,
stride=1,
padding=0,
... | 5,802 | 31.601124 | 78 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/engine/inference.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2021 Microsoft Corporation. Licensed under the MIT license.
import imp
import logging
import time
import os
import json
import base64
import torch
from tqdm import tqdm
from maskrcnn_benchmark.data.datasets.evaluation import eval... | 13,932 | 42.404984 | 127 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/engine/bbox_aug.py | import torch
import torchvision.transforms as TT
from maskrcnn_benchmark.config import cfg
from maskrcnn_benchmark.data import transforms as T
from maskrcnn_benchmark.structures.image_list import to_image_list
from maskrcnn_benchmark.structures.bounding_box import BoxList
from maskrcnn_benchmark.modeling.roi_heads.box... | 4,440 | 36.319328 | 98 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/engine/trainer.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2021 Microsoft Corporation. Licensed under the MIT license.
import datetime
import logging
import os
import time
import torch
import torch.distributed as dist
from tqdm import tqdm
from maskrcnn_benchmark.data import make_data_lo... | 7,672 | 36.247573 | 146 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/utils/c2_model_loading.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2021 Microsoft Corporation. Licensed under the MIT license.
import logging
import pickle
from collections import OrderedDict
import torch
from maskrcnn_benchmark.utils.model_serialization import load_state_dict
from maskrcnn_benc... | 8,449 | 39.430622 | 129 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/utils/metric_logger.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from collections import defaultdict
from collections import deque
import torch
class SmoothedValue(object):
"""Track a series of values and provide access to smoothed values over a
window or the global series average.
"""
def __... | 1,862 | 26.80597 | 82 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/utils/checkpoint.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import logging
import os
import torch
from maskrcnn_benchmark.utils.model_serialization import load_state_dict
from maskrcnn_benchmark.utils.c2_model_loading import load_c2_format
from maskrcnn_benchmark.utils.imports import import_file
from mask... | 4,840 | 33.578571 | 87 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/utils/comm.py | # Copyright (c) 2021 Microsoft Corporation. Licensed under the MIT license.
"""
This file contains primitives for multi-gpu communication.
This is useful when doing distributed training.
"""
import pickle
import time
import torch
import torch.distributed as dist
def get_world_size():
if not dist.is_available()... | 5,194 | 29.203488 | 84 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/utils/model_zoo.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import os
import sys
try:
from torch.hub import _download_url_to_file
from torch.hub import urlparse
from torch.hub import HASH_REGEX
except ImportError:
from torch.utils.model_zoo import _download_url_to_file
from torch.utils.... | 3,045 | 48.129032 | 135 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/utils/collect_env.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import PIL
from torch.utils.collect_env import get_pretty_env_info
def get_pil_version():
return "\n Pillow ({})".format(PIL.__version__)
def collect_env_info():
env_str = get_pretty_env_info()
env_str += get_pil_version()
... | 338 | 21.6 | 71 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/utils/model_serialization.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from collections import OrderedDict
import logging
import math
import torch
from maskrcnn_benchmark.utils.imports import import_file
def resize_pos_embed_1d(posemb, shape_new):
# Rescale the grid of position embeddings when loading from sta... | 6,667 | 45.957746 | 132 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/utils/amp.py | from contextlib import contextmanager
@contextmanager
def nullcontext(enter_result=None, **kwargs):
yield enter_result
try:
from torch.cuda.amp import autocast, GradScaler, custom_fwd, custom_bwd
except:
print('[Warning] Library for automatic mixed precision is not found, AMP is disabled!!')
GradScale... | 421 | 27.133333 | 92 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/utils/miscellaneous.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2021 Microsoft Corporation. Licensed under the MIT license.
import errno
import json
import yaml
import shutil
import logging
import os
import re
import numpy as np
import torch
import random
from .comm import is_main_process
def... | 4,821 | 28.582822 | 116 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/utils/imports.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
if torch._six.PY3:
import importlib
import importlib.util
import sys
# from https://stackoverflow.com/questions/67631/how-to-import-a-module-given-the-full-path?utm_medium=organic&utm_source=google_rich_qa&utm_campai... | 843 | 34.166667 | 168 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/data/build.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2021 Microsoft Corporation. Licensed under the MIT license.
import bisect
import copy
import logging
import torch.utils.data
from maskrcnn_benchmark.utils.comm import get_world_size
from maskrcnn_benchmark.utils.imports import imp... | 7,865 | 38.928934 | 143 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/data/datasets/voc.py | import os
import torch
import torch.utils.data
from PIL import Image
import sys
if sys.version_info[0] == 2:
import xml.etree.cElementTree as ET
else:
import xml.etree.ElementTree as ET
from maskrcnn_benchmark.structures.bounding_box import BoxList
class PascalVOCDataset(torch.utils.data.Dataset):
CL... | 4,168 | 29.654412 | 118 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/data/datasets/concat_dataset.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import bisect
from torch.utils.data.dataset import ConcatDataset as _ConcatDataset
class ConcatDataset(_ConcatDataset):
"""
Same as torch.utils.data.dataset.ConcatDataset, but exposes an extra
method for querying the sizes of the ima... | 766 | 30.958333 | 72 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/data/datasets/cityscapes.py | import os
import glob
import json
from PIL import Image
import numpy as np
import torch
import torchvision
from maskrcnn_benchmark.structures.bounding_box import BoxList
from maskrcnn_benchmark.structures.segmentation_mask import SegmentationMask
from .abstract import AbstractDataset
from cityscapesscripts.helpers... | 7,644 | 31.257384 | 85 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/data/datasets/vg_tsv.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2021 Microsoft Corporation. Licensed under the MIT license.
import os.path as op
import numpy as np
import torch
from .relation_tsv import RelationTSVDataset
from .evaluation.sg.box import bbox_overlaps
from .utils.label_loader i... | 4,665 | 38.210084 | 106 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/data/datasets/abstract.py | import torch
class AbstractDataset(torch.utils.data.Dataset):
"""
Serves as a common interface to reduce boilerplate and help dataset
customization
A generic Dataset for the maskrcnn_benchmark must have the following
non-trivial fields / methods implemented:
CLASSES - list/tuple:
... | 2,309 | 32.478261 | 80 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/data/datasets/relation_tsv.py | # Copyright (c) 2021 Microsoft Corporation. Licensed under the MIT license.
import json
import torch
import math
import numpy as np
from maskrcnn_benchmark.structures.tsv_file import TSVFile
from .tsv_dataset import TSVYamlDataset
from .utils.load_files import find_file_path_in_yaml
from .utils.label_loader import La... | 11,106 | 49.486364 | 205 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/data/datasets/coco.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
import torchvision
from maskrcnn_benchmark.structures.bounding_box import BoxList
from maskrcnn_benchmark.structures.segmentation_mask import SegmentationMask
from maskrcnn_benchmark.structures.keypoint import PersonKeypoints
min_ke... | 3,783 | 35.038095 | 85 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/data/datasets/evaluation/utils.py | import torch
from maskrcnn_benchmark.structures.boxlist_ops import boxlist_iou
# inspired from Detectron
def evaluate_box_proposals(
predictions, dataset, thresholds=None, area="all", limit=None
):
"""Evaluate detection proposal recall metrics. This function is a much
faster alternative to the official CO... | 4,308 | 34.908333 | 85 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/data/datasets/evaluation/vg/vg_eval.py | # A modification version from chainercv repository.
# (See https://github.com/chainer/chainercv/blob/master/chainercv/evaluations/eval_detection_voc.py)
from __future__ import division
import os
import numpy as np
import torch
from maskrcnn_benchmark.structures.bounding_box import BoxList
from maskrcnn_benchmark.data.... | 15,499 | 38.540816 | 121 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/data/datasets/evaluation/sg/box.py | # Copyright (c) 2021 Microsoft Corporation. Licensed under the MIT license.
import numpy as np
import torch
def bbox_overlaps(anchors, gt_boxes):
"""
anchors: (N, 4) ndarray of float
gt_boxes: (K, 4) ndarray of float
overlaps: (N, K) ndarray of overlap between boxes and query_boxes
"""
N = an... | 1,113 | 29.944444 | 76 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/data/datasets/evaluation/sg/evaluator.py | # Copyright (c) 2021 Microsoft Corporation. Licensed under the MIT license.
# Adapted from https://github.com/danfeiX/scene-graph-TF-release (Danfei Xu) and https://github.com/rowanz/neural-motifs (Rowan Zellers).
import torch
import numpy as np
from functools import reduce
from .box import bbox_overlaps
MODES = ('sg... | 13,531 | 40.894737 | 137 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/data/datasets/evaluation/sg/sg_tsv_eval.py | # Copyright (c) 2021 Microsoft Corporation. Licensed under the MIT license.
import os
import json
from collections import defaultdict
import base64
import numpy as np
import torch
from maskrcnn_benchmark.structures.tsv_file_ops import tsv_reader
from .evaluator import BasicSceneGraphEvaluator
from .box import bbox_ov... | 16,087 | 39.22 | 365 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/data/datasets/evaluation/coco/abs_to_coco.py | # COCO style evaluation for custom datasets derived from AbstractDataset
# Warning! area is computed using binary maps, therefore results may differ
# because of the precomputed COCO areas
# by botcs@github
import numpy as np
import torch
import pycocotools.mask as mask_util
from maskrcnn_benchmark.data.datasets.abst... | 6,795 | 33.150754 | 81 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/data/datasets/evaluation/coco/coco_eval.py | import logging
import tempfile
import os
import torch
from collections import OrderedDict
from tqdm import tqdm
from maskrcnn_benchmark.modeling.roi_heads.mask_head.inference import Masker
from maskrcnn_benchmark.structures.bounding_box import BoxList
from maskrcnn_benchmark.structures.boxlist_ops import boxlist_iou
... | 14,055 | 34.405542 | 88 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/data/datasets/evaluation/cityscapes/eval_instances.py | #!/usr/bin/python
#
# The evaluation script for instance-level semantic labeling.
# We use this script to evaluate your approach on the test set.
# You can use the script to evaluate on the validation set.
#
# Please check the description of the "getPrediction" method below
# and set the required environment variables ... | 37,178 | 39.90099 | 126 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/data/datasets/evaluation/cityscapes/cityscapes_eval.py | import logging
import tempfile
import os
import torch
from collections import OrderedDict
from tqdm import tqdm
from copy import deepcopy
import torch
import numpy as np
from maskrcnn_benchmark.modeling.roi_heads.mask_head.inference import Masker
from maskrcnn_benchmark.structures.bounding_box import BoxList
from mas... | 3,502 | 32.682692 | 81 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/data/datasets/utils/label_loader.py | # Copyright (c) 2021 Microsoft Corporation. Licensed under the MIT license.
import torch
import numpy as np
import base64
import collections
from maskrcnn_benchmark.structures.bounding_box import BoxList
class LabelLoader(object):
def __init__(self, labelmap, extra_fields=(), filter_duplicate_relations=False, i... | 5,115 | 43.103448 | 119 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/data/samplers/grouped_batch_sampler.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import itertools
import torch
from torch.utils.data.sampler import BatchSampler
from torch.utils.data.sampler import Sampler
class GroupedBatchSampler(BatchSampler):
"""
Wraps another sampler to yield a mini-batch of indices.
It enfo... | 4,845 | 40.775862 | 88 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/data/samplers/iteration_based_batch_sampler.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from torch.utils.data.sampler import BatchSampler
class IterationBasedBatchSampler(BatchSampler):
"""
Wraps a BatchSampler, resampling from it until
a specified number of iterations have been sampled
"""
def __init__(self, ba... | 1,164 | 35.40625 | 71 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/data/samplers/distributed.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Code is copy-pasted exactly as in torch.utils.data.distributed.
# FIXME remove this once c10d fixes the bug it has
import math
import torch
import torch.distributed as dist
from torch.utils.data.sampler import Sampler
class DistributedSampler(S... | 2,569 | 37.358209 | 86 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/data/transforms/transforms.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2021 Microsoft Corporation. Licensed under the MIT license.
import random
import torch
import torchvision
from torchvision.transforms import functional as F
class Compose(object):
def __init__(self, transforms):
self... | 3,566 | 28 | 83 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/modeling/matcher.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2021 Microsoft Corporation. Licensed under the MIT license.
import torch
class Matcher(object):
"""
This class assigns to each predicted "element" (e.g., a box) a ground-truth
element. Each predicted element will have... | 5,660 | 45.401639 | 88 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/modeling/make_layers.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""
Miscellaneous utility functions
"""
import torch
from torch import nn
from torch.nn import functional as F
from maskrcnn_benchmark.config import cfg
from maskrcnn_benchmark.layers import Conv2d
from maskrcnn_benchmark.modeling.poolers import P... | 3,557 | 27.926829 | 78 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/modeling/utils.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""
Miscellaneous utility functions
"""
import torch
def cat(tensors, dim=0):
"""
Efficient version of torch.cat that avoids a copy if there is only a single element in a list
"""
assert isinstance(tensors, (list, tuple))
if ... | 400 | 22.588235 | 97 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/modeling/poolers.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
import torch.nn.functional as F
from torch import nn
from maskrcnn_benchmark.layers import ROIAlign
from .utils import cat
class LevelMapper(object):
"""Determine which FPN level each RoI in a set of RoIs should map to based
... | 4,577 | 33.164179 | 90 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/modeling/balanced_positive_negative_sampler.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
class BalancedPositiveNegativeSampler(object):
"""
This class samples batches, ensuring that they contain a fixed proportion of positives
"""
def __init__(self, batch_size_per_image, positive_fraction):
"""
... | 2,748 | 38.84058 | 92 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/modeling/box_coder.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import math
import torch
class BoxCoder(object):
"""
This class encodes and decodes a set of bounding boxes into
the representation used for training the regressors.
"""
def __init__(self, weights, bbox_xform_clip=math.log(1... | 3,367 | 34.083333 | 86 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/modeling/backbone/msvit.py | import math
from functools import partial
import logging
import torch
from torch import nn
from timm.models.layers import DropPath, trunc_normal_, to_2tuple
from .longformer2d import Long2DSCSelfAttention
class Mlp(nn.Module):
def __init__(self, in_features, hidden_features=None, out_features=None,
... | 26,078 | 38.633739 | 126 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/modeling/backbone/resnet.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2021 Microsoft Corporation. Licensed under the MIT license.
"""
Variant of the resnet module that takes cfg as an argument.
Example usage. Strings may be specified in the config file.
model = ResNet(
"StemWithFixedBatch... | 14,531 | 30.591304 | 85 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/modeling/backbone/slidingchunk_2d.py | # Copyright (c) 2021 Microsoft Corporation. Licensed under the MIT license.
# Written by Pengchuan Zhang, penzhan@microsoft.com
from functools import lru_cache
import torch
from torch import einsum
from torch.cuda.amp import autocast
class SlidingChunk2D(torch.autograd.Function):
"""
Class to encapsulate for ... | 15,056 | 40.027248 | 103 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/modeling/backbone/fbnet_builder.py | """
FBNet model builder
"""
from __future__ import absolute_import, division, print_function, unicode_literals
import copy
import logging
import math
from collections import OrderedDict
import torch
import torch.nn as nn
from maskrcnn_benchmark.layers import (
BatchNorm2d,
Conv2d,
FrozenBatchNorm2d,
... | 24,964 | 29.078313 | 88 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/modeling/backbone/fbnet.py | from __future__ import absolute_import, division, print_function, unicode_literals
import copy
import json
import logging
from collections import OrderedDict
from . import (
fbnet_builder as mbuilder,
fbnet_modeldef as modeldef,
)
import torch.nn as nn
from maskrcnn_benchmark.modeling import registry
from mas... | 7,845 | 30.011858 | 83 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/modeling/backbone/backbone.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2021 Microsoft Corporation. Licensed under the MIT license.
from collections import OrderedDict
from torch import nn
from maskrcnn_benchmark.modeling import registry
from maskrcnn_benchmark.modeling.make_layers import conv_with_k... | 3,247 | 34.304348 | 105 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/modeling/backbone/fpn.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2021 Microsoft Corporation. Licensed under the MIT license.
import torch
import torch.nn.functional as F
from torch import nn
class FPN(nn.Module):
"""
Module that adds FPN on top of a list of feature maps.
The featur... | 4,025 | 38.861386 | 88 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/modeling/backbone/longformer2d.py | # Copyright (c) 2021 Microsoft Corporation. Licensed under the MIT license.
# Written by Pengchuan Zhang, penzhan@microsoft.com
import random
import torch
from torch import nn, einsum
import torch.nn.functional as F
from einops import rearrange
from timm.models.layers import trunc_normal_
from .slidingchunk_2d import s... | 13,311 | 45.383275 | 146 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/modeling/detector/generalized_rcnn.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""
Implements the Generalized R-CNN framework
"""
import torch
from torch import nn
from maskrcnn_benchmark.structures.bounding_box import BoxList
from maskrcnn_benchmark.structures.image_list import to_image_list
from ..backbone import build_b... | 3,277 | 35.831461 | 87 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/modeling/rpn/inference.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from maskrcnn_benchmark.modeling.box_coder import BoxCoder
from maskrcnn_benchmark.structures.bounding_box import BoxList
from maskrcnn_benchmark.structures.boxlist_ops import cat_boxlist
from maskrcnn_benchmark.structures.boxlist_ops... | 7,758 | 36.483092 | 87 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/modeling/rpn/anchor_generator.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import math
import numpy as np
import torch
from torch import nn
from maskrcnn_benchmark.structures.bounding_box import BoxList
class BufferList(nn.Module):
"""
Similar to nn.ParameterList, but for buffers
"""
def __init__(self... | 9,947 | 33.303448 | 88 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/modeling/rpn/loss.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""
This file contains specific functions for computing losses on the RPN
file
"""
import torch
from torch.nn import functional as F
from .utils import concat_box_prediction_layers
from ..balanced_positive_negative_sampler import BalancedPositiv... | 5,807 | 35.759494 | 103 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/modeling/rpn/utils.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""
Utility functions minipulating the prediction layers
"""
from ..utils import cat
import torch
def permute_and_flatten(layer, N, A, C, H, W):
layer = layer.view(N, -1, C, H, W)
layer = layer.permute(0, 3, 4, 1, 2)
layer = layer.re... | 1,679 | 35.521739 | 80 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/modeling/rpn/rpn.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
import torch.nn.functional as F
from torch import nn
from maskrcnn_benchmark.modeling import registry
from maskrcnn_benchmark.modeling.box_coder import BoxCoder
from maskrcnn_benchmark.modeling.rpn.retinanet.retinanet import build_ret... | 7,616 | 35.620192 | 88 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/modeling/rpn/retinanet/inference.py | import torch
from ..inference import RPNPostProcessor
from ..utils import permute_and_flatten
from maskrcnn_benchmark.modeling.box_coder import BoxCoder
from maskrcnn_benchmark.modeling.utils import cat
from maskrcnn_benchmark.structures.bounding_box import BoxList
from maskrcnn_benchmark.structures.boxlist_ops impor... | 6,909 | 34.618557 | 80 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/modeling/rpn/retinanet/loss.py | """
This file contains specific functions for computing losses on the RetinaNet
file
"""
import torch
from torch.nn import functional as F
from ..utils import concat_box_prediction_layers
from maskrcnn_benchmark.layers import smooth_l1_loss
from maskrcnn_benchmark.layers import SigmoidFocalLoss
from maskrcnn_benchma... | 3,500 | 31.416667 | 83 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/modeling/rpn/retinanet/retinanet.py | import math
import torch
import torch.nn.functional as F
from torch import nn
from .inference import make_retinanet_postprocessor
from .loss import make_retinanet_loss_evaluator
from ..anchor_generator import make_anchor_generator_retinanet
from maskrcnn_benchmark.modeling.box_coder import BoxCoder
class RetinaNet... | 5,301 | 33.653595 | 88 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/modeling/roi_heads/roi_heads.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from .box_head.box_head import build_roi_box_head
from .mask_head.mask_head import build_roi_mask_head
from .keypoint_head.keypoint_head import build_roi_keypoint_head
class CombinedROIHeads(torch.nn.ModuleDict):
"""
Combine... | 3,269 | 41.467532 | 96 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/modeling/roi_heads/mask_head/inference.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import numpy as np
import torch
from torch import nn
from maskrcnn_benchmark.layers.misc import interpolate
from maskrcnn_benchmark.structures.bounding_box import BoxList
# TODO check if want to return a single BoxList or a composite
# object
cl... | 6,698 | 30.9 | 87 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/modeling/roi_heads/mask_head/roi_mask_feature_extractors.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from torch import nn
from torch.nn import functional as F
from ..box_head.roi_box_feature_extractors import ResNet50Conv5ROIFeatureExtractor
from maskrcnn_benchmark.modeling import registry
from maskrcnn_benchmark.modeling.poolers import Pooler
fr... | 2,502 | 33.287671 | 82 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/modeling/roi_heads/mask_head/loss.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from torch.nn import functional as F
from maskrcnn_benchmark.layers import smooth_l1_loss
from maskrcnn_benchmark.modeling.matcher import Matcher
from maskrcnn_benchmark.structures.boxlist_ops import boxlist_iou
from maskrcnn_benchmar... | 5,399 | 36.762238 | 90 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/modeling/roi_heads/mask_head/roi_mask_predictors.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from torch import nn
from torch.nn import functional as F
from maskrcnn_benchmark.layers import Conv2d
from maskrcnn_benchmark.layers import ConvTranspose2d
from maskrcnn_benchmark.modeling import registry
@registry.ROI_MASK_PREDICTOR.register("... | 2,229 | 37.448276 | 83 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/modeling/roi_heads/mask_head/mask_head.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from torch import nn
from maskrcnn_benchmark.structures.bounding_box import BoxList
from .roi_mask_feature_extractors import make_roi_mask_feature_extractor
from .roi_mask_predictors import make_roi_mask_predictor
from .inference imp... | 3,140 | 36.392857 | 86 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/modeling/roi_heads/box_head/inference.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2021 Microsoft Corporation. Licensed under the MIT license.
import torch
import torch.nn.functional as F
from torch import nn
from maskrcnn_benchmark.structures.bounding_box import BoxList
from maskrcnn_benchmark.structures.boxlis... | 16,017 | 42.884932 | 115 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/modeling/roi_heads/box_head/roi_box_feature_extractors.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2021 Microsoft Corporation. Licensed under the MIT license.
import torch
from torch import nn
from torch.nn import functional as F
from maskrcnn_benchmark.modeling import registry
from maskrcnn_benchmark.modeling.backbone import r... | 7,448 | 35.876238 | 85 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/modeling/roi_heads/box_head/box_head.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2021 Microsoft Corporation. Licensed under the MIT license.
import torch
from torch import nn
from .roi_box_feature_extractors import make_roi_box_feature_extractor
from .roi_box_predictors import make_roi_box_predictor
from .infe... | 2,886 | 38.013514 | 96 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/modeling/roi_heads/box_head/loss.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2021 Microsoft Corporation. Licensed under the MIT license.
import torch
from torch.nn import functional as F
from maskrcnn_benchmark.layers import smooth_l1_loss
from maskrcnn_benchmark.modeling.box_coder import BoxCoder
from mas... | 8,770 | 37.469298 | 100 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/modeling/roi_heads/box_head/roi_box_predictors.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Copyright (c) 2021 Microsoft Corporation. Licensed under the MIT license.
from maskrcnn_benchmark.modeling import registry
from torch import nn
@registry.ROI_BOX_PREDICTOR.register("FastRCNNPredictor")
class FastRCNNPredictor(nn.Module):
d... | 2,687 | 35.324324 | 87 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/modeling/roi_heads/keypoint_head/inference.py | import torch
from torch import nn
class KeypointPostProcessor(nn.Module):
def __init__(self, keypointer=None):
super(KeypointPostProcessor, self).__init__()
self.keypointer = keypointer
def forward(self, x, boxes):
mask_prob = x
scores = None
if self.keypointer:
... | 4,468 | 34.468254 | 102 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/modeling/roi_heads/keypoint_head/roi_keypoint_feature_extractors.py | from torch import nn
from torch.nn import functional as F
from maskrcnn_benchmark.modeling import registry
from maskrcnn_benchmark.modeling.poolers import Pooler
from maskrcnn_benchmark.layers import Conv2d
@registry.ROI_KEYPOINT_FEATURE_EXTRACTORS.register("KeypointRCNNFeatureExtractor")
class KeypointRCNNFeatureE... | 1,892 | 36.117647 | 87 | py |
Retrieval-Augmented-Visual-Question-Answering | Retrieval-Augmented-Visual-Question-Answering-main/materials/scene_graph_benchmark/maskrcnn_benchmark/modeling/roi_heads/keypoint_head/loss.py | import torch
from torch.nn import functional as F
from maskrcnn_benchmark.modeling.matcher import Matcher
from maskrcnn_benchmark.modeling.balanced_positive_negative_sampler import (
BalancedPositiveNegativeSampler,
)
from maskrcnn_benchmark.structures.boxlist_ops import boxlist_iou
from maskrcnn_benchmark.modeli... | 7,135 | 37.782609 | 90 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.