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 |
|---|---|---|---|---|---|---|
tdqn | tdqn-master/drrn/env.py | from os.path import basename
from jericho import *
from jericho.template_action_generator import TemplateActionGenerator
from jericho.util import *
from jericho.defines import *
import redis
def load_vocab_rev(env):
vocab = {i+2: str(v) for i, v in enumerate(env.get_dictionary())}
vocab[0] = ' '
vocab[1] =... | 3,819 | 36.087379 | 98 | py |
Image-Adaptive-YOLO | Image-Adaptive-YOLO-main/filters_lowlight.py | import tensorflow as tf
import numpy as np
import tensorflow.contrib.layers as ly
from util_filters import lrelu, rgb2lum, tanh_range, lerp
import cv2
import math
class Filter:
def __init__(self, net, cfg):
self.cfg = cfg
# self.height, self.width, self.channels = list(map(int, net.get_shape()[1:]))
#... | 20,316 | 34.64386 | 131 | py |
Image-Adaptive-YOLO | Image-Adaptive-YOLO-main/train_lowlight.py | #! /usr/bin/env python
# coding=utf-8
import os
import time
import shutil
import numpy as np
import tensorflow as tf
import core.utils as utils
from tqdm import tqdm
from core.dataset_lowlight import Dataset
from core.yolov3_lowlight import YOLOV3
from core.config_lowlight import cfg
from core.config_lowlight import ... | 12,834 | 48.941634 | 134 | py |
Image-Adaptive-YOLO | Image-Adaptive-YOLO-main/util_filters.py | import math
import cv2
import tensorflow as tf
import os
import sys
'''
output states:
0: has rewards?
1: stopped?
2: num steps
3:
'''
STATE_REWARD_DIM = 0
STATE_STOPPED_DIM = 1
STATE_STEP_DIM = 2
STATE_DROPOUT_BEGIN = 3
def get_expert_file_path(expert):
expert_path = 'data/artists/fk_%s/' % expert
... | 16,568 | 27.035533 | 120 | py |
Image-Adaptive-YOLO | Image-Adaptive-YOLO-main/freeze_graph.py | #! /usr/bin/env python
# coding=utf-8
import tensorflow as tf
from core.yolov3 import YOLOV3
pb_file = "./yolov3_coco.pb"
ckpt_file = "./checkpoint/yolov3_coco_demo.ckpt"
output_node_names = ["input/input_data", "pred_sbbox/concat_2", "pred_mbbox/concat_2", "pred_lbbox/concat_2"]
with tf.name_scope('input'):
i... | 929 | 27.181818 | 109 | py |
Image-Adaptive-YOLO | Image-Adaptive-YOLO-main/evaluate.py | #! /usr/bin/env python
# coding=utf-8
import cv2
import os
import shutil
import numpy as np
import tensorflow as tf
import core.utils as utils
from core.config import cfg
from core.yolov3 import YOLOV3
from core.config import args
import random
import math
import subprocess as sub
import time
from filters import *
ex... | 11,108 | 42.73622 | 170 | py |
Image-Adaptive-YOLO | Image-Adaptive-YOLO-main/from_darknet_weights_to_ckpt.py | import tensorflow as tf
from core.yolov3 import YOLOV3
iput_size = 416
darknet_weights = '<your yolov3.weights' path>'
ckpt_file = './checkpoint/yolov3_coco.ckpt'
def load_weights(var_list, weights_file):
"""
Loads and converts pre-trained weights.
:param var_list: list of network variables.
:param we... | 2,972 | 38.118421 | 106 | py |
Image-Adaptive-YOLO | Image-Adaptive-YOLO-main/evaluate_lowlight.py | #! /usr/bin/env python
# coding=utf-8
import cv2
import os
import shutil
import numpy as np
import tensorflow as tf
import core.utils as utils
from core.config_lowlight import cfg
from core.yolov3_lowlight import YOLOV3
from core.config_lowlight import args
import random
import time
exp_folder = os.path.join(args.exp... | 7,446 | 42.046243 | 113 | py |
Image-Adaptive-YOLO | Image-Adaptive-YOLO-main/from_darknet_weights_to_pb.py | import tensorflow as tf
from core.yolov3 import YOLOV3
from from_darknet_weights_to_ckpt import load_weights
input_size = 416
darknet_weights = '<your darknet weights file path>'
pb_file = './yolov3.pb'
output_node_names = ["input/input_data", "pred_sbbox/concat_2", "pred_mbbox/concat_2", "pred_lbbox/concat_2"]
with ... | 983 | 35.444444 | 109 | py |
Image-Adaptive-YOLO | Image-Adaptive-YOLO-main/filters.py | import tensorflow as tf
import numpy as np
import tensorflow.contrib.layers as ly
from util_filters import lrelu, rgb2lum, tanh_range, lerp
import cv2
import math
class Filter:
def __init__(self, net, cfg):
self.cfg = cfg
# self.height, self.width, self.channels = list(map(int, net.get_shape()[1:]))
#... | 23,809 | 35.295732 | 131 | py |
Image-Adaptive-YOLO | Image-Adaptive-YOLO-main/train.py | #! /usr/bin/env python
# coding=utf-8
import os
import time
import shutil
import numpy as np
import tensorflow as tf
import core.utils as utils
from tqdm import tqdm
from core.dataset import Dataset
from core.yolov3 import YOLOV3
from core.config import cfg
from core.config import args
import random
import cv2
import... | 15,293 | 46.203704 | 115 | py |
Image-Adaptive-YOLO | Image-Adaptive-YOLO-main/convert_weight.py | #! /usr/bin/env python
# coding=utf-8
import argparse
import tensorflow as tf
from core.yolov3 import YOLOV3
from core.config import cfg
import os
os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID"
os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
parser = argparse.ArgumentParser()
parser.add_argument("--train_from_coco", dest... | 3,176 | 34.3 | 109 | py |
Image-Adaptive-YOLO | Image-Adaptive-YOLO-main/core/data_make.py | import numpy as np
import os
import cv2
import math
from numba import jit
import random
# only use the image including the labeled instance objects for training
def load_annotations(annot_path):
print(annot_path)
with open(annot_path, 'r') as f:
txt = f.readlines()
annotations = [line.strip() f... | 2,434 | 33.295775 | 97 | py |
Image-Adaptive-YOLO | Image-Adaptive-YOLO-main/core/dataset_lowlight.py | #! /usr/bin/env python
# coding=utf-8
import os
import cv2
import random
import numpy as np
import tensorflow as tf
import core.utils as utils
from core.config_lowlight import cfg
class Dataset(object):
"""implement Dataset here"""
def __init__(self, dataset_type):
self.annot_path = cfg.TRAIN.ANNO... | 11,016 | 42.203922 | 127 | py |
Image-Adaptive-YOLO | Image-Adaptive-YOLO-main/core/config_lowlight.py | #! /usr/bin/env python
# coding=utf-8
from easydict import EasyDict as edict
from filters_lowlight import *
import argparse
parser = argparse.ArgumentParser(description='')
parser.add_argument('--exp_num', dest='exp_num', type=str, default='58', help='current experiment number')
parser.add_argument('--epoch_first_stage... | 5,327 | 37.057143 | 187 | py |
Image-Adaptive-YOLO | Image-Adaptive-YOLO-main/core/utils.py | #! /usr/bin/env python
# coding=utf-8
import cv2
import random
import colorsys
import numpy as np
import tensorflow as tf
def read_class_names(class_file_name):
'''loads class name from a file'''
names = {}
with open(class_file_name, 'r') as data:
for ID, name in enumerate(data):
name... | 8,188 | 33.263598 | 106 | py |
Image-Adaptive-YOLO | Image-Adaptive-YOLO-main/core/dataset.py | #! /usr/bin/env python
# coding=utf-8
import os
import cv2
import random
import numpy as np
import tensorflow as tf
import core.utils as utils
from core.config import cfg
from core.config import args
import time
import math
from numba import jit
class Dataset(object):
"""implement Dataset here"""
def __in... | 15,547 | 43.806916 | 121 | py |
Image-Adaptive-YOLO | Image-Adaptive-YOLO-main/core/backbone.py | #! /usr/bin/env python
# coding=utf-8
import core.common as common
import tensorflow as tf
def darknet53(input_data, trainable):
with tf.variable_scope('darknet'):
input_data = common.convolutional(input_data, filters_shape=(3, 3, 3, 32), trainable=trainable, name='conv0')
input_data = commo... | 2,051 | 42.659574 | 123 | py |
Image-Adaptive-YOLO | Image-Adaptive-YOLO-main/core/config.py | #! /usr/bin/env python
# coding=utf-8
from easydict import EasyDict as edict
from filters import *
import argparse
parser = argparse.ArgumentParser(description='')
parser.add_argument('--exp_num', dest='exp_num', type=str, default='101', help='current experiment number')
parser.add_argument('--epoch_first_stage', des... | 6,043 | 38.763158 | 179 | py |
Image-Adaptive-YOLO | Image-Adaptive-YOLO-main/core/common.py | #! /usr/bin/env python
# coding=utf-8
import tensorflow as tf
import tensorflow.contrib.layers as ly
from util_filters import *
def extract_parameters(net, cfg, trainable):
output_dim = cfg.num_filter_parameters
# net = net - 0.5
min_feature_map_size = 4
print('extract_parameters CNN:')
channels... | 6,331 | 41.783784 | 119 | py |
Image-Adaptive-YOLO | Image-Adaptive-YOLO-main/core/yolov3_lowlight.py | #! /usr/bin/env python
# coding=utf-8
import numpy as np
import tensorflow as tf
import core.utils as utils
import core.common as common
import core.backbone as backbone
from core.config_lowlight import cfg
class YOLOV3(object):
"""Implement tensoflow yolov3 here"""
def __init__(self, input_data, trainable,... | 13,856 | 47.114583 | 147 | py |
Image-Adaptive-YOLO | Image-Adaptive-YOLO-main/core/__init__.py | 0 | 0 | 0 | py | |
Image-Adaptive-YOLO | Image-Adaptive-YOLO-main/core/yolov3.py | #! /usr/bin/env python
# coding=utf-8
import numpy as np
import tensorflow as tf
import core.utils as utils
import core.common as common
import core.backbone as backbone
from core.config import cfg
import time
class YOLOV3(object):
"""Implement tensoflow yolov3 here"""
def __init__(self, input_data, trainab... | 14,179 | 47.561644 | 123 | py |
Image-Adaptive-YOLO | Image-Adaptive-YOLO-main/scripts/voc_annotation.py | import os
import argparse
import xml.etree.ElementTree as ET
def convert_voc_annotation(data_path, data_type, anno_path, use_difficult_bbox=False):
# classes = ['aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus',
# 'car', 'cat', 'chair', 'cow', 'diningtable', 'dog', 'horse',
# '... | 3,104 | 49.901639 | 143 | py |
Image-Adaptive-YOLO | Image-Adaptive-YOLO-main/scripts/show_bboxes.py | #! /usr/bin/env python
# coding=utf-8
import cv2
import numpy as np
from PIL import Image
import math
ID = 60
label_txt = ""
image_info = open(label_txt).readlines()[ID].split()
image_path = image_info[0]
image = cv2.imread(image_path)
for bbox in image_info[1:]:
bbox = bbox.split(",")
image = cv2.rectangle... | 5,333 | 23.925234 | 97 | py |
Image-Adaptive-YOLO | Image-Adaptive-YOLO-main/scripts/voc_RTTS.py | import os
import argparse
import xml.etree.ElementTree as ET
def convert_voc_annotation(data_path, data_type, anno_path, use_difficult_bbox=True):
# classes = ['aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus',
# 'car', 'cat', 'chair', 'cow', 'diningtable', 'dog', 'horse',
# 'm... | 2,759 | 50.111111 | 136 | py |
Image-Adaptive-YOLO | Image-Adaptive-YOLO-main/experiments/exp_101/mAP/main.py | import glob
import json
import os
import shutil
import operator
import sys
import argparse
MINOVERLAP = 0.5 # default value (defined in the PASCAL VOC2012 challenge)
parser = argparse.ArgumentParser()
parser.add_argument('-na', '--no-animation', help="no animation is shown.", action="store_true")
parser.add_argument(... | 27,755 | 34.768041 | 125 | py |
Image-Adaptive-YOLO | Image-Adaptive-YOLO-main/experiments_lowlight/exp_58/mAP/main.py | import glob
import json
import os
import shutil
import operator
import sys
import argparse
MINOVERLAP = 0.5 # default value (defined in the PASCAL VOC2012 challenge)
parser = argparse.ArgumentParser()
parser.add_argument('-na', '--no-animation', help="no animation is shown.", action="store_true")
parser.add_argument(... | 27,755 | 34.768041 | 125 | py |
RioGNN | RioGNN-main/train.py | import os
import argparse
from time import localtime, strftime, time
from sklearn.model_selection import train_test_split
from utils.utils import *
from model.model import *
from model.layers import *
from model.graphsage import *
from RL.rl_model import *
"""
Training and testing RIO-GNN
Paper: Reinforced Nei... | 8,973 | 45.497409 | 120 | py |
RioGNN | RioGNN-main/RL/rl_model.py | from operator import itemgetter
from RL.actor_critic import *
"""
RL Forest.
Paper: Reinforced Neighborhood Selection Guided Multi-Relational Graph Neural Networks
Source: https://github.com/safe-graph/RioGNN
"""
class RLForest:
def __init__(self, width_rl, height_rl, device, LR, GAMMA, stop_num, r_... | 10,498 | 41.506073 | 116 | py |
RioGNN | RioGNN-main/RL/actor_critic.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
"""
Actor-Critic implementations
Paper: Actor-Critic Algorithms
Source: https://github.com/llSourcell/actor_critic
"""
# torch.backends.cudnn.enabled = False # Non-deterministic algorithm
class PGNetwork(nn.Module):
... | 4,388 | 32.761538 | 105 | py |
RioGNN | RioGNN-main/utils/data_process.py | from utils.utils import sparse_to_adjlist
from scipy.io import loadmat
"""
Read data and save the adjacency matrices to adjacency lists
Paper: Reinforced Neighborhood Selection Guided Multi-Relational Graph Neural Networks
Source: https://github.com/safe-graph/RioGNN
"""
if __name__ == "__main__":
prefix = './d... | 1,642 | 30.596154 | 87 | py |
RioGNN | RioGNN-main/utils/utils.py | import pickle
import random as rd
import numpy as np
import scipy.sparse as sp
from scipy.io import loadmat
import copy as cp
from sklearn.metrics import f1_score, accuracy_score, recall_score, roc_auc_score, average_precision_score
from collections import defaultdict
"""
Utility functions to handle data and evalu... | 11,237 | 38.293706 | 114 | py |
RioGNN | RioGNN-main/model/graphsage.py | import torch
import torch.nn as nn
from torch.nn import init
import torch.nn.functional as F
from torch.autograd import Variable
import random
"""
GraphSAGE implementations
Paper: Inductive Representation Learning on Large Graphs
Source: https://github.com/williamleif/graphsage-simple/
"""
class GraphSage(nn.Mod... | 4,341 | 27.946667 | 101 | py |
RioGNN | RioGNN-main/model/model.py | import torch
import torch.nn as nn
from torch.nn import init
from torch.autograd import Variable
"""
Rio-GNN Models
Paper: Reinforced Neighborhood Selection Guided Multi-Relational Graph Neural Networks
Source: https://github.com/safe-graph/RioGNN
"""
class OneLayerRio(nn.Module):
"""
The Rio-GNN model in one l... | 3,611 | 34.067961 | 91 | py |
RioGNN | RioGNN-main/model/layers.py | import sys
import torch
import torch.nn as nn
from torch.nn import init
import torch.nn.functional as F
from torch.autograd import Variable
from operator import itemgetter
import math
from RL.rl_model import *
"""
Rio-GNN Layers
Paper: Reinforced Neighborhood Selection Guided Multi-Relational Graph Neural Netw... | 18,857 | 42.855814 | 119 | py |
EuclidEmulator | EuclidEmulator-master/wrapper2/e2py/ee_observables.py | """
ee_observables.py
EuclidEmulator submodule for actual emulation of cosmological observables.
"""
# This file is part of EuclidEmulator
# Copyright (c) 2018-2020 Mischa Knabenhans
#
# EuclidEmulator is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as pu... | 12,678 | 38.746082 | 90 | py |
EuclidEmulator | EuclidEmulator-master/wrapper2/e2py/ee_input.py | """
ee_input.py
EuclidEmulator submodule containing functions related to argument parsing.
"""
# This file is part of EuclidEmulator
# Copyright (c) 2018-2020 Mischa Knabenhans
#
# EuclidEmulator is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as publishe... | 7,734 | 34.645161 | 88 | py |
EuclidEmulator | EuclidEmulator-master/wrapper2/e2py/__init__.py | # This file is part of EuclidEmulator
# Copyright (c) 2018-2020 Mischa Knabenhans
#
# EuclidEmulator is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# at your option) any l... | 1,090 | 40.961538 | 82 | py |
EuclidEmulator | EuclidEmulator-master/wrapper2/e2py/_ee_lens.py | """
ee_lens.py
EuclidEmulator submodule for computation of cosmological lensing quantities.
REMARK: The geometry of the Universe is fixed to be flat (i.e.
Omega_curvature = 1) and the radiation energy density
is set to Om_rad = 4.183709411969527e-5/(h*h). These
values were ... | 3,699 | 35.27451 | 80 | py |
EuclidEmulator | EuclidEmulator-master/wrapper2/e2py/_internal/_ee_aux.py | """
_ee_aux.py
EuclidEmulator submodule for auxiliary functions.
"""
# This file is part of EuclidEmulator
# Copyright (c) 2018-2020 Mischa Knabenhans
#
# EuclidEmulator is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software ... | 4,029 | 29.074627 | 81 | py |
EuclidEmulator | EuclidEmulator-master/wrapper2/e2py/_internal/_ee_background.py | """
ee_background.py
EuclidEmulator submodule for computation of cosmological background quantities.
REMARK: The geometry of the Universe is fixed to be flat (i.e.
Omega_curvature = 1) and the radiation energy density
is set to Om_rad = 4.183709411969527e-5/(h*h). These
val... | 3,814 | 39.585106 | 83 | py |
EuclidEmulator | EuclidEmulator-master/wrapper2/e2py/_internal/_ee_cosmoconv.py | """
ee_cosmoconv.py
EuclidEmulator submodule for converting cosmological quantities.
REMARK: The geometry of the Universe is fixed to be flat (i.e.
Omega_curvature = 1) and the radiation energy density
is set to Om_rad = 4.183709411969527e-5/(h*h). These
values were assumed... | 7,394 | 33.078341 | 83 | py |
EuclidEmulator | EuclidEmulator-master/wrapper2/e2py/_internal/__init__.py | import _ee_cosmoconv as _cc
import _ee_background as _bg
| 57 | 18.333333 | 28 | py |
EuclidEmulator | EuclidEmulator-master/examples/test.py | import e2py
import matplotlib.pyplot as plt
import numpy as np
import pylab as plb
from scipy.interpolate import CubicSpline
import os
# Specify cosmology and redshifts at which the non-linear
# power spectrum shall be emulated
csm = {'om_b': 0.0219961,
'om_m': 0.1431991,
'n_s': 0.96,
'h': 0.67,
... | 2,350 | 28.759494 | 102 | py |
EuclidEmulator | EuclidEmulator-master/examples/ProducePublicationPlot.py | import numpy as np
import matplotlib.pyplot as plt
import e2py
from classy import Class
csm = {'om_b': 0.0219961,
'om_m': 0.1431991,
'n_s': 0.96,
'h': 0.67,
'w_0': -1.0,
'sigma_8': 0.83}
h = csm['h']
#zvec = np.array([0.0,0.5,1.0,2.0])
Pnl = e2py.get_pnonlin(csm,0.5)
kvec = Pnl['k'... | 1,415 | 24.285714 | 109 | py |
EuclidEmulator | EuclidEmulator-master/wrapper3/e2py/ee_observables.py | """
ee_observables.py
EuclidEmulator submodule for actual emulation of cosmological observables.
"""
# This file is part of EuclidEmulator
# Copyright (c) 2018-2020 Mischa Knabenhans
#
# EuclidEmulator is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as pu... | 12,537 | 38.677215 | 90 | py |
EuclidEmulator | EuclidEmulator-master/wrapper3/e2py/ee_input.py | """
ee_input.py
EuclidEmulator submodule containing functions related to argument parsing.
"""
# This file is part of EuclidEmulator
# Copyright (c) 2018-2020 Mischa Knabenhans
#
# EuclidEmulator is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as publishe... | 8,016 | 35.112613 | 86 | py |
EuclidEmulator | EuclidEmulator-master/wrapper3/e2py/__init__.py | # This file is part of EuclidEmulator
# Copyright (c) 2018-2020 Mischa Knabenhans
#
# EuclidEmulator is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# at your option) any l... | 1,092 | 41.038462 | 82 | py |
EuclidEmulator | EuclidEmulator-master/wrapper3/e2py/_ee_lens.py | """
ee_lens.py
EuclidEmulator submodule for computation of cosmological lensing quantities.
REMARK: The geometry of the Universe is fixed to be flat (i.e.
Omega_curvature = 1) and the radiation energy density
is set to Om_rad = 4.183709411969527e-5/(h*h). These
values were ... | 3,585 | 34.50495 | 80 | py |
EuclidEmulator | EuclidEmulator-master/wrapper3/e2py/_internal/_ee_aux.py | """
_ee_aux.py
EuclidEmulator submodule for auxiliary functions.
"""
# This file is part of EuclidEmulator
# Copyright (c) 2018-2020 Mischa Knabenhans
#
# EuclidEmulator is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software ... | 4,034 | 29.11194 | 81 | py |
EuclidEmulator | EuclidEmulator-master/wrapper3/e2py/_internal/_ee_background.py | """
ee_background.py
EuclidEmulator submodule for computation of cosmological background quantities.
REMARK: The geometry of the Universe is fixed to be flat (i.e.
Omega_curvature = 1) and the radiation energy density
is set to Om_rad = 4.183709411969527e-5/(h*h). These
val... | 3,849 | 39.526316 | 83 | py |
EuclidEmulator | EuclidEmulator-master/wrapper3/e2py/_internal/_ee_cosmoconv.py | """
ee_cosmoconv.py
EuclidEmulator submodule for converting cosmological quantities.
REMARK: The geometry of the Universe is fixed to be flat (i.e.
Omega_curvature = 1) and the radiation energy density
is set to Om_rad = 4.183709411969527e-5/(h*h). These
values were assumed... | 5,665 | 34.4125 | 83 | py |
EuclidEmulator | EuclidEmulator-master/wrapper3/e2py/_internal/__init__.py | 0 | 0 | 0 | py | |
HIPT | HIPT-master/1-Hierarchical-Pretraining/eval_copy_detection.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# 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 ... | 12,631 | 40.827815 | 160 | py |
HIPT | HIPT-master/1-Hierarchical-Pretraining/eval_linear.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# 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 ... | 13,256 | 46.010638 | 135 | py |
HIPT | HIPT-master/1-Hierarchical-Pretraining/eval_image_retrieval.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# 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 ... | 9,288 | 44.985149 | 192 | py |
HIPT | HIPT-master/1-Hierarchical-Pretraining/hubconf.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# 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 ... | 5,653 | 36.197368 | 124 | py |
HIPT | HIPT-master/1-Hierarchical-Pretraining/run_with_submitit.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# 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 ... | 4,374 | 31.894737 | 103 | py |
HIPT | HIPT-master/1-Hierarchical-Pretraining/visualize_attention.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# 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 ... | 9,389 | 42.878505 | 157 | py |
HIPT | HIPT-master/1-Hierarchical-Pretraining/utils.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# 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 ... | 28,039 | 32.783133 | 119 | py |
HIPT | HIPT-master/1-Hierarchical-Pretraining/video_generation.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# 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 ... | 13,669 | 35.068602 | 135 | py |
HIPT | HIPT-master/1-Hierarchical-Pretraining/vision_transformer.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# 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 ... | 12,706 | 37.389728 | 124 | py |
HIPT | HIPT-master/1-Hierarchical-Pretraining/main_dino4k.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# 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 ... | 23,147 | 47.225 | 136 | py |
HIPT | HIPT-master/1-Hierarchical-Pretraining/eval_knn.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# 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 ... | 11,128 | 44.798354 | 117 | py |
HIPT | HIPT-master/1-Hierarchical-Pretraining/vision_transformer4k.py | import argparse
import os
import sys
import datetime
import time
import math
import json
from pathlib import Path
import numpy as np
from PIL import Image
import torch
import torch.nn as nn
import torch.distributed as dist
import torch.backends.cudnn as cudnn
import torch.nn.functional as F
from torchvision import dat... | 10,220 | 35.503571 | 123 | py |
HIPT | HIPT-master/1-Hierarchical-Pretraining/main_dino.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# 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 ... | 22,945 | 47.614407 | 114 | py |
HIPT | HIPT-master/1-Hierarchical-Pretraining/eval_video_segmentation.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# 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 ... | 11,835 | 39.395904 | 153 | py |
HIPT | HIPT-master/3-Self-Supervised-Eval/slide_evaluation_utils.py | def get_knn_classification_results(dataeroot, study='tcga_lung', enc_name='vit256mean', prop=1.0):
r"""
Runs 10-fold CV for KNN of mean WSI embeddings
Args:
- dataroot (str): Path to mean WSI embeddings for each feature type.
- study (str): Which TCGA study (Choices: tcga_brca, tcga_lun... | 2,324 | 46.44898 | 115 | py |
HIPT | HIPT-master/3-Self-Supervised-Eval/patch_evaluation_utils.py | import numpy as np
import scipy
import scipy.special as special
from scipy.stats._stats import (_kendall_dis, _toint64, _weightedrankedtau,
_local_correlations)
from scipy.stats import *
def _contains_nan(a, nan_policy='propagate'):
policies = ['propagate', 'raise', 'omit']
if nan_policy... | 9,513 | 40.72807 | 80 | py |
HIPT | HIPT-master/3-Self-Supervised-Eval/patch_extraction.py | ### Dependencies
# Base Dependencies
import os
import pickle
import sys
# LinAlg / Stats / Plotting Dependencies
import h5py
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from PIL import Image
import umap
import umap.plot
from tqdm import tqdm
# Torch Dependencies
import torch
import torch.mu... | 1,521 | 34.395349 | 125 | py |
HIPT | HIPT-master/3-Self-Supervised-Eval/slide_extraction_utils.py | # Base Dependencies
import os
import pickle
import sys
j_ = os.path.join
# LinAlg / Stats / Plotting Dependencies
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from PIL import Image
from tqdm import tqdm
# Scikit-Learn Imports
import sklearn
from sklearn.linear_model import LogisticRegressio... | 6,006 | 37.754839 | 118 | py |
HIPT | HIPT-master/3-Self-Supervised-Eval/patch_extraction_utils.py | ### Dependencies
# Base Dependencies
import os
import pickle
import sys
# LinAlg / Stats / Plotting Dependencies
import h5py
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from PIL import Image
import umap
import umap.plot
from tqdm import tqdm
# Torch Dependencies
import torch
import torch.mu... | 11,702 | 46.573171 | 117 | py |
HIPT | HIPT-master/HIPT_4K/hipt_4k.py | ### Dependencies
# Base Dependencies
import os
import pickle
import sys
# LinAlg / Stats / Plotting Dependencies
import h5py
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from PIL import Image
Image.MAX_IMAGE_PIXELS = None
from tqdm import tqdm
# Torch Dependencies
import torch
import torch.m... | 15,783 | 46.830303 | 149 | py |
HIPT | HIPT-master/HIPT_4K/hipt_heatmap_utils.py | ### Dependencies
# Base Dependencies
import argparse
import colorsys
from io import BytesIO
import os
import random
import requests
import sys
# LinAlg / Stats / Plotting Dependencies
import cv2
import h5py
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.patches import Polygon
import numpy as np
from... | 31,892 | 46.672646 | 163 | py |
HIPT | HIPT-master/HIPT_4K/vision_transformer.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# 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 ... | 12,706 | 37.389728 | 124 | py |
HIPT | HIPT-master/HIPT_4K/vision_transformer4k.py | import argparse
import os
import sys
import datetime
import time
import math
import json
from pathlib import Path
import numpy as np
from PIL import Image
import torch
import torch.nn as nn
import torch.distributed as dist
import torch.backends.cudnn as cudnn
import torch.nn.functional as F
from torchvision import dat... | 10,172 | 35.858696 | 123 | py |
HIPT | HIPT-master/HIPT_4K/hipt_model_utils.py | ### Dependencies
# Base Dependencies
import argparse
import colorsys
from io import BytesIO
import os
import random
import requests
import sys
# LinAlg / Stats / Plotting Dependencies
import cv2
import h5py
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.patches import Polygon
import numpy as np
from... | 5,125 | 32.503268 | 122 | py |
HIPT | HIPT-master/HIPT_4K/attention_visualization_utils.py | ### Dependencies
import argparse
import colorsys
from io import BytesIO
import os
import random
import requests
import sys
import cv2
import h5py
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.patches import Polygon
import numpy as np
from PIL import Image
from PIL import ImageFont
from PIL import I... | 36,576 | 44.10111 | 141 | py |
HIPT | HIPT-master/2-Weakly-Supervised-Subtyping/main.py | ### Base Packages
from __future__ import print_function
import argparse
import pdb
import os
import math
### Numerical Packages
import numpy as np
import pandas as pd
### Internal Imports
from datasets.dataset_generic import Generic_WSI_Classification_Dataset, Generic_MIL_Dataset
from utils.file_utils import save_pkl... | 12,119 | 45.259542 | 157 | py |
HIPT | HIPT-master/2-Weakly-Supervised-Subtyping/wsi_core/util_classes.py | import os
import numpy as np
from PIL import Image
import pdb
import cv2
class Mosaic_Canvas(object):
def __init__(self,patch_size=256, n=100, downscale=4, n_per_row=10, bg_color=(0,0,0), alpha=-1):
self.patch_size = patch_size
self.downscaled_patch_size = int(np.ceil(patch_size/downscale))
self.n_rows = int(np.... | 3,787 | 32.22807 | 121 | py |
HIPT | HIPT-master/2-Weakly-Supervised-Subtyping/wsi_core/WholeSlideImage.py | import math
import os
import time
import xml.etree.ElementTree as ET
from xml.dom import minidom
import multiprocessing as mp
import cv2
import matplotlib.pyplot as plt
import numpy as np
import openslide
from PIL import Image
import pdb
import h5py
import math
from wsi_core.wsi_utils import savePatchIter_bag_hdf5, ini... | 33,883 | 44.727395 | 198 | py |
HIPT | HIPT-master/2-Weakly-Supervised-Subtyping/wsi_core/wsi_utils.py | import h5py
import numpy as np
import os
import pdb
from wsi_core.util_classes import Mosaic_Canvas
from PIL import Image
import math
import cv2
def isWhitePatch(patch, satThresh=5):
patch_hsv = cv2.cvtColor(patch, cv2.COLOR_RGB2HSV)
return True if np.mean(patch_hsv[:,:,1]) < satThresh else False
def isBlackP... | 13,194 | 38.864048 | 153 | py |
HIPT | HIPT-master/2-Weakly-Supervised-Subtyping/wsi_core/batch_process_utils.py | import pandas as pd
import numpy as np
import pdb
'''
initiate a pandas df describing a list of slides to process
args:
slides (df or array-like):
array-like structure containing list of slide ids, if df, these ids assumed to be
stored under the 'slide_id' column
seg_params (dict): segmentation paramters
fil... | 3,212 | 38.182927 | 98 | py |
HIPT | HIPT-master/2-Weakly-Supervised-Subtyping/models/model_utils.py | from collections import OrderedDict
from os.path import join
import math
import pdb
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
"""
Attention Network without Gating (2 fc layers)
args:
L: input feature dimension
D: hidden layer dimension
dropout: whether to use ... | 2,562 | 25.978947 | 77 | py |
HIPT | HIPT-master/2-Weakly-Supervised-Subtyping/models/model_dgcn.py | from os.path import join
from collections import OrderedDict
import pdb
import numpy as np
import torch
import torch.nn.functional as F
import torch.nn as nn
from torch.nn import Sequential as Seq
from torch.nn import Linear, LayerNorm, ReLU
#from torch_geometric.nn import GINConv
#from torch_geometric.transforms.nor... | 3,422 | 41.7875 | 116 | py |
HIPT | HIPT-master/2-Weakly-Supervised-Subtyping/models/model_mil.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from utils.utils import initialize_weights
import numpy as np
class MIL_fc(nn.Module):
def __init__(self, path_input_dim=384, gate = True, size_arg = "small", dropout = False, n_classes = 2, top_k=1):
super(MIL_fc, self).__init__()
... | 3,647 | 36.22449 | 121 | py |
HIPT | HIPT-master/2-Weakly-Supervised-Subtyping/models/model_clam.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from utils.utils import initialize_weights
import numpy as np
from models.model_utils import *
"""
args:
gate: whether to use gated attention network
size_arg: config for network size
dropout: whether to use dropout
k_sample: number of ... | 9,447 | 43.990476 | 128 | py |
HIPT | HIPT-master/2-Weakly-Supervised-Subtyping/models/model_hierarchical_mil.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import pdb
import numpy as np
from os.path import join
from collections import OrderedDict
import torch
import torch.nn as nn
import torch.nn.functional as F
from models.model_utils import *
import sys
sys.path.append('../HIPT_4K/')
from vision_trans... | 8,672 | 39.528037 | 116 | py |
HIPT | HIPT-master/2-Weakly-Supervised-Subtyping/models/model_dsmil.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
class FCLayer(nn.Module):
def __init__(self, in_size, out_size=1):
super(FCLayer, self).__init__()
self.fc = nn.Sequential(nn.Linear(in_size, out_size))
def forward(self, feats, **kwargs):
... | 3,324 | 43.333333 | 168 | py |
HIPT | HIPT-master/2-Weakly-Supervised-Subtyping/models/model_cluster.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import pdb
import numpy as np
from os.path import join
from collections import OrderedDict
import torch
import torch.nn as nn
import torch.nn.functional as F
######################################
# Deep Attention MISL Implementation #
###############... | 3,697 | 37.520833 | 108 | py |
HIPT | HIPT-master/2-Weakly-Supervised-Subtyping/models/resnet_custom.py | # modified from Pytorch official resnet.py
import torch.nn as nn
import torch.utils.model_zoo as model_zoo
import torch
from torchsummary import summary
import torch.nn.functional as F
__all__ = ['ResNet', 'resnet18', 'resnet34', 'resnet50', 'resnet101',
'resnet152']
model_urls = {
'resnet18': 'https:/... | 4,314 | 32.976378 | 90 | py |
HIPT | HIPT-master/2-Weakly-Supervised-Subtyping/datasets/dataset_generic.py | from __future__ import print_function, division
import os
import torch
import numpy as np
import pandas as pd
import math
import re
import pdb
import pickle
from scipy import stats
from torch.utils.data import Dataset
import h5py
from utils.utils import generate_split, nth
def save_splits(split_datasets, column_keys... | 16,504 | 38.204276 | 167 | py |
HIPT | HIPT-master/2-Weakly-Supervised-Subtyping/datasets/dataset_h5.py | from __future__ import print_function, division
import os
import torch
import numpy as np
import pandas as pd
import math
import re
import pdb
import pickle
from torch.utils.data import Dataset, DataLoader, sampler
from torchvision import transforms, utils, models
import torch.nn.functional as F
from PIL import Image... | 4,426 | 24.738372 | 104 | py |
HIPT | HIPT-master/2-Weakly-Supervised-Subtyping/datasets/BatchWSI.py | import torch_geometric
from typing import List
import torch
from torch import Tensor
from torch_sparse import SparseTensor, cat
import torch_geometric
from torch_geometric.data import Data
class BatchWSI(torch_geometric.data.Batch):
def __init__(self):
super(BatchWSI, self).__init__()
pass
... | 6,596 | 42.98 | 93 | py |
HIPT | HIPT-master/2-Weakly-Supervised-Subtyping/utils/core_utils.py | import numpy as np
import torch
import torch.nn.functional as F
from utils.utils import *
import os
import torch.nn.functional as F
from datasets.dataset_generic import save_splits
from models.model_dsmil import *
from models.model_mil import MIL_fc, MIL_fc_mc
from models.model_dgcn import DeepGraphConv
from models.mod... | 23,019 | 36.986799 | 163 | py |
HIPT | HIPT-master/2-Weakly-Supervised-Subtyping/utils/utils.py | import pickle
import torch
import numpy as np
import torch.nn as nn
import pdb
import torch
import numpy as np
import torch.nn as nn
from torchvision import transforms
from torch.utils.data import DataLoader, Sampler, WeightedRandomSampler, RandomSampler, SequentialSampler, sampler
import torch.optim as optim
import p... | 6,214 | 32.413978 | 197 | py |
HIPT | HIPT-master/2-Weakly-Supervised-Subtyping/utils/file_utils.py | import pickle
import h5py
def save_pkl(filename, save_object):
writer = open(filename,'wb')
pickle.dump(save_object, writer)
writer.close()
def load_pkl(filename):
loader = open(filename,'rb')
file = pickle.load(loader)
loader.close()
return file
def save_hdf5(output_path, asset_dict, attr_dict= None, mode='... | 1,129 | 31.285714 | 117 | py |
HIPT | HIPT-master/2-Weakly-Supervised-Subtyping/utils/eval_utils.py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from models.model_mil import MIL_fc, MIL_fc_mc
from models.model_clam import CLAM_SB, CLAM_MB
import pdb
import os
import pandas as pd
from utils.utils import *
from utils.core_utils import Accuracy_Logger
from sklearn.metrics import... | 4,650 | 33.451852 | 114 | py |
benchmarking_graph | benchmarking_graph-main/src/md.py | from functools import partial
import jax
import jax.numpy as jnp
from jax import jit, lax, value_and_grad
from jax.experimental import optimizers
from .nve import nve, nve2, nve3
# ===============================
# ===============================
def dynamics_generator(ensemble, force_fn, shift_fn, params, dt, ma... | 5,251 | 27.699454 | 83 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.