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 |
|---|---|---|---|---|---|---|
HumanDensePose | HumanDensePose-main/detectron2/modeling/roi_heads/rotated_fast_rcnn.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
import numpy as np
import torch
from detectron2.config import configurable
from detectron2.layers import ShapeSpec, batched_nms_rotated
from detectron2.structures import Instances, RotatedBoxes, pairwise_iou_rotated
from detectron2.u... | 11,439 | 40.299639 | 100 | py |
HumanDensePose | HumanDensePose-main/detectron2/modeling/roi_heads/mask_head.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from typing import List
import fvcore.nn.weight_init as weight_init
import torch
from torch import nn
from torch.nn import functional as F
from detectron2.config import configurable
from detectron2.layers import Conv2d, ConvTranspose2d, ShapeSpec, ... | 11,437 | 38.993007 | 100 | py |
HumanDensePose | HumanDensePose-main/detectron2/modeling/proposal_generator/rrpn.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import itertools
import logging
from typing import Dict, List
import torch
from detectron2.layers import ShapeSpec, batched_nms_rotated, cat
from detectron2.structures import Instances, RotatedBoxes, pairwise_iou_rotated
from detectron2.utils.memor... | 8,508 | 42.192893 | 100 | py |
HumanDensePose | HumanDensePose-main/detectron2/modeling/proposal_generator/rpn.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from typing import Dict, List, Optional, Tuple, Union
import torch
import torch.nn.functional as F
from fvcore.nn import giou_loss, smooth_l1_loss
from torch import nn
from detectron2.config import configurable
from detectron2.layers import ShapeSp... | 23,219 | 44.618861 | 100 | py |
HumanDensePose | HumanDensePose-main/detectron2/modeling/proposal_generator/proposal_utils.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
import math
from typing import List, Tuple
import torch
from detectron2.layers import batched_nms, cat
from detectron2.structures import Boxes, Instances
logger = logging.getLogger(__name__)
def find_top_rpn_proposals(
proposa... | 7,090 | 40.467836 | 100 | py |
HumanDensePose | HumanDensePose-main/detectron2/structures/image_list.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from __future__ import division
from typing import Any, List, Sequence, Tuple
import torch
from torch.nn import functional as F
class ImageList(object):
"""
Structure that holds a list of images (of possibly
varying sizes) as a single... | 4,819 | 39.166667 | 100 | py |
HumanDensePose | HumanDensePose-main/detectron2/structures/instances.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import itertools
from typing import Any, Dict, List, Tuple, Union
import torch
import copy
class Instances:
"""
This class represents a list of instances in an image.
It stores the attributes of instances (e.g., boxes, masks, labels, s... | 6,534 | 31.839196 | 100 | py |
HumanDensePose | HumanDensePose-main/detectron2/structures/masks.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import copy
import itertools
import numpy as np
from typing import Any, Iterator, List, Union
import pycocotools.mask as mask_util
import torch
from detectron2.layers.roi_align import ROIAlign
from .boxes import Boxes
def polygon_area(x, y):
... | 16,592 | 36.797267 | 100 | py |
HumanDensePose | HumanDensePose-main/detectron2/structures/rotated_boxes.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import math
from typing import Any, Iterator, Tuple, Union
import torch
from detectron2.layers.rotated_boxes import pairwise_iou_rotated
from .boxes import Boxes
class RotatedBoxes(Boxes):
"""
This structure stores a list of rotated boxe... | 18,148 | 36.653527 | 98 | py |
HumanDensePose | HumanDensePose-main/detectron2/structures/keypoints.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import numpy as np
from typing import Any, List, Tuple, Union
import torch
from detectron2.layers import interpolate
class Keypoints:
"""
Stores keypoint **annotation** data. GT Instances have a `gt_keypoints` property
containing the ... | 8,202 | 37.511737 | 100 | py |
HumanDensePose | HumanDensePose-main/detectron2/structures/boxes.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import math
import numpy as np
from enum import IntEnum, unique
from typing import Any, List, Tuple, Union
import torch
_RawBoxType = Union[List[float], Tuple[float, ...], torch.Tensor, np.ndarray]
@unique
class BoxMode(IntEnum):
"""
Enum... | 12,632 | 32.688 | 97 | py |
HumanDensePose | HumanDensePose-main/projects/KTNv2/query_db.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import argparse
import logging
import os
import sys
from timeit import default_timer as timer
from typing import Any, ClassVar, Dict, List
import torch
from fvcore.common.file_io import PathManager
from detectron2.data.catal... | 8,452 | 32.677291 | 96 | py |
HumanDensePose | HumanDensePose-main/projects/KTNv2/apply_net.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import argparse
import glob
import logging
import os
import pickle
import sys
from typing import Any, ClassVar, Dict, List
import torch
from detectron2.config import get_cfg
from detectron2.data.detection_utils import read_i... | 11,139 | 33.8125 | 97 | py |
HumanDensePose | HumanDensePose-main/projects/KTNv2/densepose/dataset_mapper.py | # -*- coding: utf-8 -*-
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import copy
import torch
from fvcore.common.file_io import PathManager
import os
from detectron2.data import MetadataCatalog
from detectron2.data import detection_utils as utils
from detectron2.data import transforms as T
fr... | 4,955 | 39.958678 | 100 | py |
HumanDensePose | HumanDensePose-main/projects/KTNv2/densepose/densepose_head.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import math
import pickle
from dataclasses import dataclass
from enum import Enum
from typing import Iterable, List, Optional, Tuple
import fvcore.nn.weight_init as weight_init
import torch
from torch import nn
from torch.nn import functional as F
f... | 93,758 | 39.71168 | 205 | py |
HumanDensePose | HumanDensePose-main/projects/KTNv2/densepose/evaluator.py | # -*- coding: utf-8 -*-
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import contextlib
import copy
import io
import itertools
import json
import logging
import numpy as np
import os
from collections import OrderedDict
import torch
from fvcore.common.file_io import PathManager
from pycocotools... | 7,327 | 36.773196 | 99 | py |
HumanDensePose | HumanDensePose-main/projects/KTNv2/densepose/roi_head.py | # -*- coding: utf-8 -*-
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import numpy as np
from typing import Dict, List, Optional
import fvcore.nn.weight_init as weight_init
import torch
import torch.nn as nn
from torch.nn import functional as F
from detectron2.layers import Conv2d, ShapeSpec,... | 26,565 | 42.694079 | 128 | py |
HumanDensePose | HumanDensePose-main/projects/KTNv2/densepose/vis/base.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
import numpy as np
import cv2
import torch
Image = np.ndarray
Boxes = torch.Tensor
class MatrixVisualizer(object):
"""
Base visualizer for matrix data
"""
def __init__(
self,
inplace=True,
c... | 6,708 | 33.942708 | 100 | py |
HumanDensePose | HumanDensePose-main/projects/KTNv2/densepose/vis/extractor.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
from typing import Sequence
import torch
from detectron2.layers.nms import batched_nms
from detectron2.structures.instances import Instances
from densepose.vis.bounding_box import BoundingBoxVisualizer, ScoredBoundingBoxVisualizer
f... | 5,076 | 32.183007 | 100 | py |
HumanDensePose | HumanDensePose-main/projects/KTNv2/densepose/data/structures.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import base64
import numpy as np
from io import BytesIO
from typing import BinaryIO, Dict, List, Optional, Tuple, Union
import torch
from PIL import Image
from torch.nn import functional as F
class DensePoseTransformData(object):
# Horizontal... | 30,012 | 40.800836 | 128 | py |
HumanDensePose | HumanDensePose-main/projects/KTNv2/densepose/data/inference_based_loader.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import random
from typing import Any, Callable, Iterable, Iterator, List, Optional, Tuple
import torch
from torch import nn
SampledData = Any
ModelOutput = Any
def _grouper(iterable: Iterable[Any], n: int, fillvalue=None) -> Iterator[Tuple[Any]]... | 5,418 | 35.863946 | 94 | py |
HumanDensePose | HumanDensePose-main/projects/KTNv2/densepose/data/dataset_mapper.py | # -*- coding: utf-8 -*-
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import copy
import logging
from typing import Any, Dict, Tuple
import torch
from fvcore.common.file_io import PathManager
from detectron2.data import MetadataCatalog
from detectron2.data import detection_utils as utils
from... | 7,014 | 40.508876 | 100 | py |
HumanDensePose | HumanDensePose-main/projects/KTNv2/densepose/data/build.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import itertools
import logging
import numpy as np
from typing import Any, Callable, Collection, Dict, Iterable, List, Optional, Sequence
import torch
from detectron2.config import CfgNode
from detectron2.data.build import (
build_batch_data_l... | 22,501 | 37.998267 | 100 | py |
HumanDensePose | HumanDensePose-main/projects/KTNv2/densepose/data/video/video_keyframe_dataset.py | # -*- coding: utf-8 -*-
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
import numpy as np
from typing import Callable, List, Optional
import torch
from fvcore.common.file_io import PathManager
from torch.utils.data.dataset import Dataset
import av
from ..utils import maybe_prep... | 8,634 | 37.896396 | 98 | py |
HumanDensePose | HumanDensePose-main/projects/KTNv2/densepose/data/samplers/densepose_confidence_based.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import random
from typing import List, Optional
import torch
from .densepose_base import DensePoseBaseSampler
class DensePoseConfidenceBasedSampler(DensePoseBaseSampler):
"""
Samples DensePose data from DensePose predictions.
Samples... | 4,034 | 42.858696 | 87 | py |
HumanDensePose | HumanDensePose-main/projects/KTNv2/densepose/data/samplers/densepose_base.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from typing import List, Optional
import torch
from torch.nn import functional as F
from detectron2.structures import BoxMode, Instances
from ..structures import (
DensePoseDataRelative,
DensePoseList,
DensePoseOutput,
resample_ou... | 7,169 | 36.539267 | 95 | py |
HumanDensePose | HumanDensePose-main/projects/KTNv2/densepose/data/samplers/densepose_uniform.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import random
import torch
from .densepose_base import DensePoseBaseSampler
class DensePoseUniformSampler(DensePoseBaseSampler):
"""
Samples DensePose data from DensePose predictions.
Samples for each class are drawn uniformly over a... | 1,312 | 30.261905 | 82 | py |
HumanDensePose | HumanDensePose-main/projects/KTNv2/densepose/data/samplers/mask_from_densepose.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import torch
from detectron2.structures import BitMasks, BoxMode, Instances
from ..structures import resample_output_to_bbox
class MaskFromDensePoseSampler:
"""
Produce mask GT from DensePose predictions
DensePose prediction is an i... | 1,583 | 38.6 | 93 | py |
HumanDensePose | HumanDensePose-main/projects/KTNv2/densepose/data/transform/image.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import torch
class ImageResizeTransform:
"""
Transform that converts frames loaded from a dataset
(RGB data in NHWC channel order, typically uint8) to a format ready to be
consumed by DensePose training (BGR float32 data in NCHW c... | 1,480 | 37.973684 | 79 | py |
HumanDensePose | HumanDensePose-main/projects/KTNv2/densepose/modeling/hrnet.py | # ------------------------------------------------------------------------------
# Copyright (c) Microsoft
# Licensed under the MIT License.
# Written by Bin Xiao (leoxiaobin@gmail.com)
# Modified by Bowen Cheng (bcheng9@illinois.edu)
# Adapted from https://github.com/HRNet/Higher-HRNet-Human-Pose-Estimation/blob/maste... | 17,783 | 36.518987 | 126 | py |
HumanDensePose | HumanDensePose-main/projects/KTNv2/densepose/modeling/test_time_augmentation.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import copy
import numpy as np
import torch
from fvcore.transforms import HFlipTransform, TransformList
from torch.nn import functional as F
from detectron2.data.transforms import RandomRotation, RotationTransform, apply_transform_gens
from detectr... | 10,675 | 51.333333 | 100 | py |
HumanDensePose | HumanDensePose-main/projects/KTNv2/densepose/modeling/hrfpn.py | """
MIT License
Copyright (c) 2019 Microsoft
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distr... | 6,991 | 37.417582 | 98 | py |
HumanDensePose | HumanDensePose-main/tests/test_checkpoint.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import unittest
from collections import OrderedDict
import torch
from torch import nn
from detectron2.checkpoint.c2_model_loading import align_and_update_state_dicts
from detectron2.utils.logger import setup_logger
class TestCheckpointer(unittest... | 1,655 | 32.795918 | 79 | py |
HumanDensePose | HumanDensePose-main/tests/test_model_analysis.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import unittest
import torch
import detectron2.model_zoo as model_zoo
from detectron2.config import get_cfg
from detectron2.modeling import build_model
from detectron2.utils.analysis import flop_count_operators, parameter_count
def get_model_z... | 1,946 | 32 | 81 | py |
HumanDensePose | HumanDensePose-main/tests/test_config.py | #!/usr/bin/env python
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import os
import tempfile
import unittest
import torch
from detectron2.config import configurable, downgrade_config, get_cfg, upgrade_config
from detectron2.layers import ShapeSpec
_V0_CFG = """
MODEL:
RPN_HEAD:
NAME:... | 7,333 | 29.431535 | 88 | py |
HumanDensePose | HumanDensePose-main/tests/test_export_caffe2.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
# -*- coding: utf-8 -*-
import copy
import numpy as np
import os
import tempfile
import unittest
import cv2
import torch
from fvcore.common.file_io import PathManager
from detectron2 import model_zoo
from detectron2.checkpoint import DetectionChec... | 2,605 | 35.704225 | 95 | py |
HumanDensePose | HumanDensePose-main/tests/test_engine.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import unittest
import torch
from torch import nn
from detectron2.engine import SimpleTrainer
class SimpleModel(nn.Sequential):
def forward(self, x):
return {"loss": x.sum() + sum([x.mean() for x in self.parameters()])}
class Test... | 884 | 27.548387 | 95 | py |
HumanDensePose | HumanDensePose-main/tests/test_visualizer.py | # -*- coding: utf-8 -*-
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
# File:
import numpy as np
import unittest
import cv2
import torch
from detectron2.data import MetadataCatalog
from detectron2.structures import BoxMode, Instances, RotatedBoxes
from detectron2.utils.visualizer import Visua... | 6,112 | 36.503067 | 93 | py |
HumanDensePose | HumanDensePose-main/tests/layers/test_mask_ops.py | # -*- coding: utf-8 -*-
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import contextlib
import io
import numpy as np
import unittest
from collections import defaultdict
import torch
import tqdm
from fvcore.common.benchmark import benchmark
from fvcore.common.file_io import PathManager
from pyc... | 6,816 | 34.691099 | 100 | py |
HumanDensePose | HumanDensePose-main/tests/layers/test_roi_align_rotated.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
import unittest
import cv2
import torch
from torch.autograd import Variable, gradcheck
from detectron2.layers.roi_align import ROIAlign
from detectron2.layers.roi_align_rotated import ROIAlignRotated
logger = logging.getLogger(__nam... | 6,736 | 37.062147 | 100 | py |
HumanDensePose | HumanDensePose-main/tests/layers/test_nms.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from __future__ import absolute_import, division, print_function, unicode_literals
import unittest
import torch
from detectron2.layers import batched_nms
from detectron2.utils.env import TORCH_VERSION
class TestNMS(unittest.TestCase):
def _cr... | 1,575 | 38.4 | 94 | py |
HumanDensePose | HumanDensePose-main/tests/layers/test_nms_rotated.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from __future__ import absolute_import, division, print_function, unicode_literals
import numpy as np
import unittest
import torch
from torchvision import ops
from detectron2.layers import batched_nms, batched_nms_rotated, nms_rotated
def nms_edi... | 8,495 | 44.191489 | 96 | py |
HumanDensePose | HumanDensePose-main/tests/layers/test_roi_align.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import numpy as np
import unittest
import cv2
import torch
from fvcore.common.benchmark import benchmark
from detectron2.layers.roi_align import ROIAlign
class ROIAlignTest(unittest.TestCase):
def test_forward_output(self):
input = np... | 5,389 | 34.228758 | 91 | py |
HumanDensePose | HumanDensePose-main/tests/data/test_sampler.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import unittest
from torch.utils.data.sampler import SequentialSampler
from detectron2.data.samplers import GroupedBatchSampler
class TestGroupedBatchSampler(unittest.TestCase):
def test_missing_group_id(self):
sampler = SequentialSa... | 800 | 32.375 | 71 | py |
HumanDensePose | HumanDensePose-main/tests/modeling/test_matcher.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import unittest
from typing import List
import torch
from detectron2.config import get_cfg
from detectron2.modeling.matcher import Matcher
from detectron2.utils.env import TORCH_VERSION
class TestMatcher(unittest.TestCase):
# need https://git... | 1,864 | 39.543478 | 98 | py |
HumanDensePose | HumanDensePose-main/tests/modeling/test_roi_pooler.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
import unittest
import torch
from detectron2.modeling.poolers import ROIPooler
from detectron2.structures import Boxes, RotatedBoxes
from detectron2.utils.env import TORCH_VERSION
logger = logging.getLogger(__name__)
class TestROI... | 4,515 | 33.738462 | 100 | py |
HumanDensePose | HumanDensePose-main/tests/modeling/test_fast_rcnn.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
import unittest
import torch
from detectron2.layers import ShapeSpec
from detectron2.modeling.box_regression import Box2BoxTransform, Box2BoxTransformRotated
from detectron2.modeling.roi_heads.fast_rcnn import FastRCNNOutputLayers
fr... | 4,433 | 40.439252 | 100 | py |
HumanDensePose | HumanDensePose-main/tests/modeling/test_model_e2e.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import numpy as np
import unittest
import torch
import detectron2.model_zoo as model_zoo
from detectron2.config import get_cfg
from detectron2.modeling import build_model
from detectron2.structures import BitMasks, Boxes, ImageList, Instances
fr... | 5,942 | 36.613924 | 100 | py |
HumanDensePose | HumanDensePose-main/tests/modeling/test_box2box_transform.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
import unittest
import torch
from detectron2.modeling.box_regression import Box2BoxTransform, Box2BoxTransformRotated
logger = logging.getLogger(__name__)
def random_boxes(mean_box, stdev, N):
return torch.rand(N, 4) * stdev +... | 2,509 | 37.615385 | 94 | py |
HumanDensePose | HumanDensePose-main/tests/modeling/test_rpn.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
import unittest
import torch
from detectron2.config import get_cfg
from detectron2.export.torchscript import export_torchscript_with_instances
from detectron2.layers import ShapeSpec
from detectron2.modeling.backbone import build_bac... | 11,767 | 44.789883 | 99 | py |
HumanDensePose | HumanDensePose-main/tests/modeling/test_anchor_generator.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
import unittest
import torch
from detectron2.config import get_cfg
from detectron2.layers import ShapeSpec
from detectron2.modeling.anchor_generator import DefaultAnchorGenerator, RotatedAnchorGenerator
from detectron2.utils.env impo... | 4,794 | 37.98374 | 95 | py |
HumanDensePose | HumanDensePose-main/tests/modeling/test_roi_heads.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import logging
import unittest
import torch
from detectron2.config import get_cfg
from detectron2.layers import ShapeSpec
from detectron2.modeling.proposal_generator.build import build_proposal_generator
from detectron2.modeling.roi_heads import St... | 5,829 | 41.554745 | 97 | py |
HumanDensePose | HumanDensePose-main/tests/structures/test_rotated_boxes.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from __future__ import absolute_import, division, print_function, unicode_literals
import logging
import math
import random
import unittest
import torch
from fvcore.common.benchmark import benchmark
from detectron2.layers.rotated_boxes import pairw... | 15,708 | 42.879888 | 100 | py |
HumanDensePose | HumanDensePose-main/tests/structures/test_boxes.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import json
import math
import numpy as np
import unittest
import torch
from detectron2.structures import Boxes, BoxMode, pairwise_iou
from detectron2.utils.env import TORCH_VERSION
class TestBoxMode(unittest.TestCase):
def _convert_xy_to_wh(... | 7,290 | 36.582474 | 100 | py |
HumanDensePose | HumanDensePose-main/tests/structures/test_imagelist.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import unittest
from typing import List, Sequence, Tuple
import torch
from detectron2.structures import ImageList
from detectron2.utils.env import TORCH_VERSION
class TestImageList(unittest.TestCase):
def test_imagelist_padding_shape(self):
... | 2,059 | 33.333333 | 82 | py |
HumanDensePose | HumanDensePose-main/tests/structures/test_masks.py | import unittest
import torch
from detectron2.structures.masks import BitMasks, PolygonMasks, polygons_to_bitmask
class TestBitMask(unittest.TestCase):
def test_get_bounding_box(self):
masks = torch.tensor(
[
[
[False, False, False, True],
... | 1,498 | 33.860465 | 96 | py |
HumanDensePose | HumanDensePose-main/tests/structures/test_instances.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import unittest
import torch
from detectron2.export.torchscript import patch_instances
from detectron2.structures import Instances
from detectron2.utils.env import TORCH_VERSION
class TestInstances(unittest.TestCase):
def test_int_indexing(se... | 2,162 | 35.05 | 98 | py |
HumanDensePose | HumanDensePose-main/demo/predictor.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import atexit
import bisect
import multiprocessing as mp
from collections import deque
import cv2
import torch
from detectron2.data import MetadataCatalog
from detectron2.engine.defaults import DefaultPredictor
from detectron2.utils.video_visualize... | 7,864 | 34.588235 | 96 | py |
HumanDensePose | HumanDensePose-main/docs/conf.py | # -*- coding: utf-8 -*-
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
# flake8: noqa
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/maste... | 11,465 | 32.043228 | 140 | py |
HumanDensePose | HumanDensePose-main/dev/packaging/gen_install_table.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
template = """<details><summary> install </summary><pre><code>\
python -m pip install detectron2{d2_version} -f \\
https://dl.fbaipublicfiles.com/detectron2/wheels/{cuda}/torch{torch}/index.html
</code></pre> </details>"""
CUDA_SUFFIX = {"10.2": "cu102",... | 1,769 | 34.4 | 95 | py |
MS-MLP | MS-MLP-main/main.py |
import os
import time
import argparse
import datetime
import numpy as np
import torch
import torch.backends.cudnn as cudnn
import torch.distributed as dist
from timm.loss import LabelSmoothingCrossEntropy, SoftTargetCrossEntropy
from timm.utils import accuracy, AverageMeter, ModelEma
from config import get_config
f... | 16,167 | 40.45641 | 129 | py |
MS-MLP | MS-MLP-main/lr_scheduler.py |
import torch
from timm.scheduler.cosine_lr import CosineLRScheduler
from timm.scheduler.step_lr import StepLRScheduler
from timm.scheduler.scheduler import Scheduler
def build_scheduler(config, optimizer, n_iter_per_epoch):
num_steps = int(config.TRAIN.EPOCHS * n_iter_per_epoch)
warmup_steps = int(config.TRA... | 3,300 | 33.030928 | 105 | py |
MS-MLP | MS-MLP-main/utils.py |
import os
import torch
import torch.distributed as dist
from timm.utils import get_state_dict
try:
# noinspection PyUnresolvedReferences
from apex import amp
except ImportError:
amp = None
def load_checkpoint(config, model, optimizer, lr_scheduler, logger, model_ema=None):
logger.info(f"============... | 3,655 | 37.083333 | 117 | py |
MS-MLP | MS-MLP-main/optimizer.py |
from torch import optim as optim
def build_optimizer(config, model):
"""
Build optimizer, set weight decay of normalization to 0 by default.
"""
skip = {}
skip_keywords = {}
if hasattr(model, 'no_weight_decay'):
skip = model.no_weight_decay()
if hasattr(model, 'no_weight_decay_key... | 1,766 | 32.980769 | 111 | py |
MS-MLP | MS-MLP-main/models/ms_mlp.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.checkpoint as checkpoint
from timm.models.layers import DropPath, to_2tuple, trunc_normal_
class MixShiftBlock(nn.Module):
r""" Mix-Shifting Block.
Args:
dim (int): Number of input channels.
input_resolutio... | 15,706 | 40.334211 | 216 | py |
MS-MLP | MS-MLP-main/data/samplers.py |
import torch
class SubsetRandomSampler(torch.utils.data.Sampler):
r"""Samples elements randomly from a given list of indices, without replacement.
Arguments:
indices (sequence): a sequence of indices
"""
def __init__(self, indices):
self.epoch = 0
self.indices = indices
... | 534 | 21.291667 | 84 | py |
MS-MLP | MS-MLP-main/data/build.py | import os
import torch
import numpy as np
import torch.distributed as dist
from torchvision import datasets, transforms
from timm.data.constants import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD
from timm.data import Mixup
from timm.data import create_transform
from timm.data.transforms import _pil_interp
from .cache... | 5,501 | 41.651163 | 165 | py |
MS-MLP | MS-MLP-main/data/cached_image_folder.py | import io
import os
import time
import torch.distributed as dist
import torch.utils.data as data
from PIL import Image
import pickle
from .zipreader import is_zip_path, ZipReader
def has_file_allowed_extension(filename, extensions):
"""Checks if a file is an allowed extension.
Args:
filename (string)... | 9,730 | 35.040741 | 115 | py |
cluttered-pushing | cluttered-pushing-main/Networks/VAE/models/tf_model.py | import tensorflow as tf
import tensorflow_probability as tfp
import numpy as np
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
tfd = tfp.distributions
tfpl = tfp.layers
tfk = tf.keras
tfkl = tf.keras.layers
np.random.seed(25)
class create_Architecture():
def __init__(self, indipendent, inp... | 9,088 | 49.21547 | 148 | py |
cluttered-pushing | cluttered-pushing-main/Networks/VAE/scripts/train_vae.py | from tf_model import VAE, create_Architecture
from custom_callback import SaveModelCallback
import tensorflow as tf
import numpy as np
import h5py
import os
import cv2
tfk = tf.keras
from tqdm import tqdm
#os.environ["CUDA_VISIBLE_DEVICES"] = str(5)
gpus = tf.config.experimental.list_physical_devices('GPU')
for gpu in ... | 4,067 | 48.012048 | 119 | py |
cluttered-pushing | cluttered-pushing-main/Networks/VAE/scripts/custom_callback.py | import tensorflow as tf
import tensorflow_probability as tfp
import numpy as np
import matplotlib
import shutil
matplotlib.use('Agg')
import matplotlib.pyplot as plt
tfd = tfp.distributions
tfpl = tfp.layers
tfk = tf.keras
tfkl = tf.keras.layers
np.random.seed(25)
class SaveModelCallback(tfk.callbacks.Callback):
... | 13,024 | 49.096154 | 139 | py |
cluttered-pushing | cluttered-pushing-main/Networks/RL/scripts/test_agent_script.py | from stable_baselines3 import TD3, PPO, SAC
from sb3_contrib import TQC
import gym, push_gym
import tensorflow as tf
from tqdm import tqdm
from stable_baselines3.common.env_util import make_vec_env
import json
import os
for gpu in tf.config.experimental.list_physical_devices("GPU"):
tf.config.experimental.set_memo... | 2,141 | 37.25 | 118 | py |
cluttered-pushing | cluttered-pushing-main/Networks/RL/scripts/policy_network.py | import gym
import torch as th
import torch.nn as nn
from stable_baselines3.common.torch_layers import BaseFeaturesExtractor
class CNN(BaseFeaturesExtractor):
"""
:param observation_space: (gym.Space)
:param features_dim: (int) Number of features extracted.
This corresponds to the number of unit for... | 3,962 | 42.076087 | 135 | py |
cluttered-pushing | cluttered-pushing-main/Networks/RL/scripts/train_agent_script.py | from stable_baselines3 import TD3, PPO, SAC
from sb3_contrib import TQC
from stable_baselines3.common.callbacks import EvalCallback
from stable_baselines3.common.noise import NormalActionNoise
from custom_callbacks import SavingCallback, ProgressBarManager, CurriculumCallback
import os
import gym, push_gym
import numpy... | 4,851 | 48.010101 | 159 | py |
cluttered-pushing | cluttered-pushing-main/push_gym/push_gym/utils/transformations.py | # -*- coding: utf-8 -*-
# transformations.py
# Copyright (c) 2006, Christoph Gohlke
# Copyright (c) 2006-2009, The Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions a... | 57,638 | 35.619441 | 79 | py |
DeepSatModels | DeepSatModels-master/models/LocalSelfAttention/cscl.py | # modified from: https://github.com/leaderj1001/Stand-Alone-Self-Attention/blob/master/attention.py
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.nn.init as init
class ContextSelfSimilarity(nn.Module):
def __init__(self, in_channels, attn_channels, kernel_size, stride=1, dilation... | 13,119 | 47.058608 | 137 | py |
DeepSatModels | DeepSatModels-master/models/CropTypeMapping/constants.py | import numpy as np
import torch.nn as nn
import torch
import os
"""
Constants for file paths
"""
SPLITS = ['train', 'val', 'test']
NON_DL_MODELS = ['logreg', 'random_forest']
DL_MODELS = ['bidir_clstm','fcn', 'unet', 'fcn_crnn', 'mi_clstm', 'unet3d', 'only_clstm_mi']
MULTI_RES_MODELS = ['fcn_crnn']
S1_NUM_BANDS = 3
... | 7,118 | 48.4375 | 216 | py |
DeepSatModels | DeepSatModels-master/models/CropTypeMapping/loss_fns.py | """
Loss functions and optimization definition.
"""
import numpy as np
import torch.optim as optim
import torch.nn as nn
import torch
import preprocess
from constants import *
def get_loss_fn(model_name):
"""
Allows for changing the loss function depending on the model.
Currently always returns... | 5,546 | 36.47973 | 104 | py |
DeepSatModels | DeepSatModels-master/models/CropTypeMapping/datasets.py | """
File that houses the dataset wrappers we have.
"""
import torch
from torch.utils.data import Dataset, DataLoader, Sampler
import pickle
import h5py
import numpy as np
import os
from skimage.transform import resize as imresize
import preprocess
from constants import *
from random import shuffle
from pprint impo... | 21,486 | 46.120614 | 300 | py |
DeepSatModels | DeepSatModels-master/models/CropTypeMapping/util.py | """
Util file for misc functions
"""
from constants import *
import numpy as np
import itertools
import matplotlib.pyplot as plt
import argparse
import pickle
import pandas as pd
import time
import random
from datetime import datetime
from sklearn.model_selection import GroupShuffleSplit
from constants import *
impor... | 21,563 | 44.783439 | 192 | py |
DeepSatModels | DeepSatModels-master/models/CropTypeMapping/models.py | """
code modified from: https://github.com/roserustowicz/crop-type-mapping
File housing all models.
Each model can be created by invoking the appropriate function
given by:
make_MODELNAME_model(MODEL_SETTINGS)
Changes to allow this are still in progess
"""
from torchvision import models
import torchfcn
from mod... | 31,032 | 53.828622 | 200 | py |
DeepSatModels | DeepSatModels-master/models/CropTypeMapping/metrics.py | import numpy as np
import torch
import util
import preprocess
from constants import *
from sklearn.metrics import confusion_matrix, f1_score
def get_accuracy(model_name, y_pred, y_true, reduction='avg'):
"""
Get accuracy from predictions and labels
Args:
y_true - (torch tensor) torch.Size([batch_... | 3,347 | 35 | 93 | py |
DeepSatModels | DeepSatModels-master/models/CropTypeMapping/train.py | """
Script for training and evaluating a model
"""
import os
import loss_fns
import models
import datetime
import torch
import datasets
import metrics
import util
import numpy as np
import pickle
from torch import autograd
from constants import *
from tqdm import tqdm
from torch import autograd
import visualize
d... | 13,387 | 46.814286 | 206 | py |
DeepSatModels | DeepSatModels-master/models/CropTypeMapping/preprocess.py | """
File that houses all functions used to format, preprocess, or manipulate the data.
Consider this essentially a util library specifically for data manipulation.
"""
import torch
from PIL import Image
from torchvision.utils import save_image
import torchvision.transforms as transforms
import torch.nn.utils.rnn as ... | 27,677 | 40.496252 | 218 | py |
DeepSatModels | DeepSatModels-master/models/CropTypeMapping/visualize.py | """
import random
File for visualizing model performance.
"""
import numpy as np
import os
from matplotlib import pyplot as plt
plt.switch_backend('agg')
import visdom
from torchvision.utils import save_image, make_grid
import metrics
import preprocess
import util
from constants import *
class VisdomLogger:
... | 17,613 | 46.605405 | 193 | py |
DeepSatModels | DeepSatModels-master/models/CropTypeMapping/random_search.py | """
Wrapper script for performing random search.
Hyperparameters should be specified as --hpname_range="(...)" and added to the appropriate list in the constants.py file.
The types of values that can be generated are specified in the functions below.
run with:
python random_search.py --model_name fcn_crnn --datas... | 9,382 | 43.259434 | 567 | py |
DeepSatModels | DeepSatModels-master/models/CropTypeMapping/modelling/cgru_cell.py | # script assumes it will be called from root directory, hence 'modelling.recurrent_norm' instead of just 'recurrent_norm'
import torch
import torch.nn as nn
import torch.nn.functional as F
from torchvision import models
import numpy as np
from models.CropTypeMapping.constants import *
from models.CropTypeMapping.mode... | 3,437 | 38.517241 | 128 | py |
DeepSatModels | DeepSatModels-master/models/CropTypeMapping/modelling/baselines.py | from keras.models import Sequential, Model
from keras.layers import InputLayer, Activation, BatchNormalization, Flatten, Dropout
from keras.layers import Dense, Conv2D, MaxPooling2D, ConvLSTM2D, Lambda
from keras.layers import Conv1D, MaxPooling1D
from keras import regularizers
from keras.layers import Bidirectional, T... | 6,488 | 38.567073 | 130 | py |
DeepSatModels | DeepSatModels-master/models/CropTypeMapping/modelling/recurrent_norm.py | import torch
import torch.nn as nn
from torch.autograd import Variable
from torch.nn import functional, init
class RecurrentNorm2d(nn.Module):
"""
Normalization Module which keeps track of separate statistics for each timestep as described in
https://arxiv.org/pdf/1603.09025.pdf
Currently only con... | 4,521 | 35.764228 | 115 | py |
DeepSatModels | DeepSatModels-master/models/CropTypeMapping/modelling/only_clstm_mi.py | import torch
import torch.nn as nn
from models.CropTypeMapping.modelling.util import initialize_weights
from models.CropTypeMapping.modelling.clstm import CLSTM
from models.CropTypeMapping.modelling.clstm_segmenter import CLSTMSegmenter
from models.CropTypeMapping.modelling.attention import ApplyAtt, attn_or_avg
from p... | 4,366 | 40.990385 | 148 | py |
DeepSatModels | DeepSatModels-master/models/CropTypeMapping/modelling/clstm.py | import torch
import torch.nn as nn
from models.CropTypeMapping.modelling.recurrent_norm import RecurrentNorm2d
from models.CropTypeMapping.modelling.clstm_cell import ConvLSTMCell
from models.CropTypeMapping.modelling.util import initialize_weights
class CLSTM(nn.Module):
def __init__(self,
inp... | 4,343 | 40.371429 | 106 | py |
DeepSatModels | DeepSatModels-master/models/CropTypeMapping/modelling/clstm_segmenter.py | import torch
import torch.nn as nn
from models.CropTypeMapping.modelling.util import initialize_weights
from models.CropTypeMapping.modelling.clstm import CLSTM
from models.CropTypeMapping.modelling.attention import ApplyAtt, attn_or_avg
class CLSTMSegmenter(nn.Module):
""" CLSTM followed by conv for segmentation ... | 2,483 | 40.4 | 129 | py |
DeepSatModels | DeepSatModels-master/models/CropTypeMapping/modelling/fcn8.py | import torch
import torch.nn as nn
class FCN8(nn.Module):
'''
FCN implementation from https://github.com/wkentaro/pytorch-fcn/tree/63bc2c5bf02633f08d0847bb2dbd0b2f90034837
'''
def __init__(self, n_class=5, n_channel = 11):
super(FCN8s_croptype, self).__init__()
# conv1
self.co... | 5,178 | 34.472603 | 113 | py |
DeepSatModels | DeepSatModels-master/models/CropTypeMapping/modelling/cgru_segmenter.py | import torch
import torch.nn as nn
from models.CropTypeMapping.modelling.util import initialize_weights
from models.CropTypeMapping.modelling.cgru import CGRU
class CGRUSegmenter(nn.Module):
""" cgru followed by conv for segmentation output
"""
def __init__(self, input_size, hidden_dims, gru_kernel_sizes,... | 1,622 | 42.864865 | 151 | py |
DeepSatModels | DeepSatModels-master/models/CropTypeMapping/modelling/clstm_cell.py | # script assumes it will be called from root directory, hence 'modelling.recurrent_norm' instead of just 'recurrent_norm'
import torch
import torch.nn as nn
import torch.nn.functional as F
from torchvision import models
import numpy as np
from models.CropTypeMapping.constants import *
from models.CropTypeMapping.mode... | 3,078 | 37.012346 | 131 | py |
DeepSatModels | DeepSatModels-master/models/CropTypeMapping/modelling/unet.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from models.CropTypeMapping.modelling.util import initialize_weights
class _EncoderBlock(nn.Module):
""" U-Net encoder block
"""
def __init__(self, in_channels, out_channels, dropout=False):
super(_EncoderBlock, self).__init__()
... | 7,231 | 36.278351 | 117 | py |
DeepSatModels | DeepSatModels-master/models/CropTypeMapping/modelling/util.py | import torch
import torch.nn as nn
from models.CropTypeMapping.constants import *
def set_parameter_requires_grad(model, fix_feats):
if fix_feats:
for param in model.parameters():
param.requires_grad = False
def initialize_weights(*models):
for model in models:
for module in mode... | 2,189 | 33.761905 | 95 | py |
DeepSatModels | DeepSatModels-master/models/CropTypeMapping/modelling/unet3d.py | import torch
import torch.nn as nn
def conv_block(in_dim, middle_dim, out_dim):
model = nn.Sequential(
nn.Conv3d(in_dim,middle_dim, kernel_size=3, stride=1, padding=1),
nn.BatchNorm3d(middle_dim),
nn.LeakyReLU(inplace=True),
nn.Conv3d(middle_dim, out_dim, kernel_size=3, stride=1, p... | 3,980 | 33.921053 | 98 | py |
DeepSatModels | DeepSatModels-master/models/CropTypeMapping/modelling/attention.py | import torch
import torch.nn as nn
def attn_or_avg(attention, avg_hidden_states, layer_outputs, rev_layer_outputs, bidirectional, lengths=None):
if (attention is None) or (attention(layer_outputs) is None):
if not avg_hidden_states:
# TODO: want to take the last non-zero padded output here inst... | 5,981 | 46.47619 | 161 | py |
DeepSatModels | DeepSatModels-master/models/CropTypeMapping/modelling/multi_input_clstm.py | import torch
import torch.nn as nn
from models.CropTypeMapping.modelling.util import initialize_weights
from models.CropTypeMapping.modelling.clstm import CLSTM
from models.CropTypeMapping.modelling.clstm_segmenter import CLSTMSegmenter
from models.CropTypeMapping.modelling.unet import UNet, UNet_Encode, UNet_Decode
fr... | 9,083 | 48.639344 | 152 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.