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 |
|---|---|---|---|---|---|---|
dream | dream-main/data/compile_scene_elaboration_dataset.py | #!/usr/bin/env python
# coding: utf-8
# In[1]:
import json
import csv
import os
import random
# In[2]:
def make_sure_dir_exists(dir_to_check):
if not os.path.exists(dir_to_check):
os.makedirs(dir_to_check)
# In[3]:
# !rm -r external_data/
# !rm -r external_data_tidied/
# !rm -r external_data_tidi... | 18,576 | 34.65643 | 279 | py |
CLMR | CLMR-master/main.py | import argparse
import pytorch_lightning as pl
from pytorch_lightning.callbacks.early_stopping import EarlyStopping
from pytorch_lightning import Trainer
from pytorch_lightning.loggers import TensorBoardLogger
from torch.utils.data import DataLoader
# Audio Augmentations
from torchaudio_augmentations import (
Rand... | 5,117 | 28.583815 | 88 | py |
CLMR | CLMR-master/export.py | """
This script will extract a pre-trained CLMR PyTorch model to an ONNX model.
"""
import argparse
import os
import torch
from collections import OrderedDict
from copy import deepcopy
from clmr.models import SampleCNN, Identity
from clmr.utils import load_encoder_checkpoint, load_finetuner_checkpoint
def convert_en... | 2,321 | 28.025 | 87 | py |
CLMR | CLMR-master/setup.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Note: To use the 'upload' functionality of this file, you must:
# $ pipenv install twine --dev
import io
import os
import sys
from shutil import rmtree
from setuptools import find_packages, setup, Command
# Package meta-data.
NAME = "clmr"
DESCRIPTION = "Contrastive... | 3,919 | 27.405797 | 86 | py |
CLMR | CLMR-master/linear_evaluation.py | import os
import argparse
import pytorch_lightning as pl
from torch.utils.data import DataLoader
from torchaudio_augmentations import Compose, RandomResizedCrop
from pytorch_lightning import Trainer
from pytorch_lightning.callbacks import EarlyStopping
from pytorch_lightning.loggers import TensorBoardLogger
from clmr.... | 4,555 | 28.393548 | 87 | py |
CLMR | CLMR-master/preprocess.py | import argparse
from tqdm import tqdm
from clmr.datasets import get_dataset
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--dataset", type=str, default="magnatagatune")
parser.add_argument("--dataset_dir", type=str, default="./data")
parser.add_argument("--sample_ra... | 921 | 37.416667 | 79 | py |
CLMR | CLMR-master/tests/test_dataset.py | import unittest
import pytest
from clmr.datasets import (
get_dataset,
AUDIO,
LIBRISPEECH,
GTZAN,
MAGNATAGATUNE,
MillionSongDataset,
)
class TestAudioSet(unittest.TestCase):
datasets = {
"librispeech": LIBRISPEECH,
"gtzan": GTZAN,
"magnatagatune": MAGNATAGATUNE,
... | 910 | 24.305556 | 80 | py |
CLMR | CLMR-master/tests/test_spectogram.py | import unittest
import torchaudio
import torch.nn as nn
from torchaudio_augmentations import *
from clmr.datasets import AUDIO
class TestAudioSet(unittest.TestCase):
sample_rate = 16000
def get_audio_transforms(self, num_samples):
transform = Compose(
[
RandomResizedCrop(... | 1,659 | 29.740741 | 86 | py |
CLMR | CLMR-master/tests/__init__.py | 0 | 0 | 0 | py | |
CLMR | CLMR-master/tests/test_audioset.py | import unittest
import torchaudio
from torchaudio_augmentations import (
Compose,
RandomApply,
RandomResizedCrop,
PolarityInversion,
Noise,
Gain,
Delay,
PitchShift,
Reverb,
)
from clmr.datasets import AUDIO
class TestAudioSet(unittest.TestCase):
sample_rate = 16000
def get... | 1,500 | 29.632653 | 86 | py |
CLMR | CLMR-master/clmr/data.py | """Wrapper for Torch Dataset class to enable contrastive training
"""
import torch
from torch import Tensor
from torch.utils.data import Dataset
from torchaudio_augmentations import Compose
from typing import Tuple, List
class ContrastiveDataset(Dataset):
def __init__(self, dataset: Dataset, input_shape: List[int... | 1,258 | 27.613636 | 85 | py |
CLMR | CLMR-master/clmr/evaluation.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.data import Dataset
from tqdm import tqdm
from sklearn import metrics
def evaluate(
encoder: nn.Module,
finetuned_head: nn.Module,
test_dataset: Dataset,
dataset_name: str,
audio_length: int,
device,
) -> dict:... | 1,921 | 30.508197 | 95 | py |
CLMR | CLMR-master/clmr/modules/callbacks.py | import matplotlib
import matplotlib.pyplot as plt
matplotlib.use("Agg")
from pytorch_lightning.callbacks import Callback
class PlotSpectogramCallback(Callback):
def on_train_start(self, trainer, pl_module):
if not pl_module.hparams.time_domain:
x, y = trainer.train_dataloader.dataset[0]
... | 725 | 24.928571 | 61 | py |
CLMR | CLMR-master/clmr/modules/linear_evaluation.py | import torch
import torch.nn as nn
import torchmetrics
from copy import deepcopy
from pytorch_lightning import LightningModule
from torch import Tensor
from torch.utils.data import DataLoader, Dataset, TensorDataset
from typing import Tuple
from tqdm import tqdm
class LinearEvaluation(LightningModule):
def __init... | 3,975 | 31.590164 | 98 | py |
CLMR | CLMR-master/clmr/modules/supervised_learning.py | import torch
import torchmetrics
import torch.nn as nn
from pytorch_lightning import LightningModule
class SupervisedLearning(LightningModule):
def __init__(self, args, encoder: nn.Module, output_dim: int):
super().__init__()
self.save_hyperparameters(args)
self.encoder = encoder
... | 2,082 | 29.632353 | 75 | py |
CLMR | CLMR-master/clmr/modules/__init__.py | from .callbacks import PlotSpectogramCallback
from .contrastive_learning import ContrastiveLearning
from .linear_evaluation import LinearEvaluation
from .supervised_learning import SupervisedLearning
| 200 | 39.2 | 53 | py |
CLMR | CLMR-master/clmr/modules/contrastive_learning.py | import torch
import torch.nn as nn
from pytorch_lightning import LightningModule
from torch import Tensor
from simclr import SimCLR
from simclr.modules import NT_Xent, LARS
class ContrastiveLearning(LightningModule):
def __init__(self, args, encoder: nn.Module):
super().__init__()
self.save_hyper... | 2,587 | 35.450704 | 87 | py |
CLMR | CLMR-master/clmr/models/sample_cnn.py | import torch
import torch.nn as nn
from .model import Model
class SampleCNN(Model):
def __init__(self, strides, supervised, out_dim):
super(SampleCNN, self).__init__()
self.strides = strides
self.supervised = supervised
self.sequential = [
nn.Sequential(
... | 1,881 | 26.676471 | 84 | py |
CLMR | CLMR-master/clmr/models/sample_cnn_xl.py | import torch
import torch.nn as nn
from .model import Model
class SampleCNNXL(Model):
def __init__(self, strides, supervised, out_dim):
super(SampleCNN, self).__init__()
self.strides = strides
self.supervised = supervised
self.sequential = [
nn.Sequential(
... | 1,892 | 26.838235 | 84 | py |
CLMR | CLMR-master/clmr/models/shortchunk_cnn.py | import torch.nn as nn
class ShortChunkCNN_Res(nn.Module):
"""
Short-chunk CNN architecture with residual connections.
"""
def __init__(self, n_channels=128, n_classes=50):
super(ShortChunkCNN_Res, self).__init__()
self.spec_bn = nn.BatchNorm2d(1)
# CNN
self.layer1 = ... | 2,845 | 28.340206 | 85 | py |
CLMR | CLMR-master/clmr/models/model.py | import torch.nn as nn
import numpy as np
class Model(nn.Module):
def __init__(self):
super(Model, self).__init__()
def initialize(self, m):
if isinstance(m, (nn.Conv1d)):
# nn.init.xavier_uniform_(m.weight)
# if m.bias is not None:
# nn.init.xavier_unif... | 555 | 22.166667 | 82 | py |
CLMR | CLMR-master/clmr/models/__init__.py | from .model import Model, Identity
from .sample_cnn import SampleCNN
from .shortchunk_cnn import ShortChunkCNN_Res
from .sinc_net import SincNet
| 145 | 28.2 | 45 | py |
CLMR | CLMR-master/clmr/models/sinc_net.py | import numpy as np
import torch
import torch.nn.functional as F
import torch.nn as nn
import sys
from torch.autograd import Variable
import math
def flip(x, dim):
xsize = x.size()
dim = x.dim() + dim if dim < 0 else dim
x = x.contiguous()
x = x.view(-1, *xsize[dim:])
x = x.view(x.size(0), x.size(1... | 16,565 | 28.902527 | 226 | py |
CLMR | CLMR-master/clmr/datasets/magnatagatune.py | import os
import warnings
import subprocess
import torch
import numpy as np
import zipfile
from collections import defaultdict
from typing import Any, Tuple, Optional
from tqdm import tqdm
import soundfile as sf
import torchaudio
torchaudio.set_audio_backend("soundfile")
from torch import Tensor, FloatTensor
from tor... | 6,744 | 35.069519 | 99 | py |
CLMR | CLMR-master/clmr/datasets/million_song_dataset.py | import os
import pickle
import torch
import torchaudio
from collections import defaultdict
from pathlib import Path
from torch import Tensor, FloatTensor
from tqdm import tqdm
from typing import Any, Tuple, Optional
from clmr.datasets import Dataset
def load_id2gt(gt_file, msd_7d):
ids = []
with open(gt_file... | 4,169 | 29.661765 | 89 | py |
CLMR | CLMR-master/clmr/datasets/gtzan.py | import torchaudio
from torchaudio.datasets.gtzan import gtzan_genres
from torch.utils.data import Dataset
class GTZAN(Dataset):
subset_map = {"train": "training", "valid": "validation", "test": "testing"}
def __init__(self, root, download, subset):
self.dataset = torchaudio.datasets.GTZAN(
... | 802 | 26.689655 | 80 | py |
CLMR | CLMR-master/clmr/datasets/audio.py | import os
from glob import glob
from torch import Tensor
from typing import Tuple
from clmr.datasets import Dataset
class AUDIO(Dataset):
"""Create a Dataset for any folder of audio files.
Args:
root (str): Path to the directory where the dataset is found or downloaded.
src_ext_audio (str): ... | 1,506 | 24.116667 | 91 | py |
CLMR | CLMR-master/clmr/datasets/dataset.py | import os
import subprocess
import torchaudio
from torch.utils.data import Dataset as TorchDataset
from abc import abstractmethod
def preprocess_audio(source, target, sample_rate):
p = subprocess.Popen(
["ffmpeg", "-i", source, "-ar", str(sample_rate), target, "-loglevel", "quiet"]
)
p.wait()
cl... | 1,201 | 25.130435 | 87 | py |
CLMR | CLMR-master/clmr/datasets/__init__.py | import os
from .dataset import Dataset
from .audio import AUDIO
from .librispeech import LIBRISPEECH
from .gtzan import GTZAN
from .magnatagatune import MAGNATAGATUNE
from .million_song_dataset import MillionSongDataset
def get_dataset(dataset, dataset_dir, subset, download=True):
if not os.path.exists(dataset_d... | 922 | 31.964286 | 77 | py |
CLMR | CLMR-master/clmr/datasets/librispeech.py | import os
import torchaudio
from torch.utils.data import Dataset
class LIBRISPEECH(Dataset):
subset_map = {"train": "train-clean-100", "test": "test-clean"}
def __init__(self, root, download, subset):
self.dataset = torchaudio.datasets.LIBRISPEECH(
root=root, download=download, url=self.... | 1,147 | 26.333333 | 79 | py |
CLMR | CLMR-master/clmr/utils/yaml_config_hook.py | import os
import yaml
def yaml_config_hook(config_file):
"""
Custom YAML config loader, which can include other yaml files (I like using config files
insteaad of using argparser)
"""
# load yaml files in the nested 'defaults' section, which include defaults for experiments
with open(config_fi... | 709 | 27.4 | 94 | py |
CLMR | CLMR-master/clmr/utils/checkpoint.py | import torch
from collections import OrderedDict
def load_encoder_checkpoint(checkpoint_path: str, output_dim: int) -> OrderedDict:
state_dict = torch.load(checkpoint_path, map_location=torch.device("cpu"))
if "pytorch-lightning_version" in state_dict.keys():
new_state_dict = OrderedDict(
... | 1,265 | 33.216216 | 82 | py |
CLMR | CLMR-master/clmr/utils/__init__.py | from .checkpoint import load_encoder_checkpoint, load_finetuner_checkpoint
from .yaml_config_hook import yaml_config_hook
| 122 | 40 | 74 | py |
RSFormer | RSFormer-master/calculate_psnr_ssim.py | import os
import sys
import cv2
from skimage.metrics import peak_signal_noise_ratio, structural_similarity
from config import Options
opt = Options()
path_result = opt.Result_Path_Test
path_target = opt.Target_Path_Test
image_list = os.listdir(path_target)
L = len(image_list)
total_psnr, total_ssim = 0, 0
for i in r... | 870 | 29.034483 | 82 | py |
RSFormer | RSFormer-master/utils.py | import torch.nn.functional as F
# pad
def pad(x, factor=16, mode='reflect'):
_, _, h_even, w_even = x.shape
padh_left = (factor - h_even % factor) // 2
padw_top = (factor - w_even % factor) // 2
padh_right = padh_left if h_even % 2 == 0 else padh_left + 1
padw_bottom = padw_top if w_even % 2 == 0 ... | 776 | 31.375 | 79 | py |
RSFormer | RSFormer-master/config.py | class Options():
def __init__(self):
super().__init__()
self.Input_Path_Test = 'E://RSCityScape_small/test/input/'
self.Target_Path_Test = 'E://RSCityScape_small/test/target/'
self.Result_Path_Test = 'E://RSCityScape_small/test/result_Restormer/'
self.MODEL_PATH = './model_b... | 384 | 37.5 | 78 | py |
RSFormer | RSFormer-master/datasets.py | import os
from PIL import Image
from torch.utils.data import Dataset
import torchvision.transforms.functional as ttf
class MyTestDataSet(Dataset):
def __init__(self, inputPathTest):
super(MyTestDataSet, self).__init__()
self.inputPath = inputPathTest
self.inputImages = os.listdir(inputPath... | 702 | 28.291667 | 78 | py |
RSFormer | RSFormer-master/demo.py | import sys
import time
import torch
import torch.nn as nn
from tqdm import tqdm
from torch.utils.data import DataLoader
from torchvision.utils import save_image
from RSFormer import RSFormer
from datasets import *
from config import Options
from utils import pad, unpad
if __name__ == '__main__':
opt = Options()
... | 1,721 | 30.888889 | 101 | py |
RSFormer | RSFormer-master/RSFormer.py | import torch
import torch.nn as nn
class FeedForward(nn.Module):
def __init__(self, dim, mlp_ratio=4):
super().__init__()
hidden_features = int(dim * mlp_ratio)
self.norm = LayerNorm(dim)
self.fc1 = nn.Conv2d(dim, hidden_features, 1)
self.dwconv = nn.Conv2d(hidden_features,... | 8,508 | 34.016461 | 146 | py |
DRT | DRT-master/libsvm/tools/easy.py | #!/usr/bin/env python
import sys
import os
from subprocess import *
if len(sys.argv) <= 1:
print('Usage: %s training_file [testing_file]' % sys.argv[0])
raise SystemExit
# svm, grid, and gnuplot executable files
is_win32 = (sys.platform == 'win32')
if not is_win32:
svmscale_exe = "../svm-scale"
svmtrain_exe = "... | 2,627 | 31.85 | 96 | py |
DRT | DRT-master/libsvm/tools/checkdata.py | #!/usr/bin/env python
#
# A format checker for LIBSVM
#
#
# Copyright (c) 2007, Rong-En Fan
#
# All rights reserved.
#
# This program is distributed under the same license of the LIBSVM package.
#
from sys import argv, exit
import os.path
def err(line_no, msg):
print("line %d: %s" % (line_no, msg))
# works like ... | 2,423 | 21.238532 | 124 | py |
DRT | DRT-master/libsvm/tools/grid.py | #!/usr/bin/env python
import os, sys, traceback
import getpass
from threading import Thread
from subprocess import *
if(sys.hexversion < 0x03000000):
import Queue
else:
import queue as Queue
# svmtrain and gnuplot executable
is_win32 = (sys.platform == 'win32')
if not is_win32:
svmtrain_exe = "../svm-tr... | 11,414 | 30.708333 | 102 | py |
DRT | DRT-master/libsvm/tools/subset.py | #!/usr/bin/env python
from sys import argv, exit, stdout, stderr
from random import randint
method = 0
global n
global dataset_filename
subset_filename = ""
rest_filename = ""
def exit_with_help():
print("""\
Usage: %s [options] dataset number [output1] [output2]
This script selects a subset of the given dataset.
... | 2,987 | 19.326531 | 79 | py |
DRT | DRT-master/libsvm/python/svm.py | #!/usr/bin/env python
from ctypes import *
from ctypes.util import find_library
import sys
# For unix the prefix 'lib' is not considered.
if find_library('svm'):
libsvm = CDLL(find_library('svm'))
elif find_library('libsvm'):
libsvm = CDLL(find_library('libsvm'))
else:
if sys.platform == 'win32':
libsvm = CDLL('... | 7,768 | 28.880769 | 122 | py |
DRT | DRT-master/libsvm/python/svmutil.py | #!/usr/bin/env python
from svm import *
def svm_read_problem(data_file_name):
"""
svm_read_problem(data_file_name) -> [y, x]
Read LIBSVM-format data from data_file_name and return labels y
and data instances x.
"""
prob_y = []
prob_x = []
for line in open(data_file_name):
line = line.split(None, 1)
# In ... | 8,068 | 32.205761 | 113 | py |
DRT | DRT-master/external_libs/matconvnet/matconvnet/utils/layers.py | # file: layers.py
# brief: A number of objects to wrap caffe layers for conversion
# author: Andrea Vedaldi
from collections import OrderedDict
from math import floor, ceil
from operator import mul
import numpy as np
from numpy import array
import scipy
import scipy.io
import scipy.misc
import copy
import collections
... | 43,791 | 36.493151 | 156 | py |
DRT | DRT-master/external_libs/matconvnet/matconvnet/utils/import-caffe.py | #! /usr/bin/python
# file: import-caffe.py
# brief: Caffe importer for DagNN and SimpleNN
# author: Karel Lenc and Andrea Vedaldi
# Requires Google Protobuf for Python and SciPy
import sys
import os
import argparse
import code
import re
import numpy as np
from math import floor, ceil
import numpy
from numpy import ar... | 33,156 | 36.213244 | 114 | py |
DRT | DRT-master/external_libs/matconvnet/matconvnet/utils/proto/caffe_0115_pb2.py | # Generated by the protocol buffer compiler. DO NOT EDIT!
from google.protobuf import descriptor
from google.protobuf import message
from google.protobuf import reflection
from google.protobuf import descriptor_pb2
# @@protoc_insertion_point(imports)
DESCRIPTOR = descriptor.FileDescriptor(
name='caffe.proto',
... | 148,708 | 41.163028 | 17,413 | py |
DRT | DRT-master/external_libs/matconvnet/matconvnet/utils/proto/caffe_fastrcnn_pb2.py | # Generated by the protocol buffer compiler. DO NOT EDIT!
# source: caffe_fastrcnn.proto
from google.protobuf.internal import enum_type_wrapper
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from google.protobuf import reflection as _reflection
from google.protob... | 194,370 | 42.777252 | 22,943 | py |
DRT | DRT-master/external_libs/matconvnet/matconvnet/utils/proto/caffe_6e3916_pb2.py | # Generated by the protocol buffer compiler. DO NOT EDIT!
from google.protobuf import descriptor
from google.protobuf import message
from google.protobuf import reflection
from google.protobuf import descriptor_pb2
# @@protoc_insertion_point(imports)
DESCRIPTOR = descriptor.FileDescriptor(
name='caffe_6e3916.pro... | 218,004 | 42.349572 | 26,073 | py |
DRT | DRT-master/external_libs/matconvnet/matconvnet/utils/proto/caffe_old_pb2.py | # Generated by the protocol buffer compiler. DO NOT EDIT!
from google.protobuf import descriptor
from google.protobuf import message
from google.protobuf import reflection
from google.protobuf import descriptor_pb2
# @@protoc_insertion_point(imports)
DESCRIPTOR = descriptor.FileDescriptor(
name='caffe-old.proto'... | 39,691 | 43.348603 | 4,364 | py |
DRT | DRT-master/external_libs/matconvnet/matconvnet/utils/proto/caffe_b590f1d_pb2.py | # Generated by the protocol buffer compiler. DO NOT EDIT!
from google.protobuf import descriptor
from google.protobuf import message
from google.protobuf import reflection
from google.protobuf import descriptor_pb2
# @@protoc_insertion_point(imports)
DESCRIPTOR = descriptor.FileDescriptor(
name='caffe_b590f1d.pr... | 232,112 | 42.264306 | 27,801 | py |
DRT | DRT-master/external_libs/matconvnet/matconvnet/utils/proto/__init__.py | 0 | 0 | 0 | py | |
DRT | DRT-master/external_libs/matconvnet/matconvnet/utils/proto/caffe_pb2.py | # Generated by the protocol buffer compiler. DO NOT EDIT!
from google.protobuf import descriptor
from google.protobuf import message
from google.protobuf import reflection
from google.protobuf import descriptor_pb2
# @@protoc_insertion_point(imports)
DESCRIPTOR = descriptor.FileDescriptor(
name='caffe.proto',
... | 91,458 | 42.407214 | 10,562 | py |
DRT | DRT-master/external_libs/matconvnet/matconvnet/utils/proto/vgg_caffe_pb2.py | # Generated by the protocol buffer compiler. DO NOT EDIT!
from google.protobuf import descriptor
from google.protobuf import message
from google.protobuf import reflection
from google.protobuf import descriptor_pb2
# @@protoc_insertion_point(imports)
DESCRIPTOR = descriptor.FileDescriptor(
name='vgg_caffe.proto'... | 44,873 | 42.865103 | 4,761 | py |
DRT | DRT-master/external_libs/matconvnet/matconvnet/doc/matdoc.py | # file: matdoc.py
# author: Andrea Vedaldi
# brief: Extact comments from a MATLAB mfile and generate a Markdown file
import sys, os, re, shutil
import subprocess, signal
import string, fnmatch
from matdocparser import *
from optparse import OptionParser
usage = """usage: %prog [options] <mfile>
Extracts the comment... | 7,192 | 30.273913 | 94 | py |
DRT | DRT-master/external_libs/matconvnet/matconvnet/doc/matdocparser.py | #!/usr/bin/python
# file: matdocparser.py
# author: Andrea Vedaldi
# description: Utility to format MATLAB comments.
# Copyright (C) 2014-15 Andrea Vedaldi.
# All rights reserved.
#
# This file is part of the VLFeat library and is made available under
# the terms of the BSD license (see the COPYING file).
"""
MatDocP... | 11,110 | 29.275204 | 80 | py |
DRT | DRT-master/external_libs/matconvnet/utils/layers.py | # file: layers.py
# brief: A number of objects to wrap caffe layers for conversion
# author: Andrea Vedaldi
from collections import OrderedDict
from math import floor, ceil
from operator import mul
import numpy as np
from numpy import array
import scipy
import scipy.io
import scipy.misc
import copy
import collections
... | 43,791 | 36.493151 | 156 | py |
DRT | DRT-master/external_libs/matconvnet/utils/import-caffe.py | #! /usr/bin/python
# file: import-caffe.py
# brief: Caffe importer for DagNN and SimpleNN
# author: Karel Lenc and Andrea Vedaldi
# Requires Google Protobuf for Python and SciPy
import sys
import os
import argparse
import code
import re
import numpy as np
from math import floor, ceil
import numpy
from numpy import ar... | 33,156 | 36.213244 | 114 | py |
DRT | DRT-master/external_libs/matconvnet/utils/proto/caffe_0115_pb2.py | # Generated by the protocol buffer compiler. DO NOT EDIT!
from google.protobuf import descriptor
from google.protobuf import message
from google.protobuf import reflection
from google.protobuf import descriptor_pb2
# @@protoc_insertion_point(imports)
DESCRIPTOR = descriptor.FileDescriptor(
name='caffe.proto',
... | 148,708 | 41.163028 | 17,413 | py |
DRT | DRT-master/external_libs/matconvnet/utils/proto/caffe_fastrcnn_pb2.py | # Generated by the protocol buffer compiler. DO NOT EDIT!
# source: caffe_fastrcnn.proto
from google.protobuf.internal import enum_type_wrapper
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from google.protobuf import reflection as _reflection
from google.protob... | 194,370 | 42.777252 | 22,943 | py |
DRT | DRT-master/external_libs/matconvnet/utils/proto/caffe_6e3916_pb2.py | # Generated by the protocol buffer compiler. DO NOT EDIT!
from google.protobuf import descriptor
from google.protobuf import message
from google.protobuf import reflection
from google.protobuf import descriptor_pb2
# @@protoc_insertion_point(imports)
DESCRIPTOR = descriptor.FileDescriptor(
name='caffe_6e3916.pro... | 218,004 | 42.349572 | 26,073 | py |
DRT | DRT-master/external_libs/matconvnet/utils/proto/caffe_old_pb2.py | # Generated by the protocol buffer compiler. DO NOT EDIT!
from google.protobuf import descriptor
from google.protobuf import message
from google.protobuf import reflection
from google.protobuf import descriptor_pb2
# @@protoc_insertion_point(imports)
DESCRIPTOR = descriptor.FileDescriptor(
name='caffe-old.proto'... | 39,691 | 43.348603 | 4,364 | py |
DRT | DRT-master/external_libs/matconvnet/utils/proto/caffe_b590f1d_pb2.py | # Generated by the protocol buffer compiler. DO NOT EDIT!
from google.protobuf import descriptor
from google.protobuf import message
from google.protobuf import reflection
from google.protobuf import descriptor_pb2
# @@protoc_insertion_point(imports)
DESCRIPTOR = descriptor.FileDescriptor(
name='caffe_b590f1d.pr... | 232,112 | 42.264306 | 27,801 | py |
DRT | DRT-master/external_libs/matconvnet/utils/proto/__init__.py | 0 | 0 | 0 | py | |
DRT | DRT-master/external_libs/matconvnet/utils/proto/caffe_pb2.py | # Generated by the protocol buffer compiler. DO NOT EDIT!
from google.protobuf import descriptor
from google.protobuf import message
from google.protobuf import reflection
from google.protobuf import descriptor_pb2
# @@protoc_insertion_point(imports)
DESCRIPTOR = descriptor.FileDescriptor(
name='caffe.proto',
... | 91,458 | 42.407214 | 10,562 | py |
DRT | DRT-master/external_libs/matconvnet/utils/proto/vgg_caffe_pb2.py | # Generated by the protocol buffer compiler. DO NOT EDIT!
from google.protobuf import descriptor
from google.protobuf import message
from google.protobuf import reflection
from google.protobuf import descriptor_pb2
# @@protoc_insertion_point(imports)
DESCRIPTOR = descriptor.FileDescriptor(
name='vgg_caffe.proto'... | 44,873 | 42.865103 | 4,761 | py |
DRT | DRT-master/external_libs/matconvnet/doc/matdoc.py | # file: matdoc.py
# author: Andrea Vedaldi
# brief: Extact comments from a MATLAB mfile and generate a Markdown file
import sys, os, re, shutil
import subprocess, signal
import string, fnmatch
from matdocparser import *
from optparse import OptionParser
usage = """usage: %prog [options] <mfile>
Extracts the comment... | 7,192 | 30.273913 | 94 | py |
DRT | DRT-master/external_libs/matconvnet/doc/matdocparser.py | #!/usr/bin/python
# file: matdocparser.py
# author: Andrea Vedaldi
# description: Utility to format MATLAB comments.
# Copyright (C) 2014-15 Andrea Vedaldi.
# All rights reserved.
#
# This file is part of the VLFeat library and is made available under
# the terms of the BSD license (see the COPYING file).
"""
MatDocP... | 11,110 | 29.275204 | 80 | py |
DRT | DRT-master/caffe/tools/extra/extract_seconds.py | #!/usr/bin/env python
import datetime
import os
import sys
def extract_datetime_from_line(line, year):
# Expected format: I0210 13:39:22.381027 25210 solver.cpp:204] Iteration 100, lr = 0.00992565
line = line.strip().split()
month = int(line[0][1:3])
day = int(line[0][3:])
timestamp = line[1]
p... | 1,966 | 29.261538 | 97 | py |
DRT | DRT-master/caffe/tools/extra/resize_and_crop_images.py | #!/usr/bin/env python
from mincepie import mapreducer, launcher
import gflags
import os
import cv2
from PIL import Image
# gflags
gflags.DEFINE_string('image_lib', 'opencv',
'OpenCV or PIL, case insensitive. The default value is the faster OpenCV.')
gflags.DEFINE_string('input_folder', '',
... | 4,541 | 40.290909 | 99 | py |
DRT | DRT-master/caffe/tools/extra/parse_log.py | #!/usr/bin/env python
"""
Parse training log
Evolved from parse_log.sh
"""
import os
import re
import extract_seconds
import argparse
import csv
from collections import OrderedDict
def parse_log(path_to_log):
"""Parse log file
Returns (train_dict_list, train_dict_names, test_dict_list, test_dict_names)
... | 6,700 | 33.015228 | 86 | py |
DRT | DRT-master/caffe/examples/web_demo/app.py | import os
import time
import cPickle
import datetime
import logging
import flask
import werkzeug
import optparse
import tornado.wsgi
import tornado.httpserver
import numpy as np
import pandas as pd
from PIL import Image
import cStringIO as StringIO
import urllib
import exifutil
import caffe
REPO_DIRNAME = os.path.abs... | 7,793 | 33.184211 | 105 | py |
DRT | DRT-master/caffe/examples/web_demo/exifutil.py | """
This script handles the skimage exif problem.
"""
from PIL import Image
import numpy as np
ORIENTATIONS = { # used in apply_orientation
2: (Image.FLIP_LEFT_RIGHT,),
3: (Image.ROTATE_180,),
4: (Image.FLIP_TOP_BOTTOM,),
5: (Image.FLIP_LEFT_RIGHT, Image.ROTATE_90),
6: (Image.ROTATE_270,),
7... | 1,046 | 25.175 | 51 | py |
DRT | DRT-master/caffe/examples/pycaffe/caffenet.py | from __future__ import print_function
from caffe import layers as L, params as P, to_proto
from caffe.proto import caffe_pb2
# helper function for common structures
def conv_relu(bottom, ks, nout, stride=1, pad=0, group=1):
conv = L.Convolution(bottom, kernel_size=ks, stride=stride,
... | 2,112 | 36.732143 | 91 | py |
DRT | DRT-master/caffe/examples/pycaffe/layers/pyloss.py | import caffe
import numpy as np
class EuclideanLossLayer(caffe.Layer):
"""
Compute the Euclidean Loss in the same manner as the C++ EuclideanLossLayer
to demonstrate the class interface for developing layers in Python.
"""
def setup(self, bottom, top):
# check input pair
if len(bo... | 1,223 | 31.210526 | 79 | py |
DRT | DRT-master/caffe/examples/finetune_flickr_style/assemble_data.py | #!/usr/bin/env python
"""
Form a subset of the Flickr Style data, download images to dirname, and write
Caffe ImagesDataLayer training file.
"""
import os
import urllib
import hashlib
import argparse
import numpy as np
import pandas as pd
from skimage import io
import multiprocessing
# Flickr returns a special image i... | 3,636 | 35.737374 | 94 | py |
DRT | DRT-master/caffe/examples/coco_caption/hdf5_sequence_generator.py | #!/usr/bin/env python
import h5py
import numpy as np
import os
import random
import sys
class SequenceGenerator():
def __init__(self):
self.dimension = 10
self.batch_stream_length = 2000
self.batch_num_streams = 8
self.min_stream_length = 13
self.max_stream_length = 17
self.substream_names =... | 5,170 | 37.879699 | 101 | py |
DRT | DRT-master/caffe/examples/coco_caption/captioner.py | #!/usr/bin/env python
from collections import OrderedDict
import h5py
import math
import matplotlib.pyplot as plt
import numpy as np
import os
import random
import sys
sys.path.append('./python/')
import caffe
class Captioner():
def __init__(self, weights_path, image_net_proto, lstm_net_proto,
vocab... | 16,658 | 40.337469 | 88 | py |
DRT | DRT-master/caffe/examples/coco_caption/coco_to_hdf5_data.py | #!/usr/bin/env python
from hashlib import sha1
import os
import random
random.seed(3)
import re
import sys
sys.path.append('./examples/coco_caption/')
COCO_PATH = './data/coco/coco'
COCO_TOOL_PATH = '%s/PythonAPI/build/lib/pycocotools' % COCO_PATH
COCO_IMAGE_ROOT = '%s/images' % COCO_PATH
MAX_HASH = 100000
sys.pat... | 10,769 | 37.602151 | 100 | py |
DRT | DRT-master/caffe/examples/coco_caption/retrieval_experiment.py | #!/usr/bin/env python
from collections import OrderedDict
import json
import numpy as np
import pprint
import cPickle as pickle
import string
import sys
# seed the RNG so we evaluate on the same subset each time
np.random.seed(seed=0)
from coco_to_hdf5_data import *
from captioner import Captioner
COCO_EVAL_PATH = ... | 15,281 | 41.099174 | 89 | py |
DRT | DRT-master/caffe/src/caffe/test/test_data/generate_sample_data.py | """
Generate data used in the HDF5DataLayer and GradientBasedSolver tests.
"""
import os
import numpy as np
import h5py
script_dir = os.path.dirname(os.path.abspath(__file__))
# Generate HDF5DataLayer sample_data.h5
num_cols = 8
num_rows = 10
height = 6
width = 5
total_size = num_cols * num_rows * height * width
da... | 2,023 | 24.3 | 70 | py |
DRT | DRT-master/caffe/python/draw_net.py | #!/usr/bin/env python
"""
Draw a graph of the net architecture.
"""
from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter
from google.protobuf import text_format
import caffe
import caffe.draw
from caffe.proto import caffe_pb2
def parse_args():
"""Parse input arguments
"""
parser = Argument... | 1,389 | 29.217391 | 78 | py |
DRT | DRT-master/caffe/python/detect.py | #!/usr/bin/env python
"""
detector.py is an out-of-the-box windowed detector
callable from the command line.
By default it configures and runs the Caffe reference ImageNet model.
Note that this model was trained for image classification and not detection,
and finetuning for detection can be expected to improve results... | 5,743 | 32.011494 | 88 | py |
DRT | DRT-master/caffe/python/classify.py | #!/usr/bin/env python
"""
classify.py is an out-of-the-box image classifer callable from the command line.
By default it configures and runs the Caffe reference ImageNet model.
"""
import numpy as np
import os
import sys
import argparse
import glob
import time
import caffe
def main(argv):
pycaffe_dir = os.path.... | 4,262 | 29.669065 | 88 | py |
DRT | DRT-master/caffe/python/caffe/net_spec.py | """Python net specification.
This module provides a way to write nets directly in Python, using a natural,
functional style. See examples/pycaffe/caffenet.py for an example.
Currently this works as a thin wrapper around the Python protobuf interface,
with layers and parameters automatically generated for the "layers"... | 7,876 | 34.642534 | 82 | py |
DRT | DRT-master/caffe/python/caffe/classifier.py | #!/usr/bin/env python
"""
Classifier is an image classifier specialization of Net.
"""
import numpy as np
import caffe
class Classifier(caffe.Net):
"""
Classifier extends Net for image class prediction
by scaling, center cropping, or oversampling.
Parameters
----------
image_dims : dimensio... | 3,501 | 34.734694 | 78 | py |
DRT | DRT-master/caffe/python/caffe/detector.py | #!/usr/bin/env python
"""
Do windowed detection by classifying a number of images/crops at once,
optionally using the selective search window proposal method.
This implementation follows ideas in
Ross Girshick, Jeff Donahue, Trevor Darrell, Jitendra Malik.
Rich feature hierarchies for accurate object detection... | 8,562 | 38.460829 | 80 | py |
DRT | DRT-master/caffe/python/caffe/__init__.py | from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver
from ._caffe import set_mode_cpu, set_mode_gpu, set_device, Layer, get_solver, layer_type_list
from .proto.caffe_pb2 import TRAIN, TEST
from .classifier import Classifier
from .detector import Detector
from . i... | 385 | 47.25 | 109 | py |
DRT | DRT-master/caffe/python/caffe/pycaffe.py | """
Wrap the internal caffe C++ module (_caffe.so) with a clean, Pythonic
interface.
"""
from collections import OrderedDict
try:
from itertools import izip_longest
except:
from itertools import zip_longest as izip_longest
import numpy as np
from ._caffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, \... | 9,706 | 32.129693 | 80 | py |
DRT | DRT-master/caffe/python/caffe/draw.py | """
Caffe network visualization: draw the NetParameter protobuffer.
.. note::
This requires pydot>=1.0.2, which is not included in requirements.txt since
it requires graphviz and other prerequisites outside the scope of the
Caffe.
"""
from caffe.proto import caffe_pb2
import pydot
# Internal layer and ... | 7,216 | 32.724299 | 79 | py |
DRT | DRT-master/caffe/python/caffe/io.py | import numpy as np
import skimage.io
from scipy.ndimage import zoom
from skimage.transform import resize
try:
# Python3 will most likely not be able to load protobuf
from caffe.proto import caffe_pb2
except:
import sys
if sys.version_info >= (3, 0):
print("Failed to include caffe_pb2, things mi... | 12,575 | 32.094737 | 79 | py |
DRT | DRT-master/caffe/python/caffe/test/test_python_layer_with_param_str.py | import unittest
import tempfile
import os
import six
import caffe
class SimpleParamLayer(caffe.Layer):
"""A layer that just multiplies by the numeric value of its param string"""
def setup(self, bottom, top):
try:
self.value = float(self.param_str)
except ValueError:
... | 1,925 | 31.1 | 79 | py |
DRT | DRT-master/caffe/python/caffe/test/test_solver.py | import unittest
import tempfile
import os
import numpy as np
import six
import caffe
from test_net import simple_net_file
class TestSolver(unittest.TestCase):
def setUp(self):
self.num_output = 13
net_f = simple_net_file(self.num_output)
f = tempfile.NamedTemporaryFile(mode='w+', delete=F... | 1,849 | 33.259259 | 76 | py |
DRT | DRT-master/caffe/python/caffe/test/test_layer_type_list.py | import unittest
import caffe
class TestLayerTypeList(unittest.TestCase):
def test_standard_types(self):
for type_name in ['Data', 'Convolution', 'InnerProduct']:
self.assertIn(type_name, caffe.layer_type_list(),
'%s not in layer_type_list()' % type_name)
| 302 | 26.545455 | 65 | py |
DRT | DRT-master/caffe/python/caffe/test/test_net.py | import unittest
import tempfile
import os
import numpy as np
import six
import caffe
def simple_net_file(num_output):
"""Make a simple net prototxt, based on test_net.cpp, returning the name
of the (temporary) file."""
f = tempfile.NamedTemporaryFile(mode='w+', delete=False)
f.write("""name: 'testne... | 2,927 | 34.707317 | 78 | py |
DRT | DRT-master/caffe/python/caffe/test/test_net_spec.py | import unittest
import tempfile
import caffe
from caffe import layers as L
from caffe import params as P
def lenet(batch_size):
n = caffe.NetSpec()
n.data, n.label = L.DummyData(shape=[dict(dim=[batch_size, 1, 28, 28]),
dict(dim=[batch_size, 1, 1, 1])],
... | 3,287 | 39.097561 | 77 | py |
DRT | DRT-master/caffe/python/caffe/test/test_python_layer.py | import unittest
import tempfile
import os
import six
import caffe
class SimpleLayer(caffe.Layer):
"""A layer that just multiplies by ten"""
def setup(self, bottom, top):
pass
def reshape(self, bottom, top):
top[0].reshape(*bottom[0].data.shape)
def forward(self, bottom, top):
... | 4,604 | 31.659574 | 81 | py |
DRT | DRT-master/caffe/scripts/cpp_lint.py | #!/usr/bin/python2
#
# Copyright (c) 2009 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of... | 187,464 | 37.501746 | 93 | py |
DRT | DRT-master/caffe/scripts/download_model_binary.py | #!/usr/bin/env python
import os
import sys
import time
import yaml
import urllib
import hashlib
import argparse
required_keys = ['caffemodel', 'caffemodel_url', 'sha1']
def reporthook(count, block_size, total_size):
"""
From http://blog.moleculea.com/2012/10/04/urlretrieve-progres-indicator/
"""
glob... | 2,496 | 31.428571 | 78 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.