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 |
|---|---|---|---|---|---|---|
alignn | alignn-main/alignn/scripts/make_test_split_cross_pred.py | from jarvis.db.jsonutils import loadjson
from alignn.models.alignn_layernorm import ALIGNN # , ALIGNNConfig
# from alignn.models.alignn import ALIGNN
import pandas as pd
import torch
from jarvis.core.atoms import Atoms
from jarvis.core.graphs import Graph
from jarvis.db.figshare import data
from sklearn.metrics impor... | 1,923 | 24.315789 | 75 | py |
alignn | alignn-main/alignn/scripts/alignn_evac.py | """Modules for making point-defect vacancies."""
# https://arxiv.org/abs/2205.08366
from jarvis.analysis.defects.vacancy import Vacancy
from jarvis.analysis.thermodynamics.energetics import unary_energy
from alignn.pretrained import get_figshare_model
from jarvis.db.figshare import data
import torch
from jarvis.core.at... | 4,124 | 28.891304 | 71 | py |
alignn | alignn-main/alignn/scripts/predict.py | """Module to predict using a trained model."""
import torch
from jarvis.core.atoms import Atoms
from jarvis.core.graphs import Graph
from alignn.models.alignn import ALIGNN
from jarvis.analysis.structure.spacegroup import Spacegroup3D
device = "cpu"
if torch.cuda.is_available():
device = torch.device("cuda")
model... | 1,192 | 21.509434 | 63 | py |
alignn | alignn-main/alignn/tests/test_force_reduction.py | import json
import torch
from torch import nn
from torch.nn import functional as F
from jarvis.core.atoms import Atoms
import dgl
import dgl.function as fn
from dgl.nn import SumPooling
from alignn.models.alignn import EdgeGatedGraphConv
# double precision for gradient checking
torch.set_default_dtype(torch.float64)... | 8,358 | 29.731618 | 86 | py |
torchcv | torchcv-master/main.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# Main Scripts for computer vision.
import os
import json
import time
import random
import argparse
import torch
import torch.backends.cudnn as cudnn
from runner.runner_selector import RunnerSelector
from lib.runner.controller imp... | 10,089 | 51.827225 | 104 | py |
torchcv | torchcv-master/runner/seg/fcn_segmentor_test.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You (youansheng@gmail.com)
# Class Definition for Semantic Segmentation.
import os
import cv2
import numpy as np
import torch
from PIL import Image
from data.test.test_data_loader import TestDataLoader
from lib.runner.blob_helper import BlobHelper
from lib... | 11,068 | 46.506438 | 120 | py |
torchcv | torchcv-master/runner/seg/fcn_segmentor.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You (youansheng@gmail.com)
# Class Definition for Semantic Segmentation.
import cv2
import time
import numpy as np
import torch
from data.seg.data_loader import DataLoader
from lib.runner.runner_helper import RunnerHelper
from lib.runner.trainer import Tra... | 7,602 | 40.546448 | 117 | py |
torchcv | torchcv-master/runner/cls/image_classifier_test.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You (youansheng@gmail.com)
# Class Definition for Image Classifier.
import os
import cv2
import json
import torch
import torchvision.transforms as transforms
from PIL import Image
from lib.runner.blob_helper import BlobHelper
from lib.runner.runner_helper ... | 4,573 | 35.887097 | 118 | py |
torchcv | torchcv-master/runner/cls/image_classifier.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You (youansheng@gmail.com)
# Class Definition for Image Classifier.
import time
import torch
from lib.runner.runner_helper import RunnerHelper
from lib.runner.trainer import Trainer
from lib.tools.util.average_meter import AverageMeter, DictAverageMeter
fr... | 8,620 | 43.901042 | 123 | py |
torchcv | torchcv-master/runner/det/faster_rcnn_test.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You (youansheng@gmail.com)
# Class Definition for Single Shot Detector.
import os
import torch
import torch.nn.functional as F
from data.test.test_data_loader import TestDataLoader
from lib.runner.blob_helper import BlobHelper
from lib.runner.runner_helper... | 6,900 | 46.923611 | 120 | py |
torchcv | torchcv-master/runner/det/faster_rcnn.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You (youansheng@gmail.com)
# Class Definition for Faster R-CNN.
import time
import torch
from data.det.data_loader import DataLoader
from runner.det.faster_rcnn_test import FastRCNNTest
from lib.runner.runner_helper import RunnerHelper
from lib.runner.trai... | 8,034 | 42.198925 | 114 | py |
torchcv | torchcv-master/runner/det/single_shot_detector_test.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You (youansheng@gmail.com)
# Class Definition for Single Shot Detector.
import os
import torch
from data.test.test_data_loader import TestDataLoader
from lib.runner.blob_helper import BlobHelper
from lib.runner.runner_helper import RunnerHelper
from model.... | 5,408 | 44.453782 | 120 | py |
torchcv | torchcv-master/runner/det/single_shot_detector.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You (youansheng@gmail.com)
# Class Definition for Single Shot Detector.
import time
import torch
from data.det.data_loader import DataLoader
from runner.det.single_shot_detector_test import SingleShotDetectorTest
from lib.runner.runner_helper import Runner... | 7,867 | 41.994536 | 115 | py |
torchcv | torchcv-master/runner/det/yolov3_test.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You (youansheng@gmail.com)
# Class Definition for Single Shot Detector.
import os
import torch
from data.test.test_data_loader import TestDataLoader
from lib.runner.runner_helper import RunnerHelper
from model.det.model_manager import ModelManager
from lib... | 4,463 | 45.5 | 121 | py |
torchcv | torchcv-master/runner/det/yolov3.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You (youansheng@gmail.com)
# Class Definition for Yolo v3.
import time
import torch
from data.det.data_loader import DataLoader
from runner.det.yolov3_test import YOLOv3Test
from lib.runner.runner_helper import RunnerHelper
from lib.runner.trainer import T... | 7,212 | 39.751412 | 121 | py |
torchcv | torchcv-master/runner/pose/pose_estimator.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You (youansheng@gmail.com)
# Class Definition for Pose Estimator.
import time
import torch
from data.pose.data_loader import DataLoader
from lib.runner.runner_helper import RunnerHelper
from lib.runner.trainer import Trainer
from model.pose.model_manager i... | 5,947 | 37.623377 | 119 | py |
torchcv | torchcv-master/runner/pose/conv_pose_machine_test.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You (youansheng@gmail.com)
import os
import cv2
import numpy as np
import torch
from scipy.ndimage.filters import gaussian_filter
from lib.runner.blob_helper import BlobHelper
from lib.runner.runner_helper import RunnerHelper
from model.pose.model_manager ... | 4,133 | 40.757576 | 102 | py |
torchcv | torchcv-master/runner/pose/open_pose_test.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You (youansheng@gmail.com)
# Class Definition for Pose Estimator.
import math
import os
import cv2
import numpy as np
import torch
from scipy.ndimage.filters import gaussian_filter
from data.pose.data_loader import DataLoader
from lib.runner.blob_helper im... | 16,268 | 47.709581 | 119 | py |
torchcv | torchcv-master/runner/gan/face_gan_test.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You (youansheng@gmail.com)
# Class Definition for GAN.
import os
import glob
import numpy as np
import torch
from sklearn.metrics.pairwise import cosine_similarity
from sklearn.metrics import roc_curve
from lib.runner.blob_helper import BlobHelper
from lib... | 6,671 | 42.607843 | 121 | py |
torchcv | torchcv-master/runner/gan/image_translator_test.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You (youansheng@gmail.com)
# Class Definition for GAN.
import os
import torch
from lib.runner.blob_helper import BlobHelper
from lib.runner.runner_helper import RunnerHelper
from model.gan.model_manager import ModelManager
from data.test.test_data_loader i... | 3,963 | 49.820513 | 123 | py |
torchcv | torchcv-master/runner/gan/face_gan.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You (youansheng@gmail.com)
# Class Definition for GAN.
import time
import torch
from data.gan.data_loader import DataLoader
from lib.runner.runner_helper import RunnerHelper
from lib.runner.trainer import Trainer
from runner.gan.face_gan_test import FaceGA... | 5,995 | 37.935065 | 115 | py |
torchcv | torchcv-master/runner/gan/image_translator.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You (youansheng@gmail.com)
# Class Definition for GAN.
import time
import torch
from data.gan.data_loader import DataLoader
from lib.runner.runner_helper import RunnerHelper
from lib.runner.trainer import Trainer
from model.gan.model_manager import ModelMa... | 5,820 | 37.045752 | 113 | py |
torchcv | torchcv-master/data/seg/data_loader.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# Class for the Semantic Segmentation Data Loader.
import torch
from torch.utils import data
import lib.data.pil_aug_transforms as pil_aug_trans
import lib.data.cv2_aug_transforms as cv2_aug_trans
import lib.data.transforms as tra... | 5,065 | 41.571429 | 104 | py |
torchcv | torchcv-master/data/seg/datasets/cityscapes_dataset.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
import os
import numpy as np
from torch.utils import data
from lib.parallel.data_container import DataContainer
from lib.tools.helper.image_helper import ImageHelper
from lib.tools.helper.file_helper import FileHelper
from lib.too... | 5,032 | 37.128788 | 97 | py |
torchcv | torchcv-master/data/seg/datasets/default_dataset.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
import os
import numpy as np
from torch.utils import data
from lib.parallel.data_container import DataContainer
from lib.tools.helper.image_helper import ImageHelper
from lib.tools.util.logger import Logger as Log
class DefaultD... | 4,767 | 36.543307 | 97 | py |
torchcv | torchcv-master/data/test/test_data_loader.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
import torch
from torch.utils import data
import lib.data.pil_aug_transforms as pil_aug_trans
import lib.data.cv2_aug_transforms as cv2_aug_trans
from lib.data.collate import collate
from lib.data.transforms import ToTensor, Norma... | 3,892 | 44.8 | 110 | py |
torchcv | torchcv-master/data/test/datasets/facegan_dataset.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# Single Shot Detector data loader
import os
import torch.utils.data as data
from lib.parallel.data_container import DataContainer
from lib.tools.helper.json_helper import JsonHelper
from lib.tools.helper.image_helper import Image... | 2,372 | 34.954545 | 109 | py |
torchcv | torchcv-master/data/test/datasets/default_dataset.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# Single Shot Detector data loader
import os
import torch.utils.data as data
from lib.parallel.data_container import DataContainer
from lib.tools.helper.file_helper import FileHelper
from lib.tools.helper.image_helper import Image... | 1,886 | 34.603774 | 104 | py |
torchcv | torchcv-master/data/test/datasets/list_dataset.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# Single Shot Detector data loader
import os
import torch.utils.data as data
from lib.parallel.data_container import DataContainer
from lib.tools.helper.image_helper import ImageHelper
from lib.tools.util.logger import Logger as L... | 2,336 | 34.409091 | 109 | py |
torchcv | torchcv-master/data/test/datasets/json_dataset.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# Single Shot Detector data loader
import os
import torch.utils.data as data
from lib.parallel.data_container import DataContainer
from lib.tools.helper.json_helper import JsonHelper
from lib.tools.helper.image_helper import Image... | 2,307 | 34.507692 | 109 | py |
torchcv | torchcv-master/data/cls/data_loader.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
import torch
from torch.utils import data
import lib.data.pil_aug_transforms as pil_aug_trans
import lib.data.cv2_aug_transforms as cv2_aug_trans
import lib.data.transforms as trans
from lib.data.collate import collate
from lib.to... | 3,898 | 39.614583 | 101 | py |
torchcv | torchcv-master/data/cls/datasets/default_dataset.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# Data loader for Image Classification.
import json
import os
import torch.utils.data as data
from lib.parallel.data_container import DataContainer
from lib.tools.helper.image_helper import ImageHelper
from lib.tools.util.logger i... | 2,636 | 32.807692 | 107 | py |
torchcv | torchcv-master/data/det/data_loader.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
import torch
from torch.utils import data
import lib.data.pil_aug_transforms as pil_aug_trans
import lib.data.cv2_aug_transforms as cv2_aug_trans
import lib.data.transforms as trans
from lib.data.collate import collate
from lib.to... | 3,635 | 39.4 | 101 | py |
torchcv | torchcv-master/data/det/datasets/default_dataset.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# Single Shot Detector data loader
import os
import torch
import numpy as np
import torch.utils.data as data
from lib.parallel.data_container import DataContainer
from lib.tools.helper.json_helper import JsonHelper
from lib.tools.... | 4,387 | 36.827586 | 113 | py |
torchcv | torchcv-master/data/pose/data_loader.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# Class for the Pose Data Loader.
from torch.utils import data
import lib.data.pil_aug_transforms as pil_aug_trans
import lib.data.cv2_aug_transforms as cv2_aug_trans
import lib.data.transforms as trans
from lib.data.collate impor... | 4,591 | 43.582524 | 109 | py |
torchcv | torchcv-master/data/pose/datasets/default_cpm_dataset.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# Class for the Lane Pose Loader.
import os
import numpy as np
import torch
import torch.utils.data as data
from data.pose.utils.heatmap_generator import HeatmapGenerator
from lib.parallel.data_container import DataContainer
from ... | 3,735 | 34.245283 | 85 | py |
torchcv | torchcv-master/data/pose/datasets/default_openpose_dataset.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# OpenPose data loader for keypoints detection.
import os
import torch
import numpy as np
import torch.utils.data as data
from lib.parallel.data_container import DataContainer
from lib.tools.helper.json_helper import JsonHelper
fr... | 5,630 | 38.93617 | 107 | py |
torchcv | torchcv-master/data/pose/utils/paf_generator.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
import math
import numpy as np
import torch
class PafGenerator(object):
def __init__(self, configer):
self.configer = configer
def __call__(self, gt_kpts, input_size, maskmap=None):
input_width, input_he... | 3,280 | 39.012195 | 118 | py |
torchcv | torchcv-master/data/pose/utils/heatmap_generator.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
import numpy as np
import torch
from lib.tools.util.logger import Logger as Log
class HeatmapGenerator(object):
def __init__(self, configer):
self.configer = configer
def __call__(self, gt_kpts, input_size, mas... | 2,110 | 32.507937 | 100 | py |
torchcv | torchcv-master/data/ins/data_loader.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
from torch.utils import data
import lib.data.pil_aug_transforms as pil_aug_trans
import lib.data.cv2_aug_transforms as cv2_aug_trans
import lib.data.transforms as trans
from lib.data.collate import collate
from lib.tools.util.logg... | 3,726 | 38.231579 | 101 | py |
torchcv | torchcv-master/data/ins/datasets/default_dataset.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
import os
import numpy as np
from torch.utils import data
from lib.parallel.data_container import DataContainer
from lib.tools.helper.image_helper import ImageHelper
from lib.tools.helper.json_helper import JsonHelper
from lib.too... | 3,885 | 35.660377 | 113 | py |
torchcv | torchcv-master/data/gan/data_loader.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
from torch.utils import data
from data.gan.datasets.default_pix2pix_dataset import DefaultPix2pixDataset
from data.gan.datasets.default_cyclegan_dataset import DefaultCycleGANDataset
from data.gan.datasets.default_facegan_dataset ... | 5,747 | 44.984 | 109 | py |
torchcv | torchcv-master/data/gan/datasets/default_pix2pix_dataset.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# Single Shot Detector data loader
import os
import torch.utils.data as data
from lib.parallel.data_container import DataContainer
from lib.tools.helper.image_helper import ImageHelper
from lib.tools.util.logger import Logger as L... | 3,172 | 36.77381 | 83 | py |
torchcv | torchcv-master/data/gan/datasets/default_cyclegan_dataset.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# Single Shot Detector data loader
import os
import random
import torch.utils.data as data
from lib.parallel.data_container import DataContainer
from lib.tools.helper.image_helper import ImageHelper
class DefaultCycleGANDataset(... | 2,812 | 34.607595 | 83 | py |
torchcv | torchcv-master/data/gan/datasets/default_facegan_dataset.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# Single Shot Detector data loader
import os
import json
import random
import torch.utils.data as data
from lib.parallel.data_container import DataContainer
from lib.tools.helper.image_helper import ImageHelper
from lib.tools.util... | 4,393 | 39.685185 | 122 | py |
torchcv | torchcv-master/model/seg/nets/pspnet.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# Pytorch implementation of PSP net Synchronized Batch Normalization
# this is pytorch implementation of PSP resnet101 (syn-bn) version
import torch
import torch.nn as nn
import torch.nn.functional as F
from lib.model.module_helpe... | 5,541 | 38.870504 | 111 | py |
torchcv | torchcv-master/model/seg/nets/sfnet.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You (youansheng@pku.edu.cn), Xiangtai Li(lxt@pku.edu.cn)
import torch.nn as nn
import torch
import torch.nn.functional as F
from lib.model.module_helper import ModuleHelper
from model.seg.loss.loss import BASE_LOSS_DICT
def conv3x3_bn_relu(in_planes, out... | 10,225 | 40.569106 | 138 | py |
torchcv | torchcv-master/model/seg/nets/denseassp.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# SynBN_version of DenseAspp
import torch
from torch import nn
import torch.nn.functional as F
from lib.model.module_helper import ModuleHelper
from model.seg.loss.loss import BASE_LOSS_DICT
MODEL_CONFIG = {
'dropout0': 0.1,... | 6,332 | 39.082278 | 120 | py |
torchcv | torchcv-master/model/seg/nets/annn.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from lib.model.module_helper import ModuleHelper
from model.seg.utils.apnb import APNB
from model.seg.utils.afnb import AFNB
from model.seg.loss.loss import BASE_LOSS_DICT
class asymmetric_non_local_network(nn.Sequential):
def __init__(self, conf... | 3,427 | 45.958904 | 134 | py |
torchcv | torchcv-master/model/seg/nets/deeplabv3.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# deeplabv3 res101 (synchronized BN version)
import torch
import torch.nn as nn
import torch.nn.functional as F
from lib.model.module_helper import ModuleHelper
from model.seg.loss.loss import BASE_LOSS_DICT
class ASPPModule(nn.... | 5,785 | 42.833333 | 120 | py |
torchcv | torchcv-master/model/seg/loss/ohem_ce_loss.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# Loss function for Semantic Segmentation.
import torch
import torch.nn as nn
import torch.nn.functional as F
class OhemCELoss(nn.Module):
def __init__(self, configer):
super(OhemCELoss, self).__init__()
self.... | 2,818 | 46.779661 | 113 | py |
torchcv | torchcv-master/model/seg/loss/ce_loss.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# Loss function for Semantic Segmentation.
import torch
import torch.nn as nn
import torch.nn.functional as F
class CELoss(nn.Module):
def __init__(self, configer=None):
super(CELoss, self).__init__()
self.con... | 1,298 | 38.363636 | 104 | py |
torchcv | torchcv-master/model/seg/loss/loss.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# Loss function for Image Classification.
import torch.nn as nn
from model.seg.loss.ce_loss import CELoss
from model.seg.loss.embed_loss import EmbedLoss
from model.seg.loss.ohem_ce_loss import OhemCELoss
from model.seg.loss.focal... | 1,341 | 27.553191 | 100 | py |
torchcv | torchcv-master/model/seg/loss/embed_loss.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# Loss function for Semantic Segmentation.
import torch
import torch.nn as nn
class EmbedLoss(nn.Module):
def __init__(self, configer):
super(EmbedLoss, self).__init__()
self.num_classes = configer.get('data',... | 2,827 | 34.35 | 102 | py |
torchcv | torchcv-master/model/seg/loss/focal_ce_loss.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# Loss function for Semantic Segmentation.
import torch
import torch.nn as nn
import torch.nn.functional as F
class FocalCELoss(nn.Module):
def __init__(self, configer):
super(FocalCELoss, self).__init__()
sel... | 803 | 27.714286 | 66 | py |
torchcv | torchcv-master/model/seg/loss/encode_loss.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# Loss function for Semantic Segmentation.
import torch
import torch.nn as nn
import torch.nn.functional as F
class EncodeLoss(nn.Module):
def __init__(self, configer):
super(EncodeLoss, self).__init__()
self.... | 2,520 | 41.016667 | 117 | py |
torchcv | torchcv-master/model/seg/utils/gloreblock.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Xiangtai Li(lxtpku@pku.edu.cn)
# Pytorch Implementation of Glore moudle (CVPR 2019)
import torch
import torch.nn as nn
from torch.nn import BatchNorm1d, BatchNorm2d
class GloReModule(nn.Module):
def __init__(self, planes, ratio=4):
super(GloReModule,... | 2,322 | 26.987952 | 101 | py |
torchcv | torchcv-master/model/seg/utils/cgnl.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Xiangtai Li(lxtpku@pku.edu.cn)
# borrowed from offical repo: compact non-local block (nips 2018)
import torch
import torch.nn as nn
class CGNL(nn.Module):
"""CGNL block with dot production kernel for image classfication.
"""
def __init__(self, inplan... | 2,503 | 28.458824 | 81 | py |
torchcv | torchcv-master/model/seg/utils/cbam.py | import torch
import torch.nn as nn
class CBAM_Module(nn.Module):
def __init__(self, channels, reduction):
super(CBAM_Module, self).__init__()
self.avg_pool = nn.AdaptiveAvgPool2d(1)
self.max_pool = nn.AdaptiveMaxPool2d(1)
self.fc1 = nn.Conv2d(channels, channels // reduction, kernel... | 1,389 | 32.902439 | 84 | py |
torchcv | torchcv-master/model/seg/utils/apnb.py | import torch
from torch import nn
from torch.nn import functional as F
from lib.model.module_helper import ModuleHelper
class PSPModule(nn.Module):
# (1, 2, 3, 6)
def __init__(self, sizes=(1, 3, 6, 8), dimension=2):
super(PSPModule, self).__init__()
self.stages = nn.ModuleList([self._make_sta... | 6,041 | 40.383562 | 137 | py |
torchcv | torchcv-master/model/seg/utils/afnb.py | import torch
from torch import nn
from torch.nn import functional as F
from lib.model.module_helper import ModuleHelper
class PSPModule(nn.Module):
# (1, 2, 3, 6)
def __init__(self, sizes=(1, 3, 6, 8), dimension=2):
super(PSPModule, self).__init__()
self.stages = nn.ModuleList([self._make_st... | 6,737 | 42.470968 | 151 | py |
torchcv | torchcv-master/model/seg/utils/a2block.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Xiangtai Li(lxtpku@pku.edu.cn)
# Pytorch Implementation of A2-net(nips 2018)
import torch
import torch.nn as nn
class A2Block(nn.Module):
def __init__(self, inplane, plane):
super(A2Block, self).__init__()
self.down = nn.Conv2d(inplane, plane... | 1,203 | 27.666667 | 58 | py |
torchcv | torchcv-master/model/cls/nets/base_model.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
import torch
import torch.nn as nn
from lib.model.module_helper import ModuleHelper
from model.cls.loss.loss import BASE_LOSS_DICT
class BaseModel(nn.Module):
def __init__(self, configer):
super(BaseModel, self).__in... | 1,608 | 34.755556 | 96 | py |
torchcv | torchcv-master/model/cls/nets/cls_model.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# ResNet in PyTorch.
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from model.cls.loss.loss import BASE_LOSS_DICT
from model.cls.utils.metric_linear import LINEAR_DICT
from lib.model.module_... | 5,818 | 44.460938 | 117 | py |
torchcv | torchcv-master/model/cls/nets/distill_model.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# ResNet in PyTorch.
import torch
import torch.nn as nn
from model.cls.nets.cls_model import ClsModel
from model.cls.loss.loss import BASE_LOSS_DICT
class DistillModel(nn.Module):
def __init__(self, configer):
super(... | 2,566 | 47.433962 | 120 | py |
torchcv | torchcv-master/model/cls/loss/soft_ce_loss.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# Loss function for Image Classification.
import torch
import torch.nn as nn
import torch.nn.functional as F
class SoftCELoss(nn.Module):
def __init__(self, configer):
super(SoftCELoss, self).__init__()
self.p... | 1,114 | 36.166667 | 107 | py |
torchcv | torchcv-master/model/cls/loss/ce_loss.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# Loss function for Image Classification.
import torch
import torch.nn as nn
class CELoss(nn.Module):
def __init__(self, configer):
super(CELoss, self).__init__()
self.params_dict = dict()
if 'ce_loss'... | 937 | 33.740741 | 111 | py |
torchcv | torchcv-master/model/cls/loss/loss.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# Loss function for Image Classification.
import torch.nn as nn
from model.cls.loss import KLLoss, CELoss, HardTripletLoss, LiftedStructureLoss, SoftCELoss, MixupCELoss, MixupSoftCELoss
BASE_LOSS_DICT = dict(
ce_loss=0,
... | 1,373 | 28.869565 | 121 | py |
torchcv | torchcv-master/model/cls/loss/agent_center_loss.py | """
@desc: the variety of center loss, which use the class weight as the class center and normalize both the weight and feature,
in this way, the cos distance of weight and feature can be used as the supervised signal.
It's similar with torch.nn.CosineEmbeddingLoss, x_1 means weight_i, x_2 means feature_i... | 1,262 | 31.384615 | 124 | py |
torchcv | torchcv-master/model/cls/loss/mixup_ce_loss.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# Loss function for Image Classification.
import torch
import torch.nn as nn
class MixupCELoss(nn.Module):
def __init__(self, configer):
super(MixupCELoss, self).__init__()
self.params_dict = dict()
if... | 1,021 | 36.851852 | 111 | py |
torchcv | torchcv-master/model/cls/loss/mixup_soft_ce_loss.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# Loss function for Image Classification.
import torch
import torch.nn as nn
import torch.nn.functional as F
class MixupSoftCELoss(nn.Module):
def __init__(self, configer):
super(MixupSoftCELoss, self).__init__()
... | 1,408 | 41.69697 | 107 | py |
torchcv | torchcv-master/model/cls/loss/kl_loss.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# Loss function for Image Classification.
import torch
import torch.nn as nn
import torch.nn.functional as F
class KLLoss(nn.Module):
def __init__(self, configer=None):
super(KLLoss, self).__init__()
self.para... | 755 | 29.24 | 101 | py |
torchcv | torchcv-master/model/cls/loss/hard_triplet_loss.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# Loss function for Image Classification.
import torch
import torch.nn as nn
import torch.nn.functional as F
class HardTripletLoss(nn.Module):
"""Modified from Tong Xiao's open-reid (https://github.com/Cysu/open-reid).
Re... | 4,627 | 41.072727 | 91 | py |
torchcv | torchcv-master/model/cls/loss/center_loss.py | import torch
import torch.nn as nn
class CenterLoss(nn.Module):
def __init__(self, num_classes, feat_dim):
super(CenterLoss, self).__init__()
self.num_classes = num_classes
self.feat_dim = feat_dim
self.centers = nn.Parameter(torch.randn(self.num_classes, self.feat_dim))
def... | 1,506 | 34.046512 | 110 | py |
torchcv | torchcv-master/model/cls/loss/lifted_structure_loss.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# Loss function for Image Classification.
import torch
import torch.nn as nn
import torch.nn.functional as F
class LiftedStructureLoss(nn.Module):
def __init__(self, configer):
super(LiftedStructureLoss, self).__init_... | 1,177 | 37 | 116 | py |
torchcv | torchcv-master/model/cls/utils/metric_linear.py | import math
import torch
import torch.nn as nn
import torch.nn.functional as F
class Linear(nn.Linear):
def forward(self, input, *target):
return F.linear(input, self.weight, self.bias)
class NobiasLinear(nn.Linear):
def __init__(self, in_features, out_features):
super(NobiasLinear, self).... | 5,630 | 34.415094 | 121 | py |
torchcv | torchcv-master/model/det/nets/vgg16_ssd512.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# VGG300 SSD model
import torch
from torch import nn
import torch.nn.init as init
from model.det.layers.ssd_detection_layer import SSDDetectionLayer
from model.det.layers.ssd_target_generator import SSDTargetGenerator
from model.d... | 8,322 | 34.568376 | 101 | py |
torchcv | torchcv-master/model/det/nets/faster_rcnn.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
import torch
from torch import nn
from torch.nn import functional as F
from torchvision.models import vgg16
from model.det.layers.fr_roi_generator import FRROIGenerator
from model.det.layers.fr_roi_sampler import FRROISampler
from... | 9,360 | 43.57619 | 115 | py |
torchcv | torchcv-master/model/det/nets/lffdv2.py | # -*- coding: utf-8 -*-
"""
network description:
network structure:
"""
import torch
import torch.nn as nn
from model.det.layers.ssd_priorbox_layer import SSDPriorBoxLayer
from model.det.layers.ssd_target_generator import SSDTargetGenerator
from model.det.loss.loss import BASE_LOSS_DICT
from lib.tools.util.logger impo... | 11,514 | 47.179916 | 119 | py |
torchcv | torchcv-master/model/det/nets/darknet_yolov3.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
import torch
import torch.nn as nn
import torch.nn.functional as F
from collections import OrderedDict
from model.det.layers.yolo_detection_layer import YOLODetectionLayer
from lib.model.module_helper import ModuleHelper
class D... | 5,387 | 39.208955 | 111 | py |
torchcv | torchcv-master/model/det/nets/fpn_rcnn.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# The class of DenseASPPDetecNet
import torch
from torch import nn
from torch.nn import functional as F
from model.backbone.backbone_selector import BackboneSelector
from model.det.layers.fr_roi_generator import FRROIGenerator
fro... | 14,444 | 46.205882 | 118 | py |
torchcv | torchcv-master/model/det/nets/vgg16_ssd300.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# VGG300 SSD model
import torch
from torch import nn
import torch.nn.init as init
from model.det.layers.ssd_detection_layer import SSDDetectionLayer
from model.det.layers.ssd_target_generator import SSDTargetGenerator
from model.d... | 8,053 | 34.795556 | 101 | py |
torchcv | torchcv-master/model/det/layers/fr_priorbox_layer.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# Priorbox layer for Detection.
import math
import numpy as np
import torch
class FRPriorBoxLayer(object):
"""Compute prior boxes coordinates in center-offset form for each source feature map."""
def __init__(self, confi... | 2,711 | 41.375 | 118 | py |
torchcv | torchcv-master/model/det/layers/rpn_detection_layer.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
import torch
import torch.nn as nn
class RPNDetectionLayer(nn.Module):
def __init__(self, configer):
super(RPNDetectionLayer, self).__init__()
self.configer = configer
self.num_anchors = self.configer.... | 1,827 | 32.236364 | 98 | py |
torchcv | torchcv-master/model/det/layers/ssd_detection_layer.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
import torch
import torch.nn as nn
import torch.nn.functional as F
from model.det.layers.ssd_priorbox_layer import SSDPriorBoxLayer
class SSDDetectionLayer(nn.Module):
def __init__(self, configer):
super(SSDDetectio... | 2,975 | 39.767123 | 113 | py |
torchcv | torchcv-master/model/det/layers/fr_roi_sampler.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# ROI sample layer for Detection training.
import numpy as np
import torch
import random
from lib.tools.helper.mask_helper import MaskHelper
from lib.tools.helper.det_helper import DetHelper
class FRROISampler(object):
def _... | 6,304 | 50.680328 | 119 | py |
torchcv | torchcv-master/model/det/layers/ssd_priorbox_layer.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
import math
import numpy as np
import torch
from lib.tools.util.logger import Logger as Log
class SSDPriorBoxLayer(object):
"""Compute prior boxes coordinates in center-offset form for each source feature map."""
def __... | 4,144 | 46.643678 | 124 | py |
torchcv | torchcv-master/model/det/layers/fr_roi_generator.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# Priorbox layer for Detection.
import torch
from model.det.layers.fr_priorbox_layer import FRPriorBoxLayer
from lib.tools.util.logger import Logger as Log
try:
from lib.exts.ops.nms.nms_wrapper import nms
except ImportError:... | 7,085 | 42.207317 | 116 | py |
torchcv | torchcv-master/model/det/layers/yolo_detection_layer.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
import numpy as np
import torch
class YOLODetectionLayer(object):
"""Compute prior boxes coordinates in center-offset form for each source feature map."""
def __init__(self, configer):
self.configer = configer
... | 3,673 | 43.804878 | 115 | py |
torchcv | torchcv-master/model/det/layers/ssd_target_generator.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
import torch
from lib.tools.helper.det_helper import DetHelper
from model.det.layers.ssd_priorbox_layer import SSDPriorBoxLayer
class SSDTargetGenerator(object):
"""Compute prior boxes coordinates in center-offset form for e... | 2,880 | 45.467742 | 118 | py |
torchcv | torchcv-master/model/det/layers/rpn_target_assigner.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
import numpy as np
import torch
from lib.tools.helper.det_helper import DetHelper
from model.det.layers.fr_priorbox_layer import FRPriorBoxLayer
class RPNTargetAssigner(object):
"""Compute prior boxes coordinates in center-o... | 4,786 | 47.846939 | 109 | py |
torchcv | torchcv-master/model/det/loss/smooth_l1_loss.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
import torch
import torch.nn as nn
class SmoothL1Loss(nn.Module):
def __init__(self, configer):
super(SmoothL1Loss, self).__init__()
self.configer = configer
def forward(self, pred_locs, gt_locs, gt_label... | 1,414 | 37.243243 | 105 | py |
torchcv | torchcv-master/model/det/loss/ce_loss.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# Loss function for Semantic Segmentation.
import torch
import torch.nn as nn
import torch.nn.functional as F
class CELoss(nn.Module):
def __init__(self, configer=None):
super(CELoss, self).__init__()
self.con... | 1,066 | 35.793103 | 104 | py |
torchcv | torchcv-master/model/det/loss/loss.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# Loss function for Image Classification.
import torch.nn as nn
from model.det.loss.focal_loss import FocalLoss
from model.det.loss.multibox_loss import MultiBoxLoss
from model.det.loss.smooth_l1_loss import SmoothL1Loss
from mode... | 1,326 | 27.847826 | 106 | py |
torchcv | torchcv-master/model/det/loss/focal_loss.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
from lib.tools.util.logger import Logger as Log
class FocalLoss(nn.Module):
def __init__(self, configer):
super(F... | 3,073 | 31.702128 | 111 | py |
torchcv | torchcv-master/model/det/loss/region_loss.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
import math
import numpy as np
import torch
import torch.nn as nn
from lib.tools.helper.det_helper import DetHelper
class RegionLoss(nn.Module):
def __init__(self, configer):
super(RegionLoss, self).__init__()
... | 6,906 | 48.690647 | 128 | py |
torchcv | torchcv-master/model/det/loss/multibox_loss.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
import math
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
from lib.tools.helper.det_helper import DetHelper
from model.det.layers.ssd_target_generator imp... | 4,897 | 38.821138 | 139 | py |
torchcv | torchcv-master/model/pose/nets/cpm.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You (youansheng@gmail.com)
# Pose Net fot Parts Detection.
import torch.nn as nn
import torch.nn.functional as F
import torch
class CPM(nn.Module):
def __init__(self, configer):
super(CPM, self).__init__()
self.out_c = configer.get('ne... | 8,455 | 41.069652 | 98 | py |
torchcv | torchcv-master/model/pose/nets/open_pose.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
import torch
import torch.nn as nn
from model.pose.loss.loss import BASE_LOSS_DICT
from lib.model.module_helper import ModuleHelper
class OpenPose(nn.Module):
def __init__(self, configer):
super(OpenPose, self).__ini... | 7,731 | 40.347594 | 120 | py |
torchcv | torchcv-master/model/pose/layers/proposal_layer.py | #!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Donny You(youansheng@gmail.com)
# Make proposals that each consists of all possible keypoints.
import math
import numpy as np
import torch
from scipy.spatial.distance import cosine
from scipy.ndimage.filters import gaussian_filter
from torch.autograd import Varia... | 9,429 | 38.456067 | 112 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.