repo stringlengths 2 99 | file stringlengths 13 225 | code stringlengths 0 18.3M | file_length int64 0 18.3M | avg_line_length float64 0 1.36M | max_line_length int64 0 4.26M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
FPConv | FPConv-master/fpconv/pointnet2/setup.py | from setuptools import setup
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
setup(
name='pointnet2',
ext_modules=[
CUDAExtension('pointnet2_cuda', [
'src/pointnet2_api.cpp',
'src/ball_query.cpp',
'src/ball_query_gpu.cu',
... | 679 | 27.333333 | 67 | py |
FPConv | FPConv-master/fpconv/pointnet2/pointnet2_utils.py | import torch
from torch.autograd import Variable
from torch.autograd import Function
import torch.nn as nn
from typing import Tuple
import pointnet2_cuda as pointnet2
class FurthestPointSampling(Function):
@staticmethod
def forward(ctx, xyz: torch.Tensor, npoint: int) -> torch.Tensor:
"""
Use... | 12,424 | 33.803922 | 118 | py |
FPConv | FPConv-master/fpconv/pointnet2/__init__.py | 0 | 0 | 0 | py | |
FPConv | FPConv-master/fpconv/pointnet2/pointnet2_modules.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from . import pointnet2_utils
from . import pytorch_utils as pt_utils
from typing import List
class _PointnetSAModuleBase(nn.Module):
def __init__(self):
super().__init__()
self.npoint = None
self.groupers = None
... | 6,338 | 38.61875 | 119 | py |
FPConv | FPConv-master/fpconv/pointnet2/pytorch_utils.py | import torch.nn as nn
from typing import List, Tuple
class SharedMLP(nn.Sequential):
def __init__(
self,
args: List[int],
*,
bn: bool = False,
activation=nn.ReLU(inplace=True),
preact: bool = False,
first: bool = False,
... | 7,312 | 25.305755 | 95 | py |
FPConv | FPConv-master/datasets/s3dis_dataset.py | import os
import numpy as np
import sys
from torch.utils.data import Dataset
class S3DIS(Dataset):
def __init__(self, split='train', data_root='trainval_fullarea', num_point=4096, test_area=5, block_size=1.0, sample_rate=1.0, transform=None, if_normal=True):
super().__init__()
print('Initiating Da... | 7,008 | 42.265432 | 163 | py |
FPConv | FPConv-master/datasets/scannet_dataset_rgb_test.py | import pickle
import os
import sys
import numpy as np
import torch.utils.data as torch_data
class ScannetDatasetWholeScene_evaluation(torch_data.IterableDataset):
#prepare to give prediction on each points
def __init__(self, root=None, scene_list_dir=None, split='test', num_class=21, block_points=10240, with_n... | 8,118 | 42.417112 | 134 | py |
FPConv | FPConv-master/datasets/s3dis_dataset_test.py | import pickle
import os
import sys
import numpy as np
import torch.utils.data as torch_data
class S3DISWholeScene_evaluation(torch_data.IterableDataset):
# prepare to give prediction on each points
def __init__(self, root=None, split='test', test_area=5, num_class=13, block_points=8192, block_size=1.5, stride... | 8,454 | 38.143519 | 137 | py |
FPConv | FPConv-master/datasets/__init__.py | 0 | 0 | 0 | py | |
FPConv | FPConv-master/datasets/scannet_dataset_rgb.py | import pickle
import os
import sys
import numpy as np
import torch.utils.data as torch_data
class ScannetDataset(torch_data.Dataset):
def __init__(self, root=None, npoints=10240, split='train', with_dropout=False, with_norm=False, with_rgb=False, sample_rate=None):
super().__init__()
print(' ---- l... | 9,696 | 43.278539 | 135 | py |
FPConv | FPConv-master/utils/indoor3d_util.py | """
Modified from: https://github.com/charlesq34/pointnet/blob/master/sem_seg/indoor3d_util.py
"""
import numpy as np
import glob
import os
import sys
from plyfile import PlyData, PlyElement
# Shared class between two dataset
NYU_CLASS = [1, 2, 22, 9, 7, 5, 10, 6, 30, 8]
S3DIS_CLASS = [2, 1, 0, 5, 7, 8, 10, 9, 11... | 28,031 | 39.160458 | 134 | py |
FPConv | FPConv-master/utils/saver.py | import os
import torch
class Saver():
def __init__(self, save_dir, max_files=10):
if not os.path.exists(save_dir):
os.makedirs(save_dir)
self.log_list = []
self.save_dir = save_dir
self.max_files = max_files
self.saver_log_path = os.path.join(save_dir, '... | 1,784 | 34.7 | 116 | py |
FPConv | FPConv-master/utils/switchnorm.py | import torch
import torch.nn as nn
def convert_sn(module, momentum=0.95):
module_output = module
if isinstance(module, torch.nn.BatchNorm3d):
module_output = SwitchNorm3d(module.num_features)
elif isinstance(module, torch.nn.BatchNorm2d):
module_output = SwitchNorm2d(module.num_features)
... | 10,468 | 38.958015 | 104 | py |
FPConv | FPConv-master/utils/collect_indoor3d_data.py | """
https://github.com/charlesq34/pointnet/blob/master/sem_seg/collect_indoor3d_data.py
"""
import os, sys
import indoor3d_util
import argparse
import json
parser = argparse.ArgumentParser(description="Arg parser")
parser.add_argument("--config", type=str, default='../config.json')
args = parser.parse_args()
with ... | 1,424 | 31.386364 | 94 | py |
FPConv | FPConv-master/utils/__init__.py | 0 | 0 | 0 | py | |
FPConv | FPConv-master/utils/collect_scannet_pickle.py | """
Modified from https://github.com/DylanWusee/pointconv/blob/master/scannet/scannetv2_seg_dataset_rgb21c_pointid.py
"""
import os
import sys
import numpy as np
import pickle
from plyfile import PlyData, PlyElement
import json
import argparse
parser = argparse.ArgumentParser(description="Arg parser")
parser.add... | 3,860 | 39.642105 | 137 | py |
MPMQA | MPMQA-master/parser.py | # Copyright(c) 2022 Liang Zhang
# E-Mail: <zhangliang00@ruc.edu.cn>
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by app... | 4,900 | 57.345238 | 153 | py |
MPMQA | MPMQA-master/evaluate.py | # Copyright(c) 2022 Liang Zhang
# E-Mail: <zhangliang00@ruc.edu.cn>
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by app... | 21,617 | 42.761134 | 229 | py |
MPMQA | MPMQA-master/utils.py | # Copyright(c) 2022 Liang Zhang
# E-Mail: <zhangliang00@ruc.edu.cn>
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by app... | 8,686 | 35.965957 | 114 | py |
MPMQA | MPMQA-master/train.py | # Copyright(c) 2022 Liang Zhang
# E-Mail: <zhangliang00@ruc.edu.cn>
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by app... | 9,408 | 45.122549 | 192 | py |
MPMQA | MPMQA-master/detector/inference.py | import os
import numpy as np
from xml.etree.ElementInclude import default_loader
import cv2
import random
from tqdm import tqdm
from detectron2.utils.visualizer import Visualizer
from pkg_resources import DefaultProvider
from detectron2.engine import DefaultPredictor
from detectron2.evaluation import COCOEvaluator, inf... | 5,169 | 40.693548 | 153 | py |
MPMQA | MPMQA-master/detector/setup.py | #!/usr/bin/env python
import glob
import os
from setuptools import find_packages, setup
import torch
from torch.utils.cpp_extension import CUDA_HOME, CppExtension, CUDAExtension
torch_ver = [int(x) for x in torch.__version__.split(".")[:2]]
assert torch_ver >= [1, 3], "Requires PyTorch >= 1.3"
def get_extensions()... | 1,911 | 27.537313 | 100 | py |
MPMQA | MPMQA-master/detector/train_det.py | import logging
import os
from collections import OrderedDict
import torch
from torch.nn.parallel import DistributedDataParallel
import detectron2.utils.comm as comm
import bua.d2.modeling.roi_heads
from bua import add_config
from detectron2.checkpoint import DetectionCheckpointer, PeriodicCheckpointer
from detectron2.... | 7,622 | 35.3 | 99 | py |
MPMQA | MPMQA-master/detector/utils.py | import fitz
import cv2
import numpy as np
from PIL import Image, ImageTk, ImageDraw
from PIL import ImageFont
class UnionFindSet:
def __init__(self, max_n=100):
self.parent = [i for i in range(max_n)]
def union(self, i, j):
self.parent[i] = self.find_parent(i)
self.parent[j] = ... | 5,106 | 31.119497 | 203 | py |
MPMQA | MPMQA-master/detector/ROIFeatExtractor.py | import numpy as np
import cv2
import torch
import torch.nn as nn
from detectron2.config import get_cfg
from detectron2.modeling import build_model
from detectron2.structures import ImageList, Boxes
from detectron2.checkpoint import DetectionCheckpointer
import sys
sys.path.append('detector')
from bua.d2 import add_attr... | 4,030 | 37.390476 | 112 | py |
MPMQA | MPMQA-master/detector/evaluation/vg_evaluation.py | import os, io
import numpy as np
import copy
import torch
import logging
import pickle as cPickle
import itertools
import contextlib
from pycocotools.coco import COCO
from collections import OrderedDict
from fvcore.common.file_io import PathManager
import detectron2.utils.comm as comm
from detectron2.data import Meta... | 12,145 | 41.767606 | 101 | py |
MPMQA | MPMQA-master/detector/evaluation/__init__.py | from .vg_evaluation import VGEvaluator | 38 | 38 | 38 | py |
MPMQA | MPMQA-master/detector/evaluation/vg_eval.py | # --------------------------------------------------------
# Fast/er R-CNN
# Licensed under The MIT License [see LICENSE for details]
# Written by Bharath Hariharan
# --------------------------------------------------------
import numpy as np
def vg_eval(detpath,
gt_roidb,
image_index,
... | 5,261 | 33.392157 | 111 | py |
MPMQA | MPMQA-master/detector/dataset/balloon.py | import os
import json
import cv2
import numpy as np
from detectron2.structures import BoxMode
# import some common libraries
import numpy as np
import os, json, cv2, random
# import some common detectron2 utilities
from detectron2.utils.visualizer import Visualizer
from detectron2.data import MetadataCatalog, Dataset... | 2,193 | 31.746269 | 91 | py |
MPMQA | MPMQA-master/detector/dataset/vg.py | import os
import json
from unicodedata import category
import cv2
import numpy as np
from collections import defaultdict
from detectron2.structures import BoxMode
# import some common libraries
import numpy as np
import os, json, cv2, random
# import some common detectron2 utilities
from detectron2.utils.visualizer i... | 2,929 | 34.731707 | 93 | py |
MPMQA | MPMQA-master/detector/dataset/publaynet.py | import os
import json
from unicodedata import category
import cv2
import numpy as np
from collections import defaultdict
from detectron2.structures import BoxMode
# import some common libraries
import numpy as np
import os, json, cv2, random
# import some common detectron2 utilities
from detectron2.utils.visualizer i... | 2,450 | 34.014286 | 104 | py |
MPMQA | MPMQA-master/detector/bua/visual_genome.py | # -*- coding: utf-8 -*-
import contextlib
import io
import logging
import os
from fvcore.common.file_io import PathManager
from fvcore.common.timer import Timer
from detectron2.data import DatasetCatalog, MetadataCatalog
from detectron2.structures import BoxMode
logger = logging.getLogger(__name__)
"""
load json f... | 6,168 | 36.615854 | 98 | py |
MPMQA | MPMQA-master/detector/bua/__init__.py | from .d2 import add_attribute_config
from .caffe import add_bottom_up_attention_config
def add_config(args, cfg):
if args.mode == "caffe":
add_bottom_up_attention_config(cfg, True)
elif args.mode == "d2":
add_attribute_config(cfg)
else:
raise Exception("detection model not supported... | 373 | 33 | 79 | py |
MPMQA | MPMQA-master/detector/bua/d2/config.py | # -*- coding: utf-8 -*-
from detectron2.config import CfgNode as CN
"""
config for mode detectron2
"""
def add_attribute_config(cfg):
"""
Add config for attribute prediction.
"""
# Whether to have attribute prediction
cfg.MODEL.ATTRIBUTE_ON = False
# Maximum number of attributes per foregrou... | 1,952 | 33.263158 | 104 | py |
MPMQA | MPMQA-master/detector/bua/d2/__init__.py | from .dataloader.build_loader import (
build_detection_train_loader_with_attributes,
build_detection_test_loader_with_attributes,
)
from .modeling.roi_heads import AttributeRes5ROIHeads
from .. import visual_genome
from .config import add_attribute_config | 263 | 36.714286 | 53 | py |
MPMQA | MPMQA-master/detector/bua/d2/modeling/roi_heads.py |
import torch
from torch import nn
from torch.nn import functional as F
from detectron2.layers import ShapeSpec
from detectron2.modeling.roi_heads import (
build_box_head,
build_mask_head,
select_foreground_proposals,
ROI_HEADS_REGISTRY,
ROI_BOX_HEAD_REGISTRY,
ROIHeads,
Res5ROIHeads,
St... | 14,740 | 41.359195 | 198 | py |
MPMQA | MPMQA-master/detector/bua/d2/dataloader/build_loader.py |
import logging
import operator
import torch.utils.data
from detectron2.utils.comm import get_world_size
from detectron2.data import samplers
from detectron2.data.build import get_detection_dataset_dicts, worker_init_reset_seed, trivial_batch_collator
from detectron2.data.common import AspectRatioGroupedDataset, Datas... | 3,864 | 34.458716 | 109 | py |
MPMQA | MPMQA-master/detector/bua/d2/dataloader/dataset_mapper.py |
import copy
import logging
import numpy as np
import torch
from fvcore.common.file_io import PathManager
from PIL import Image
from detectron2.data import detection_utils as utils
from detectron2.data import transforms as T
from detectron2.data import DatasetMapper
from detectron2.structures import (
BitMasks,
... | 7,189 | 38.505495 | 100 | py |
MPMQA | MPMQA-master/detector/bua/d2/dataloader/__init__.py | from .build_loader import (
build_detection_train_loader_with_attributes,
build_detection_test_loader_with_attributes,
)
from ... import visual_genome | 158 | 30.8 | 49 | py |
MPMQA | MPMQA-master/detector/bua/caffe/config.py | # -*- coding: utf-8 -*-
from detectron2.config import CfgNode as CN
def add_bottom_up_attention_config(cfg, caffe=False):
"""
Add config for tridentnet.
"""
_C = cfg
_C.MODEL.BUA = CN()
_C.MODEL.BUA.CAFFE = caffe
_C.MODEL.BUA.RESNET_VERSION = 1
_C.MODEL.BUA.ATTRIBUTE_ON = False
... | 969 | 25.944444 | 104 | py |
MPMQA | MPMQA-master/detector/bua/caffe/__init__.py | from .config import add_bottom_up_attention_config
from .modeling.backbone import build_bua_resnet_backbone
from .modeling.rcnn import GeneralizedBUARCNN
from .modeling.roi_heads import BUACaffeRes5ROIHeads
from .modeling.rpn import StandardBUARPNHead, BUARPN | 259 | 51 | 56 | py |
MPMQA | MPMQA-master/detector/bua/caffe/postprocessing.py |
import numpy as np
import torch
from detectron2.structures import Instances
from modeling.layers.nms import nms # BC-compat
def extractor_postprocess(boxes, scores, features_pooled, input_per_image, extractor):
"""
Resize the output instances.
The input images are often resized when entering an object ... | 2,055 | 36.381818 | 87 | py |
MPMQA | MPMQA-master/detector/bua/caffe/modeling/box_regression.py |
import math
import torch
from detectron2.structures import Boxes
from typing import List, Tuple, Union
# Value for clamping large dw and dh predictions. The heuristic is that we clamp
# such that dw and dh are no larger than what would transform a 16px box into a
# 1000px box (based on a small anchor, 16px, and a typ... | 7,861 | 40.378947 | 99 | py |
MPMQA | MPMQA-master/detector/bua/caffe/modeling/fast_rcnn.py |
import logging
import numpy as np
import torch
from fvcore.nn import smooth_l1_loss
from torch import nn
from torch.nn import functional as F
from detectron2.layers import cat
from detectron2.structures import Instances
from detectron2.utils.events import get_event_storage
from detectron2.modeling.roi_heads import se... | 34,315 | 44.754667 | 184 | py |
MPMQA | MPMQA-master/detector/bua/caffe/modeling/rpn_outputs.py |
import itertools
import logging
import numpy as np
import torch
import torch.nn.functional as F
from fvcore.nn import smooth_l1_loss
from detectron2.layers import cat
from detectron2.structures import Instances, pairwise_iou
from detectron2.utils.events import get_event_storage
from detectron2.modeling.sampling impo... | 18,425 | 44.722084 | 147 | py |
MPMQA | MPMQA-master/detector/bua/caffe/modeling/rcnn.py |
import logging, os
import torch
from torch import nn
import torch.nn.functional as F
from detectron2.structures import ImageList
from detectron2.utils.logger import log_first_n
from detectron2.modeling.backbone import build_backbone
from detectron2.modeling.postprocessing import detector_postprocess
from detectron2... | 6,893 | 39.552941 | 98 | py |
MPMQA | MPMQA-master/detector/bua/caffe/modeling/rpn.py |
from typing import Dict, List
import torch
import torch.nn as nn
import torch.nn.functional as F
from detectron2.modeling import RPN_HEAD_REGISTRY
from detectron2.layers import ShapeSpec
from detectron2.modeling.proposal_generator import build_rpn_head
from detectron2.modeling.proposal_generator.build import PROPOS... | 7,700 | 42.022346 | 103 | py |
MPMQA | MPMQA-master/detector/bua/caffe/modeling/fast_rcnn_outputs.py | import torch
import torch.functional as F
from detectron2.layers import ShapeSpec, batched_nms, cat, cross_entropy, nonzero_tuple
from fvcore.nn import giou_loss, smooth_l1_loss
from detectron2.modeling.box_regression import Box2BoxTransform
from detectron2.structures import Boxes
class FastRCNNOutputs:
"""
An... | 7,315 | 44.440994 | 100 | py |
MPMQA | MPMQA-master/detector/bua/caffe/modeling/roi_heads.py | # -*- coding: utf-8 -*-
import numpy as np
import torch
import torch.nn as nn
from torch.nn import functional as F
from detectron2.utils.events import get_event_storage
from detectron2.modeling import ROI_HEADS_REGISTRY, ROIHeads
from detectron2.structures import Boxes, Instances, pairwise_iou
from detectron2.modelin... | 21,094 | 43.882979 | 196 | py |
MPMQA | MPMQA-master/detector/bua/caffe/modeling/backbone.py |
import fvcore.nn.weight_init as weight_init
from torch import nn
import torch.nn.functional as F
from detectron2.layers import Conv2d, FrozenBatchNorm2d, get_norm, BatchNorm2d
from detectron2.modeling import BACKBONE_REGISTRY, ResNet, make_stage
from detectron2.modeling.backbone.resnet import BottleneckBlock, DeformB... | 9,404 | 33.076087 | 116 | py |
MPMQA | MPMQA-master/detector/bua/caffe/modeling/__init__.py | from .backbone import build_bua_resnet_backbone
from .rcnn import GeneralizedBUARCNN
from .roi_heads import BUACaffeRes5ROIHeads
from .rpn import StandardBUARPNHead, BUARPN
| 173 | 33.8 | 47 | py |
MPMQA | MPMQA-master/detector/bua/caffe/modeling/layers/nms.py |
# from ._utils import _C
from bua.caffe.modeling import _C
from apex import amp
import torch
# Only valid with fp32 inputs - give AMP the hint
nms = amp.float_function(_C.nms)
# nms.__doc__ = """
# This function performs Non-maximum suppresion"""
# NOTE: In order to be consistent with bottom-up-attention, we nms c... | 2,551 | 32.578947 | 104 | py |
MPMQA | MPMQA-master/detector/bua/caffe/modeling/layers/wrappers.py | import math
import torch
from torch.nn.modules.utils import _ntuple
class Conv2dv2(torch.nn.Conv2d):
"""
A wrapper around :class:`torch.nn.Conv2d` to support more features.
"""
def __init__(self, *args, **kwargs):
"""
Extra keyword arguments supported in addition to those in `torch.nn.... | 1,228 | 31.342105 | 84 | py |
MPMQA | MPMQA-master/detector/bua/caffe/modeling/layers/csrc/__init__.py |
from .nms import SwapAlign2Nat, swap_align2nat
__all__ = [k for k in globals().keys() if not k.startswith("_")] | 113 | 27.5 | 64 | py |
MPMQA | MPMQA-master/detector/bua/caffe/dataloader/dataset_mapper.py |
import copy
import logging
import numpy as np
import torch
import cv2
from detectron2.data import detection_utils as utils
from detectron2.data import transforms as T
from .transform_gen import ResizeShortestEdge
from .detection_utils import annotations_to_instances
"""
This file contains the default mapping that'... | 6,394 | 37.757576 | 97 | py |
MPMQA | MPMQA-master/detector/bua/caffe/dataloader/detection_utils.py | # -*- coding: utf-8 -*-
"""
Common data processing utilities that are used in a
typical object detection data pipeline.
"""
import torch
from detectron2.structures import (
Boxes,
BoxMode,
Instances,
)
def transform_instance_annotations(
annotation, transforms, image_size, *, keypoint_hflip_indices=... | 2,923 | 33.4 | 95 | py |
MPMQA | MPMQA-master/detector/bua/caffe/dataloader/transform_gen.py | import cv2
import PIL.Image as Image
import numpy as np
from fvcore.transforms.transform import Transform
from detectron2.data.transforms import TransformGen
class ResizeTransform(Transform):
"""
Resize the image to a target size.
"""
def __init__(self, h, w, im_scale, pixel_mean):
"""
... | 2,471 | 29.518519 | 118 | py |
MPMQA | MPMQA-master/detector/bua/caffe/dataloader/__init__.py | from .dataset_mapper import DatasetMapper
__all__ = [k for k in globals().keys() if "builtin" not in k and not k.startswith("_")] | 130 | 42.666667 | 87 | py |
MPMQA | MPMQA-master/dataset/mqa_page_contrast.py | # Copyright(c) 2022 Liang Zhang
# E-Mail: <zhangliang00@ruc.edu.cn>
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by app... | 5,535 | 41.259542 | 135 | py |
MPMQA | MPMQA-master/dataset/const.py | # Copyright(c) 2022 Liang Zhang
# E-Mail: <zhangliang00@ruc.edu.cn>
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by app... | 1,182 | 23.142857 | 74 | py |
MPMQA | MPMQA-master/dataset/utils.py | # Copyright(c) 2022 Liang Zhang
# E-Mail: <zhangliang00@ruc.edu.cn>
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by app... | 2,864 | 30.483516 | 86 | py |
MPMQA | MPMQA-master/dataset/__init__.py | # Copyright(c) 2022 Liang Zhang
# E-Mail: <zhangliang00@ruc.edu.cn>
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by app... | 611 | 42.714286 | 74 | py |
MPMQA | MPMQA-master/dataset/mqa_dataset.py | # Copyright(c) 2022 Liang Zhang
# E-Mail: <zhangliang00@ruc.edu.cn>
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by app... | 11,026 | 42.413386 | 139 | py |
MPMQA | MPMQA-master/models/utils.py | # Copyright(c) 2022 Liang Zhang
# E-Mail: <zhangliang00@ruc.edu.cn>
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by app... | 4,078 | 32.434426 | 102 | py |
MPMQA | MPMQA-master/models/mqa_model.py | # Copyright(c) 2022 Liang Zhang
# E-Mail: <zhangliang00@ruc.edu.cn>
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by app... | 28,473 | 50.397112 | 159 | py |
MPMQA | MPMQA-master/scripts/compute_metrics.py | # Copyright(c) 2022 Liang Zhang
# E-Mail: <zhangliang00@ruc.edu.cn>
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by app... | 7,808 | 36.724638 | 161 | py |
MPMQA | MPMQA-master/scripts/__init__.py | # Copyright(c) 2022 Liang Zhang
# E-Mail: <zhangliang00@ruc.edu.cn>
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by app... | 611 | 42.714286 | 74 | py |
surface-distance | surface-distance-master/setup.py | # Copyright 2018 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or ... | 1,069 | 37.214286 | 76 | py |
surface-distance | surface-distance-master/__init__.py | # Copyright 2018 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or ... | 743 | 42.764706 | 77 | py |
surface-distance | surface-distance-master/surface_distance_test.py | # Copyright 2018 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or ... | 14,109 | 37.135135 | 80 | py |
surface-distance | surface-distance-master/surface_distance/lookup_tables.py | # Copyright 2018 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or ... | 22,758 | 55.755611 | 101 | py |
surface-distance | surface-distance-master/surface_distance/metrics.py | # Copyright 2018 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or ... | 18,367 | 40.369369 | 80 | py |
surface-distance | surface-distance-master/surface_distance/__init__.py | # Copyright 2018 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or ... | 754 | 40.944444 | 77 | py |
chatgpt-refusals | chatgpt-refusals-main/classical_model_results.py | import argparse
import matplotlib.pyplot as plt
import numpy as np
from sklearn.ensemble import RandomForestClassifier
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score
import data_processing
def plot_ngram_coeffi... | 5,598 | 41.097744 | 115 | py |
chatgpt-refusals | chatgpt-refusals-main/data_processing.py | import json
import pandas as pd
from sklearn.model_selection import train_test_split
def preprocess_data(file_path, text_source):
with open(file_path, 'r') as file:
data = json.load(file)
df = pd.DataFrame(data)
# Filter out unwanted classes
df = df.loc[~df['tone'].isin(['incoherent', 'dontkno... | 883 | 31.740741 | 98 | py |
chatgpt-refusals | chatgpt-refusals-main/bert_results.py | import os
import torch
from transformers import BertTokenizerFast, BertForSequenceClassification, Trainer, TrainingArguments
import data_processing
class TextDataset(torch.utils.data.Dataset):
def __init__(self, encodings, labels):
self.encodings = encodings
self.labels = labels
def __getitem... | 2,872 | 35.367089 | 101 | py |
SHIPS | SHIPS-master/PSFfitting.py | ############################
# Date: 06/04/2020
# Title: PSF-fitting script for SHIPS
# Author: J. Bodensteiner (2019). Edits: A. Rainot (2020)
# Description: Use this script to extract a spectrum of sources in IRDIS images with the SHIPS pipeline.
# VIP version: 0.9.11 (Rainot edit.)
# Python version: 3 ONLY
#########... | 15,962 | 39.10804 | 106 | py |
SHIPS | SHIPS-master/ships_ifs.py | ############################
# Date: 07/04/2020
# Title: Running script for SHIPS for IFS data
# Description: Use this script to run SHIPS for IFS data. In this script you'll find all the necessary parameters to run SHIPS. ONLY SPHERE-DC DATA FOR NOW. VIP is used.
# VIP version: 0.9.11 (Rainot edit.)
# Python version: ... | 29,887 | 46.067717 | 361 | py |
SHIPS | SHIPS-master/ships_irdis.py | ############################
# Date: 07/04/2020
# Title: Running script for SHIPS for IRDIS data
# Description: Use this script to run SHIPS for IRDIS data. In this script you'll find all the necessary parameters to run SHIPS. ONLY SPHERE-DC DATA FOR NOW. VIP is used.
# VIP version: 0.9.11 (Rainot edit.)
# Python versi... | 31,489 | 51.222222 | 393 | py |
SHIPS | SHIPS-master/__init__.py | from __future__ import (absolute_import)
# import vip
# from vip.phot.fakecomp import inject_fcs_cube, inject_fc_frame, psf_norm
__version__ = "1.0.0"
print("------------------------------------")
print(" _____ _ _ _____ _____ _____ ")
print(" / ____| | | |_ _| __ \ / ____|")
print(" | (___ | |__| | | |... | 808 | 35.772727 | 90 | py |
21cmVAE | 21cmVAE-main/VeryAccurateEmulator/emulator.py | import h5py
import tensorflow as tf
from tqdm.keras import TqdmCallback
import numpy as np
from VeryAccurateEmulator import __path__
import VeryAccurateEmulator.preprocess as pp
PATH = __path__[0] + "/"
def _gen_model(in_dim, hidden_dims, out_dim, activation_func, name=None):
"""
Generate a new keras model.... | 26,244 | 30.132859 | 79 | py |
21cmVAE | 21cmVAE-main/VeryAccurateEmulator/__init__.py | __version__ = "3.1.0"
__author__ = "Christian Hellum Bye"
from pathlib import Path
HERE = __file__[: -len("__init__.py")]
if not Path(HERE + "dataset_21cmVAE.h5").exists():
import requests
print("Downloading dataset.")
r = requests.get(
"https://zenodo.org/record/5084114/files/dataset_21cmVAE.h5... | 508 | 24.45 | 79 | py |
21cmVAE | 21cmVAE-main/VeryAccurateEmulator/preprocess.py | import numpy as np
def preproc(signal: np.ndarray, signal_train: np.ndarray) -> np.ndarray:
"""
Preprocess all the signals in a dataset.
Parameters
----------
signal : np.ndarray
Array of signals to preprocess.
signal_train : np.ndarray
Array of the training set signals.
... | 3,677 | 32.135135 | 78 | py |
21cmVAE | 21cmVAE-main/tests/test_emulator.py | import h5py
import numpy as np
import tensorflow as tf
from VeryAccurateEmulator import emulator, __path__
import VeryAccurateEmulator.preprocess as pp
FILE = __path__[0] + "/dataset_21cmVAE.h5"
with h5py.File(FILE, "r") as hf:
signal_train = hf["signal_train"][:]
def test_gen_model():
in_dim = 7
hidden_... | 3,644 | 30.973684 | 79 | py |
21cmVAE | 21cmVAE-main/tests/test_preprocess.py | import h5py
import numpy as np
from VeryAccurateEmulator import __path__
import VeryAccurateEmulator.preprocess as pp
FILE = __path__[0] + "/dataset_21cmVAE.h5"
with h5py.File(FILE, "r") as hf:
signal_train = hf["signal_train"][:]
par_train = hf["par_train"][:]
def test_proc():
proc_signal = pp.preproc(s... | 834 | 29.925926 | 60 | py |
THULAC-Python | THULAC-Python-master/setup.py | #coding: utf-8
from setuptools import setup, find_packages
setup(
name = 'thulac',
# packages = ['thulac_test'], # this must be the same as the name above
version = '0.1.1',
description = 'A efficient Chinese text segmentation tool',
author = 'thunlp',
url = 'https://github.com/thunlp/THULAC-Python', # use... | 1,072 | 38.740741 | 110 | py |
THULAC-Python | THULAC-Python-master/demo.py | #coding:utf-8
import thulac
thu1 = thulac.thulac(seg_only=True, model_path="请查看README下载相关模型放到thulac根目录或在这里写路径") #设置模式为行分词模式
a = thu1.cut("我爱北京天安门")
print(a)
| 161 | 17 | 96 | py |
THULAC-Python | THULAC-Python-master/thulac/__main__.py | import sys
import thulac
seg_only = False
if(len(sys.argv) >= 4 and sys.argv[3] == "-seg_only"):
seg_only = True
lac = thulac.thulac(seg_only=seg_only)
lac.cut_f(sys.argv[1], sys.argv[2]) | 190 | 20.222222 | 54 | py |
THULAC-Python | THULAC-Python-master/thulac/__init__.py | #__coding:utf-8
from .character.CBModel import CBModel
from .character.CBNGramFeature import CBNGramFeature
from .character.CBTaggingDecoder import CBTaggingDecoder
from .manage.Preprocesser import Preprocesser
from .manage.Postprocesser import Postprocesser
from .manage.Filter import Filter
from .manage.TimeWord impor... | 9,925 | 37.773438 | 146 | py |
THULAC-Python | THULAC-Python-master/thulac/character/CBTaggingDecoder.py | #coding = utf-8
from .CBModel import CBModel
from .CBNGramFeature import CBNGramFeature
from ..base.Node import Node
from ..base.Dat import Dat
from ..base.WordWithTag import WordWithTag
from ..base.AlphaBeta import AlphaBeta
import time
import array
class CBTaggingDecoder:
def __init__(self):
self.separat... | 7,614 | 37.852041 | 184 | py |
THULAC-Python | THULAC-Python-master/thulac/character/CBNGramFeature.py | #coding = utf-8
# from ..base import Dat
import time
class CBNGramFeature:
SENTENCE_BOUNDARY = '#'
SEPERATOR = "_"
maxLength = 0
uniBases = []
biBases = []
datSize = []
dat = []
values = {}
def __init__(self, myDat, model):
self.SEPERATOR = ' '
self.datSize = myDat... | 3,995 | 37.057143 | 132 | py |
THULAC-Python | THULAC-Python-master/thulac/character/CBModel.py | import struct
import binascii
import codecs
class CBModel:
DEC = 1000
l_size = 0
f_size = 0
ll_weights = []
fl_weights = []
ave_ll_weights = []
ave_fl_weights = []
def reset_ave_weights(self):
self.ave_ll_weights = [0.0 for i in range(l * l)]
self.ave_fl_weights = [0.0 ... | 2,094 | 30.742424 | 121 | py |
THULAC-Python | THULAC-Python-master/thulac/character/__init__.py | 0 | 0 | 0 | py | |
THULAC-Python | THULAC-Python-master/thulac/base/compatibility.py | #coding: utf-8
import sys
from ctypes import c_char, c_char_p, cast, POINTER, c_wchar_p
'''本模块用于兼容python2和python3,所有函数都会返回适用于对应版本的处理函数'''
isPython2 = sys.version_info[0] == 2
def decodeGenerator():
'''兼容2的decode函数'''
if(isPython2):
return lambda s: s.decode('utf-8')
return lambda s: s
def encodeGe... | 911 | 23 | 61 | py |
THULAC-Python | THULAC-Python-master/thulac/base/AlphaBeta.py | import time
class AlphaBeta:
value = 0
nodeId = 0
labelId = 0
def __init__(self):
self.value = 0
self.nodeId = -2
self.labelId = 0
def dbDecode(self, l_size, llWeights, nodeCount, nodes, values, alphas, result, preLabels, allowedLabelLists):
nodeId = 0
pNod... | 2,117 | 28.830986 | 114 | py |
THULAC-Python | THULAC-Python-master/thulac/base/Node.py | class Node:
type = 0
predecessors = []
successors = []
| 67 | 12.6 | 21 | py |
THULAC-Python | THULAC-Python-master/thulac/base/Dat.py | #coding: utf-8
import struct
import os
import functools
import sys
class Dat:
def __init__(self, filename=None, datSize=None, oldDat=None):
if(filename):
try:
inputfile = open(filename, "rb")
except:
print("open file %s failed" % filename)
... | 7,965 | 30.239216 | 122 | py |
THULAC-Python | THULAC-Python-master/thulac/base/__init__.py | 0 | 0 | 0 | py | |
THULAC-Python | THULAC-Python-master/thulac/base/WordWithTag.py | class WordWithTag:
word = ""
tag = ""
separator = ''
def __init__(self, separator):
self.separator = separator
| 137 | 14.333333 | 34 | py |
THULAC-Python | THULAC-Python-master/thulac/manage/verbword.py | from ..base.Dat import Dat
class VerbWord():
def __init__(self, filename1, filename2):
self.__vmDat = Dat(filename=filename1)
self.__vdDat = Dat(filename=filename2)
self.__tagV = 'v'
def adjustTag(self, sentence):
if(not self.__vmDat or not self.__vdDat):
return
for i in range(len(sentence)-1):
if(s... | 557 | 26.9 | 75 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.