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 |
|---|---|---|---|---|---|---|
mmvae-public | mmvae-public/src/report/analyse_ms.py | """Calculate cross and joint coherence of trained model on MNIST-SVHN dataset.
Train and evaluate a linear model for latent space digit classification."""
import argparse
import os
import sys
import torch
import torch.nn as nn
import torch.optim as optim
# relative import hacks (sorry)
import inspect
currentdir = os... | 9,192 | 36.831276 | 113 | py |
mmvae-public | mmvae-public/src/report/helper.py | import json
import os
import pickle
from collections import Counter, OrderedDict
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from gensim.models import FastText
from nltk.tokenize import sent_tokenize, word_tokenize
from scipy.linalg import eig
from skimage.filters import thres... | 7,712 | 32.977974 | 110 | py |
mmvae-public | mmvae-public/src/report/calculate_likelihoods.py | """Calculate data marginal likelihood p(x) evaluated on the trained generative model."""
import os
import sys
import argparse
import numpy as np
import torch
from torchvision.utils import save_image
# relative import hacks (sorry)
import inspect
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.cur... | 7,240 | 38.785714 | 116 | py |
mmvae-public | mmvae-public/src/models/vae_svhn.py | # SVHN model specification
import torch
import torch.distributions as dist
import torch.nn as nn
import torch.nn.functional as F
from numpy import sqrt
from torch.utils.data import DataLoader
from torchvision import transforms, datasets
from torchvision.utils import save_image, make_grid
from utils import Constants
f... | 5,053 | 37 | 101 | py |
mmvae-public | mmvae-public/src/models/mmvae_cub_images_sentences.py | # cub multi-modal model specification
import matplotlib.pyplot as plt
import torch.distributions as dist
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.data
from numpy import sqrt, prod
from torch.utils.data import DataLoader
from torchnet.dataset import TensorDataset, ResampleDataset
from tor... | 6,015 | 42.912409 | 119 | py |
mmvae-public | mmvae-public/src/models/vae.py | # Base VAE class definition
import torch
import torch.nn as nn
from utils import get_mean, kl_divergence
from vis import embed_umap, tensors_to_df
class VAE(nn.Module):
def __init__(self, prior_dist, likelihood_dist, post_dist, enc, dec, params):
super(VAE, self).__init__()
self.pz = prior_dist
... | 2,674 | 32.024691 | 89 | py |
mmvae-public | mmvae-public/src/models/vae_cub_image.py | # CUB Image model specification
import torch
import torch.distributions as dist
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.data
from numpy import sqrt
from torchvision import datasets, transforms
from torchvision.utils import make_grid, save_image
from utils import Constants
from vis imp... | 5,350 | 37.221429 | 91 | py |
mmvae-public | mmvae-public/src/models/vae_mnist.py | # MNIST model specification
import torch
import torch.distributions as dist
import torch.nn as nn
import torch.nn.functional as F
from numpy import prod, sqrt
from torch.utils.data import DataLoader
from torchvision import datasets, transforms
from torchvision.utils import save_image, make_grid
from utils import Cons... | 4,623 | 37.857143 | 101 | py |
mmvae-public | mmvae-public/src/models/vae_cub_sent_ft.py | # Sentence model specification - CUB image feature version
import json
import os
import numpy as np
import torch
import torch.distributions as dist
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.data
from torch.utils.data import DataLoader
from datasets import CUBSentences
from utils import ... | 8,185 | 40.135678 | 103 | py |
mmvae-public | mmvae-public/src/models/mmvae.py | # Base MMVAE class definition
from itertools import combinations
import torch
import torch.nn as nn
from utils import get_mean, kl_divergence
from vis import embed_umap, tensors_to_df
class MMVAE(nn.Module):
def __init__(self, prior_dist, params, *vaes):
super(MMVAE, self).__init__()
self.pz = ... | 3,238 | 37.105882 | 92 | py |
mmvae-public | mmvae-public/src/models/__init__.py | from .mmvae_cub_images_sentences import CUB_Image_Sentence as VAE_cubIS
from .mmvae_cub_images_sentences_ft import CUB_Image_Sentence_ft as VAE_cubISft
from .mmvae_mnist_svhn import MNIST_SVHN as VAE_mnist_svhn
from .vae_cub_image import CUB_Image as VAE_cubI
from .vae_cub_image_ft import CUB_Image_ft as VAE_cubIft
fro... | 565 | 46.166667 | 79 | py |
mmvae-public | mmvae-public/src/models/vae_cub_sent.py | # Sentence model specification - real CUB image version
import os
import json
import numpy as np
import torch
import torch.distributions as dist
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.data
from torch.utils.data import DataLoader
from datasets import CUBSentences
from utils import Con... | 8,186 | 39.935 | 103 | py |
mmvae-public | mmvae-public/src/models/mmvae_cub_images_sentences_ft.py | # cub multi-modal model specification
import matplotlib.pyplot as plt
import torch.distributions as dist
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.data
from numpy import sqrt, prod
from torch.utils.data import DataLoader
from torchnet.dataset import TensorDataset, ResampleDataset
from tor... | 6,432 | 44.302817 | 119 | py |
mmvae-public | mmvae-public/src/models/vae_cub_image_ft.py | # CUB Image feature model specification
import torch
import torch.distributions as dist
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.data
from numpy import sqrt
from torchvision.utils import make_grid, save_image
from datasets import CUBImageFt
from utils import Constants, NN_lookup
from v... | 5,311 | 38.348148 | 100 | py |
mmvae-public | mmvae-public/src/models/mmvae_mnist_svhn.py | # MNIST-SVHN multi-modal model specification
import os
import torch
import torch.distributions as dist
import torch.nn as nn
import torch.nn.functional as F
from numpy import sqrt, prod
from torch.utils.data import DataLoader
from torchnet.dataset import TensorDataset, ResampleDataset
from torchvision.utils import sav... | 4,479 | 45.185567 | 101 | py |
mmvae-public | mmvae-public/bin/make-mnist-svhn-idx.py | import torch
from torchvision import datasets, transforms
def rand_match_on_idx(l1, idx1, l2, idx2, max_d=10000, dm=10):
"""
l*: sorted labels
idx*: indices of sorted labels in original list
"""
_idx1, _idx2 = [], []
for l in l1.unique(): # assuming both have same idxs
l_idx1, l_idx2 =... | 2,087 | 44.391304 | 90 | py |
MinkLoc3D | MinkLoc3D-master/training/train.py | # Author: Jacek Komorowski
# Warsaw University of Technology
import argparse
import torch
from training.trainer import do_train
from misc.utils import MinkLocParams
from datasets.dataset_utils import make_dataloaders
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Train Minkowski Net em... | 1,341 | 37.342857 | 120 | py |
MinkLoc3D | MinkLoc3D-master/training/trainer.py | # Author: Jacek Komorowski
# Warsaw University of Technology
# Train on Oxford dataset (from PointNetVLAD paper) using BatchHard hard negative mining.
import os
from datetime import datetime
import numpy as np
import torch
import pickle
import tqdm
import pathlib
from torch.utils.tensorboard import SummaryWriter
fr... | 10,845 | 39.17037 | 139 | py |
MinkLoc3D | MinkLoc3D-master/eval/evaluate.py | # Author: Jacek Komorowski
# Warsaw University of Technology
# Evaluation code adapted from PointNetVlad code: https://github.com/mikacuy/pointnetvlad
from sklearn.neighbors import KDTree
import numpy as np
import pickle
import os
import argparse
import torch
import tqdm
import MinkowskiEngine as ME
import random
fr... | 7,883 | 36.542857 | 120 | py |
MinkLoc3D | MinkLoc3D-master/models/minkloc.py | # Author: Jacek Komorowski
# Warsaw University of Technology
import torch
import MinkowskiEngine as ME
from models.minkfpn import MinkFPN
from models.netvlad import MinkNetVladWrapper
import layers.pooling as pooling
class MinkLoc(torch.nn.Module):
def __init__(self, model, in_channels, feature_size, output_dim... | 3,242 | 50.47619 | 141 | py |
MinkLoc3D | MinkLoc3D-master/models/model_factory.py | # Author: Jacek Komorowski
# Warsaw University of Technology
import models.minkloc as minkloc
def model_factory(params):
in_channels = 1
if 'MinkFPN' in params.model_params.model:
model = minkloc.MinkLoc(params.model_params.model, in_channels=in_channels,
feature_size... | 793 | 38.7 | 113 | py |
MinkLoc3D | MinkLoc3D-master/models/resnet.py | # Copyright (c) Chris Choy (chrischoy@ai.stanford.edu).
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, ... | 5,315 | 31.814815 | 87 | py |
MinkLoc3D | MinkLoc3D-master/models/minkfpn.py | # Author: Jacek Komorowski
# Warsaw University of Technology
import torch.nn as nn
import MinkowskiEngine as ME
from MinkowskiEngine.modules.resnet_block import BasicBlock
from models.resnet import ResNetBase
class MinkFPN(ResNetBase):
# Feature Pyramid Network (FPN) architecture implementation using Minkowski R... | 4,364 | 44.947368 | 125 | py |
MinkLoc3D | MinkLoc3D-master/models/loss.py | # Author: Jacek Komorowski
# Warsaw University of Technology
import numpy as np
import torch
from pytorch_metric_learning import losses, miners, reducers
from pytorch_metric_learning.distances import LpDistance
def make_loss(params):
if params.loss == 'BatchHardTripletMarginLoss':
# BatchHard mining with... | 6,696 | 49.353383 | 118 | py |
MinkLoc3D | MinkLoc3D-master/models/netvlad.py | # Code taken from PointNetVLAD Pytorch implementation: https://github.com/cattaneod/PointNetVlad-Pytorch
# Adapted by Jacek Komorowski
import torch
import torch.nn as nn
import torch.utils.data
import torch.nn.functional as F
import math
# NOTE: The toolbox can only pool lists of features of the same length. It was s... | 5,287 | 38.17037 | 118 | py |
MinkLoc3D | MinkLoc3D-master/datasets/dataset_utils.py | # Author: Jacek Komorowski
# Warsaw University of Technology
import numpy as np
import torch
from torch.utils.data import DataLoader
import MinkowskiEngine as ME
from datasets.oxford import OxfordDataset, TrainTransform, TrainSetTransform
from datasets.samplers import BatchSampler
from misc.utils import MinkLocParams... | 4,547 | 44.48 | 125 | py |
MinkLoc3D | MinkLoc3D-master/datasets/oxford.py | # Author: Jacek Komorowski
# Warsaw University of Technology
# Dataset wrapper for Oxford laser scans dataset from PointNetVLAD project
# For information on dataset see: https://github.com/mikacuy/pointnetvlad
import os
import pickle
import numpy as np
import math
from scipy.linalg import expm, norm
import random
imp... | 10,148 | 33.40339 | 115 | py |
MinkLoc3D | MinkLoc3D-master/datasets/samplers.py | # Author: Jacek Komorowski
# Warsaw University of Technology
import random
import copy
from torch.utils.data import Sampler
from datasets.oxford import OxfordDataset
class ListDict(object):
def __init__(self, items=None):
if items is not None:
self.items = copy.deepcopy(items)
s... | 5,532 | 38.805755 | 114 | py |
MinkLoc3D | MinkLoc3D-master/layers/pooling.py | # Code taken from: https://github.com/filipradenovic/cnnimageretrieval-pytorch
# and ported to MinkowskiEngine by Jacek Komorowski
import torch
import torch.nn as nn
import MinkowskiEngine as ME
class MAC(nn.Module):
def __init__(self):
super().__init__()
self.f = ME.MinkowskiGlobalMaxPooling()
... | 1,280 | 30.243902 | 84 | py |
MinkLoc3D | MinkLoc3D-master/misc/utils.py | # Author: Jacek Komorowski
# Warsaw University of Technology
import os
import configparser
import time
import numpy as np
class ModelParams:
def __init__(self, model_params_path):
config = configparser.ConfigParser()
config.read(model_params_path)
params = config['MODEL']
self.mo... | 7,153 | 39.88 | 140 | py |
MinkLoc3D | MinkLoc3D-master/generating_queries/generate_test_sets.py | # PointNetVLAD datasets: based on Oxford RobotCar and Inhouse
# Code adapted from PointNetVLAD repo: https://github.com/mikacuy/pointnetvlad
import numpy as np
import os
import pandas as pd
from sklearn.neighbors import KDTree
import pickle
import argparse
# For training and test data splits
X_WIDTH = 150
Y_WIDTH = 1... | 6,937 | 40.54491 | 119 | py |
MinkLoc3D | MinkLoc3D-master/generating_queries/generate_training_tuples_baseline.py | # PointNetVLAD datasets: based on Oxford RobotCar and Inhouse
# Code adapted from PointNetVLAD repo: https://github.com/mikacuy/pointnetvlad
import numpy as np
import os
import pandas as pd
from sklearn.neighbors import KDTree
import pickle
import argparse
import tqdm
from datasets.oxford import TrainingTuple
# Impor... | 4,386 | 43.765306 | 123 | py |
MinkLoc3D | MinkLoc3D-master/generating_queries/generate_training_tuples_refine.py | # PointNetVLAD datasets: based on Oxford RobotCar and Inhouse
# Code adapted from PointNetVLAD repo: https://github.com/mikacuy/pointnetvlad
import os
import pandas as pd
import argparse
import tqdm
# Import test set boundaries
from generating_queries.generate_test_sets import P1, P2, P3, P4, P5, P6, P7, P8, P9, P10,... | 3,216 | 38.716049 | 123 | py |
RadarCommDataset | RadarCommDataset-main/load_dataset.py | import h5py
dkeys = [] # labels of each entry in the h5
W = [] # dataset container
with h5py.File('RadComDynamic.hdf5', 'r') as f:
for key in f.keys():
dkeys.append(key)
W.append(f[key][:])
f.close()
# W can be now split into training, validation,and testing sets to run your ML algorithm on... | 324 | 24 | 94 | py |
RadarCommDataset | RadarCommDataset-main/visualize.py | import h5py
import sys
import argparse
import matplotlib.pyplot as plt
def parse_args():
"Parse the command line arguments"
parser = argparse.ArgumentParser()
parser.add_argument("-num", type=int,default="0",
help="Which sample to pick. 0 to 699")
parser.add_argument("-snr", typ... | 1,281 | 32.736842 | 160 | py |
pydeps | pydeps-master/setup.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""pydeps - Python module dependency visualization
"""
# pragma: nocover
import io
import sys
import setuptools
from setuptools.command.test import test as TestCommand
version='1.12.12'
class PyTest(TestCommand):
user_options = [('pytest-args=', 'a', "Arguments to ... | 1,918 | 26.811594 | 74 | py |
pydeps | pydeps-master/tasks.py | # pragma: nocover
from invoke import Collection, task
from dktasklib import version
from dktasklib import upversion
from dktasklib import publish
from dktasklib import docs
from dktasklib.package import Package, package
@task
def freeze(ctx):
"pip freeze, but without -e installed packages"
ctx.run("pip list -... | 659 | 16.368421 | 58 | py |
pydeps | pydeps-master/pydeps/target.py | # -*- coding: utf-8 -*-
"""
Abstracting the target for pydeps to work on.
"""
from __future__ import print_function
import json
import os
import re
import shutil
import sys
import tempfile
from contextlib import contextmanager
import logging
log = logging.getLogger(__name__)
class Target(object):
"""The compilati... | 3,933 | 32.058824 | 103 | py |
pydeps | pydeps-master/pydeps/dot.py | # -*- coding: utf-8 -*-
"""
Graphviz interface.
"""
import os
import platform
import sys
from subprocess import Popen
import subprocess
import shlex
from . import cli
win32 = sys.platform == 'win32'
def is_unicode(s): # pragma: nocover
"""Test unicode with py3 support.
"""
try:
return isinstanc... | 2,906 | 23.024793 | 74 | py |
pydeps | pydeps-master/pydeps/__main__.py | from .pydeps import pydeps
pydeps()
| 36 | 11.333333 | 26 | py |
pydeps | pydeps-master/pydeps/pystdlib.py | # -*- coding: utf-8 -*-
import sys
import stdlib_list
import warnings
def pystdlib():
"""Return a set of all module-names in the Python standard library.
"""
if sys.version_info[:2] >= (3, 10):
# Python 3.10 has this functionality built-in.
return list(sys.stdlib_module_names | set(sys.bu... | 1,969 | 43.772727 | 76 | py |
pydeps | pydeps-master/pydeps/depgraph2dot.py | # Based on original code, Copyright 2004 Toby Dickenson,
# with changes 2014 (c) Bjorn Pettersen
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without lim... | 4,638 | 33.110294 | 74 | py |
pydeps | pydeps-master/pydeps/arguments.py | from __future__ import print_function, unicode_literals
from io import StringIO
import textwrap
import json
import argparse
# from devtools import debug
from .configs import Config, typefns, identity
DEFAULT_NONE = '____'
class Argument(object):
def __init__(self, *flags, **args):
if 'choices' in arg... | 7,599 | 31.067511 | 134 | py |
pydeps | pydeps-master/pydeps/mfimp.py | """
Python's modulefinder._find_module has a bug that breaks a number of popular
packages.
This is a copy of the standard lib's imp._find_module which sort of does the
right thing, ie. ignores namespace packages instead of crashing.
This is vendorized/copied here to prevent the warning error that the regular
imp mod... | 2,445 | 31.613333 | 79 | py |
pydeps | pydeps-master/pydeps/render_context.py | # -*- coding: utf-8 -*-
from collections import defaultdict
from io import StringIO
from contextlib import contextmanager
import textwrap
import enum
def to_unicode(s):
try:
return unicode(s)
except NameError:
return s
class Rankdir(enum.Enum):
BOTTOM_TOP = 'BT'
TOP_BOTTOM = 'TB'
... | 11,072 | 33.388199 | 125 | py |
pydeps | pydeps-master/pydeps/dummymodule.py | # -*- coding: utf-8 -*-
from __future__ import print_function
import os
import textwrap
import logging
from . import cli
log = logging.getLogger(__name__)
def is_module(directory):
"""A directory is a module if it contains an ``__init__.py`` file.
"""
return os.path.isdir(directory) and '__init__.py' in... | 5,638 | 36.344371 | 97 | py |
pydeps | pydeps-master/pydeps/cli.py | # -*- coding: utf-8 -*-
"""
command line interface (cli) code.
"""
# pylint: disable=line-too-long
from __future__ import print_function
import argparse
from pydeps.configs import Config
from .arguments import Arguments
# import json
# from .pycompat import configparser
import logging
import os
import sys
import subpr... | 10,311 | 46.302752 | 196 | py |
pydeps | pydeps-master/pydeps/pycompat.py | # -*- coding: utf-8 -*-
"""
Compatibility imports between py2/py3
"""
# pragma: nocover
try:
from itertools import zip_longest # noqa
except ImportError:
from itertools import izip_longest as zip_longest # noqa
try:
import configparser # noqa
except Impor... | 391 | 25.133333 | 62 | py |
pydeps | pydeps-master/pydeps/package_names.py | # -*- coding: utf-8 -*-
from __future__ import print_function
import os
import site
def _find_top_level_file(site_pkg_dir, pth):
if pth.endswith('.dist-info') or pth.endswith('.egg-info'):
top_level_fname = os.path.join(site_pkg_dir, pth, 'top_level.txt')
elif pth.endswith('.egg'):
top_level_f... | 1,892 | 29.047619 | 86 | py |
pydeps | pydeps-master/pydeps/__init__.py | # -*- coding: utf-8 -*-
"""
Python module dependency visualization. This package installs the ``pydeps``
command, and normal usage will be to use it from the command line.
"""
__version__ = "1.12.12"
| 200 | 27.714286 | 76 | py |
pydeps | pydeps-master/pydeps/mf27.py |
# from .mf.mf_next import * # for debugging next version
import modulefinder
from modulefinder import (
ModuleFinder as NativeModuleFinder
)
from importlib.util import MAGIC_NUMBER
import marshal
import dis
from . import mfimp
HAVE_ARGUMENT = dis.HAVE_ARGUMENT
# from stdlib's modulefinder
_PY_SOURCE = mfimp.... | 5,842 | 38.47973 | 112 | py |
pydeps | pydeps-master/pydeps/pydeps.py | # -*- coding: utf-8 -*-
"""cli entrypoints.
"""
from __future__ import print_function
import json
import os
import sys
from pydeps.configs import Config
from . import py2depgraph, cli, dot, target
from .depgraph2dot import dep2dot, cycles2dot
import logging
from . import colors
log = logging.getLogger(__name__)
def ... | 7,175 | 32.376744 | 106 | py |
pydeps | pydeps-master/pydeps/py2depgraph.py | # Copyright 2004,2009 Toby Dickenson
# Changes 2014 (c) Bjorn Pettersen
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use... | 10,490 | 35.681818 | 150 | py |
pydeps | pydeps-master/pydeps/depgraph.py | # -*- coding: utf-8 -*-
from __future__ import print_function
from collections import defaultdict
import fnmatch
from .pycompat import zip_longest
import json
import os
import pprint
import re
import enum
from . import colors, cli
import sys
import logging
log = logging.getLogger(__name__)
# we're normally not intere... | 15,089 | 32.019694 | 103 | py |
pydeps | pydeps-master/pydeps/configs.py |
from io import StringIO
import json
import warnings
import logging
log = logging.getLogger(__name__)
# from devtools import debug
HAVE_TOML = False
try:
import tomllib as toml
HAVE_TOML = True
except ImportError:
try:
import tomlkit as toml
HAVE_TOML = True
except ImportError:
... | 11,463 | 26.757869 | 101 | py |
pydeps | pydeps-master/pydeps/colors.py | # -*- coding: utf-8 -*-
"""Color calculations.
"""
import colorsys
# noinspection PyAugmentAssignment
# import hashlib
START_COLOR = 0 # Value can be changed from command-line argument
def frange(start, end, step):
"""Like range(), but with floats.
"""
val = start
while val < end:
yield val... | 2,957 | 24.282051 | 75 | py |
pydeps | pydeps-master/pydeps/tools/pydeps2requirements.py | # -*- coding: utf-8 -*-
"""
Generate requirements.txt from pydeps output...
Usage::
pydeps <packagename> --max-bacon=0 \
--show-raw-deps --nodot \
--noshow | python pydeps2requirements.py
"""
import json
import os
import site
import sys
from collections import defaultdict
from pydeps.packa... | 2,587 | 24.623762 | 88 | py |
pydeps | pydeps-master/tests/test_dep2dot.py | # -*- coding: utf-8 -*-
import os
import sys
import pydeps.cli
from pydeps import pydeps
from pydeps.target import Target
from tests.filemaker import create_files
from tests.simpledeps import simpledeps
def test_dep2dot():
files = """
foo:
- __init__.py
- a.py: |
f... | 648 | 22.178571 | 63 | py |
pydeps | pydeps-master/tests/test_externals.py | # -*- coding: utf-8 -*-
import ast
from pydeps.pydeps import pydeps
from tests.filemaker import create_files
from tests.simpledeps import simpledeps
def test_relative_imports(capsys):
files = """
foo:
- __init__.py
- a.py: |
from bar import b
bar:
... | 638 | 22.666667 | 50 | py |
pydeps | pydeps-master/tests/test_dot.py | # -*- coding: utf-8 -*-
from pydeps.dot import dot, cmd2args
def test_svg(tmpdir):
tmpdir.chdir()
ab = tmpdir.join('ab.svg')
dot(u"""
digraph G {
a -> b
}
""", o=ab.basename)
assert ab.exists()
def test_svg_str(tmpdir):
tmpdir.chdir()
ab = tmpdir.join('ab.svg')
dot("""... | 1,161 | 17.444444 | 41 | py |
pydeps | pydeps-master/tests/test_skinny_package.py | # -*- coding: utf-8 -*-
from tests.filemaker import create_files
from tests.simpledeps import simpledeps
def test_from_html5lib():
files = """
foo:
- __init__.py
- a.py: |
from bar import py
bar:
- __init__.py
"""
with create_files(files)... | 435 | 21.947368 | 63 | py |
pydeps | pydeps-master/tests/test_cli.py | # -*- coding: utf-8 -*-
import os
from pydeps.cli import error
from pydeps.pydeps import pydeps
from tests.filemaker import create_files
from tests.simpledeps import simpledeps, empty
def test_output(tmpdir):
files = """
unrelated: []
foo:
- __init__.py
- a.py: |
... | 2,357 | 28.111111 | 108 | py |
pydeps | pydeps-master/tests/test_dirtree.py | # -*- coding: utf-8 -*-
from pydeps.pydeps import pydeps
from tests.filemaker import create_files
from tests.simpledeps import simpledeps
import pytest
@pytest.mark.skip(reason="TODO: fix this (issue #174)")
def test_dirtree():
files = """
foo:
- a:
- __init__.py: ''
... | 633 | 24.36 | 63 | py |
pydeps | pydeps-master/tests/test_json.py | # -*- coding: utf-8 -*-
import json
import os
from pydeps import pydeps
from tests.filemaker import create_files
from tests.simpledeps import simpledeps, depgrf
def test_dep2dot():
files = """
foo:
- __init__.py
- a.py: |
from . import b
- b.py
"""
... | 654 | 25.2 | 58 | py |
pydeps | pydeps-master/tests/test_config.py | # -*- coding: utf-8 -*-
# from devtools import debug
from pydeps.cli import parse_args
from tests.filemaker import create_files
from tests.simpledeps import simpledeps
def test_pydeps_config_ini():
files = """
config.ini: |
[pydeps]
rankdir = BT
exclude =
... | 4,035 | 23.760736 | 61 | py |
pydeps | pydeps-master/tests/filemaker.py | # -*- coding: utf-8 -*-
from contextlib import contextmanager
import os
import shutil
import tempfile
import yaml
class FilemakerBase(object): # pragma: nocover
"""Override marked methods to do something useful. Base class serves as
a dry-run step generator.
"""
def __init__(self, root, fdef):
... | 2,606 | 25.333333 | 76 | py |
pydeps | pydeps-master/tests/test_skip.py | # -*- coding: utf-8 -*-
from __future__ import print_function
from tests.filemaker import create_files
from tests.simpledeps import simpledeps, depgrf
def test_no_skip():
files = """
relimp:
- __init__.py
- a.py: |
from . import b
- b.py: |
... | 3,232 | 25.284553 | 72 | py |
pydeps | pydeps-master/tests/test_pyw.py | # -*- coding: utf-8 -*-
import sys
from tests.filemaker import create_files
from tests.simpledeps import simpledeps
import pytest
@pytest.mark.skipif(sys.platform != 'win32', reason=".pyw files only exist on windows")
def test_from_pyw():
files = """
baz.pyw: |
import foo.a
import ... | 706 | 24.25 | 87 | py |
pydeps | pydeps-master/tests/test_cycles.py | # -*- coding: utf-8 -*-
from tests.filemaker import create_files
from tests.simpledeps import simpledeps
def test_cycle():
files = """
relimp:
- __init__.py
- a.py: |
from . import b
- b.py: |
from . import a
"""
with create_files... | 518 | 24.95 | 55 | py |
pydeps | pydeps-master/tests/test_colors.py | # -*- coding: utf-8 -*-
import os
from pydeps.colors import rgb2css, brightness, brightnessdiff, colordiff, name2rgb, foreground
red = (255, 0, 0)
green = (0, 255, 0)
yellow = (0, 255, 255)
blue = (0, 0, 255)
black = (0, 0, 0)
white = (255, 255, 255)
def test_rgb2css():
assert rgb2css(red) == '#ff0000'
asse... | 1,194 | 24.978261 | 94 | py |
pydeps | pydeps-master/tests/test_package_names.py |
from pydeps.package_names import find_package_names
def test_find_package_names():
packages = find_package_names()
assert 'pip' in packages
assert 'pytest' in packages
| 184 | 17.5 | 51 | py |
pydeps | pydeps-master/tests/test_relative_imports.py | # -*- coding: utf-8 -*-
import os
import sys
from tests.filemaker import create_files
from tests.simpledeps import simpledeps
import pytest
def test_relative_imports():
files = """
relimp:
- __init__.py
- a.py: |
from . import b
- b.py
"""
with c... | 2,990 | 24.784483 | 68 | py |
pydeps | pydeps-master/tests/simpledeps.py | import pydeps.cli
from pydeps import pydeps
from pydeps.py2depgraph import py2dep
from pydeps.target import Target
def empty(args="", **kw):
args = pydeps.cli.parse_args(['foo', '--no-config'] + args.split())
args.pop('fname')
args.update(kw)
return args
def depgrf(item, args=""):
t = Target(ite... | 572 | 21.92 | 73 | py |
pydeps | pydeps-master/tests/__init__.py | # -*- coding: utf-8 -*-
| 26 | 5.75 | 23 | py |
pydeps | pydeps-master/tests/test_file.py | # -*- coding: utf-8 -*-
import os
from pydeps.py2depgraph import py2dep
from pydeps.pydeps import _pydeps
from pydeps.target import Target
from tests.filemaker import create_files
from tests.simpledeps import empty, simpledeps
def test_file():
files = """
a.py: |
import collections
"""
... | 1,816 | 24.591549 | 83 | py |
pydeps | pydeps-master/tests/test_py2dep.py | # -*- coding: utf-8 -*-
import os
# from devtools import debug
from pydeps.pydeps import call_pydeps
from tests.filemaker import create_files
from tests.simpledeps import simpledeps
def test_py2depgraph(capsys):
files = """
- a.py: |
import b
- b.py
"""
with create_files(files)... | 783 | 22.757576 | 73 | py |
pydeps | pydeps-master/tests/test_cluster.py | import os
from pydeps.cli import parse_args
from pydeps.pydeps import pydeps
from tests.filemaker import create_files
from tests.simpledeps import simpledeps
def test_cluster():
files = """
- bar_module:
- __init__.py: ''
- bar_a:
- __init__.py: ''
-... | 1,535 | 32.391304 | 109 | py |
pydeps | pydeps-master/tests/test_funny_names.py | # -*- coding: utf-8 -*-
from pydeps.pydeps import pydeps
from tests.filemaker import create_files
from tests.simpledeps import simpledeps
def test_from_html5lib():
files = """
foo:
- __init__.py
- a.py: |
from bar import py
bar:
- __init__.py
... | 813 | 22.941176 | 78 | py |
pydeps | pydeps-master/tests/test_render_context.py | # -*- coding: utf-8 -*-
from pydeps.render_context import RenderContext, Rankdir
def test_render_context():
ctx = RenderContext()
with ctx.graph():
ctx.write_rule('a', 'b')
assert 'a -> b' in ctx.text()
assert 'b -> a' not in ctx.text()
assert 'rankdir = TB' in ctx.text()
def test_render... | 827 | 26.6 | 73 | py |
pydeps | pydeps-master/docs/conf.py | # -*- coding: utf-8 -*-
#
# pydeps documentation build configuration file, created by
# sphinx-quickstart on Thu Feb 13 18:59:19 2014.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All ... | 8,225 | 30.760618 | 80 | py |
pydeps | pydeps-master/docs/module-finder-archive/mf_36.py | """Find modules used by a script, using introspection."""
import dis
import importlib._bootstrap_external
import importlib.machinery
import marshal
import os
import sys
import types
import struct
import warnings
with warnings.catch_warnings():
warnings.simplefilter('ignore', DeprecationWarning)
import imp
LOA... | 23,027 | 35.321767 | 97 | py |
pydeps | pydeps-master/docs/module-finder-archive/mf_310.py | """Find modules used by a script, using introspection."""
import dis
import importlib._bootstrap_external
import importlib.machinery
import marshal
import os
import io
import sys
LOAD_CONST = dis.opmap['LOAD_CONST']
IMPORT_NAME = dis.opmap['IMPORT_NAME']
STORE_NAME = dis.opmap['STORE_NAME']
STORE_GLOBAL = dis.opmap[... | 24,401 | 34.571429 | 86 | py |
pydeps | pydeps-master/docs/module-finder-archive/mf_27.py | """Find modules used by a script, using introspection."""
from __future__ import generators
import dis
import imp
import marshal
import os
import sys
import types
import struct
if hasattr(sys.__stdout__, "newlines"):
READ_MODE = "U" # universal line endings
else:
# Python < 2.3 compatibility, no longer stric... | 24,461 | 34.973529 | 86 | py |
pydeps | pydeps-master/docs/module-finder-archive/mf_39.py | """Find modules used by a script, using introspection."""
import dis
import importlib._bootstrap_external
import importlib.machinery
import marshal
import os
import io
import sys
LOAD_CONST = dis.opmap['LOAD_CONST']
IMPORT_NAME = dis.opmap['IMPORT_NAME']
STORE_NAME = dis.opmap['STORE_NAME']
STORE_GLOBAL = dis.opmap[... | 24,401 | 34.571429 | 86 | py |
pydeps | pydeps-master/docs/module-finder-archive/mf_pydeps_orig.py | """Find modules used by a script, using introspection."""
# This module should be kept compatible with Python 2.2, see PEP 291.
from __future__ import print_function
from __future__ import generators
import dis
import imp
import marshal
import os
import sys
import types
import struct
READ_MODE = "r"
LOAD_CONST = dis... | 26,278 | 35.651325 | 112 | py |
pydeps | pydeps-master/docs/module-finder-archive/mf_next.py | """Find modules used by a script, using introspection."""
import dis
import importlib._bootstrap_external
import importlib.machinery
import marshal
import os
import io
import sys
# Old imp constants:
_SEARCH_ERROR = 0
_PY_SOURCE = 1
_PY_COMPILED = 2
_C_EXTENSION = 3
_PKG_DIRECTORY = 5
_C_BUILTIN = 6
_PY_FROZEN = 7
... | 23,699 | 34.532234 | 86 | py |
pydeps | pydeps-master/docs/module-finder-archive/mf_35.py | """Find modules used by a script, using introspection."""
import dis
import importlib._bootstrap_external
import importlib.machinery
import marshal
import os
import sys
import types
import struct
import warnings
with warnings.catch_warnings():
warnings.simplefilter('ignore', PendingDeprecationWarning)
import i... | 23,085 | 35.355906 | 97 | py |
pydeps | pydeps-master/docs/module-finder-archive/__init__.py | 0 | 0 | 0 | py | |
pydeps | pydeps-master/docs/module-finder-archive/mf_38.py | """Find modules used by a script, using introspection."""
import dis
import importlib._bootstrap_external
import importlib.machinery
import marshal
import os
import io
import sys
import types
import warnings
LOAD_CONST = dis.opmap['LOAD_CONST']
IMPORT_NAME = dis.opmap['IMPORT_NAME']
STORE_NAME = dis.opmap['STORE_NAM... | 24,430 | 34.510174 | 86 | py |
pydeps | pydeps-master/docs/module-finder-archive/mf_37.py | """Find modules used by a script, using introspection."""
import dis
import importlib._bootstrap_external
import importlib.machinery
import marshal
import os
import sys
import types
import warnings
with warnings.catch_warnings():
warnings.simplefilter('ignore', DeprecationWarning)
import imp
LOAD_CONST = dis.... | 23,035 | 35.334385 | 86 | py |
MRE-ISE | MRE-ISE-main/run.py | import argparse
import logging
import sys
sys.path.append("..")
import torch
import numpy as np
import random
from torchvision import transforms
from torch.utils.data import DataLoader
from cores.gene.model import MRE
from transformers import CLIPProcessor, CLIPModel
from transformers import CLIPConfig
from processor... | 9,056 | 52.276471 | 187 | py |
MRE-ISE | MRE-ISE-main/VSG/RelTR_parser/visual_scene_graph.py | import os
import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision.transforms as T
from PIL import Image
import requests
import matplotlib.pyplot as plt
import json
import pickle
import ast
from tqdm import tqdm
from transformers import CLIPProcessor, CLIPModel
import cv2
from models.back... | 12,857 | 45.086022 | 341 | py |
MRE-ISE | MRE-ISE-main/VSG/VG_parser/config.py | """
Configuration file!
"""
import os
from argparse import ArgumentParser
import numpy as np
ROOT_PATH = os.path.dirname(os.path.realpath(__file__))
DATA_PATH = os.path.join(ROOT_PATH, 'data')
def path(fn):
return os.path.join(DATA_PATH, fn)
def stanford_path(fn):
return os.path.join(DATA_PATH, 'stanford_fil... | 8,445 | 41.656566 | 212 | py |
MRE-ISE | MRE-ISE-main/VSG/VG_parser/models/eval_rels.py |
from dataloaders.visual_genome import VGDataLoader, VG
import numpy as np
import torch
from config import ModelConfig
from lib.pytorch_misc import optimistic_restore
from lib.evaluation.sg_eval import BasicSceneGraphEvaluator
from tqdm import tqdm
from config import BOX_SCALE, IM_SCALE
import dill as pkl
import os
c... | 4,353 | 37.530973 | 89 | py |
MRE-ISE | MRE-ISE-main/VSG/VG_parser/models/train_detector.py | """
Training script 4 Detection
"""
from dataloaders.mscoco import CocoDetection, CocoDataLoader
from dataloaders.visual_genome import VGDataLoader, VG
from lib.object_detector import ObjectDetector
import numpy as np
from torch import optim
import torch
import pandas as pd
import time
import os
from config import Mode... | 9,155 | 40.808219 | 115 | py |
MRE-ISE | MRE-ISE-main/VSG/VG_parser/models/eval_rel_count.py | """
Baseline model that works by simply iterating through the training set to make a dictionary.
Also, caches this (we can use this for training).
The model is quite simple, so we don't use the base train/test code
"""
from dataloaders.visual_genome import VGDataLoader, VG
from lib.object_detector import ObjectDetec... | 9,552 | 36.758893 | 116 | py |
MRE-ISE | MRE-ISE-main/VSG/VG_parser/models/_visualize.py | """
Visualization script. I used this to create the figures in the paper.
WARNING: I haven't tested this in a while. It's possible that some later features I added break things here, but hopefully there should be easy fixes. I'm uploading this in the off chance it might help someone. If you get it to work, let me know... | 9,693 | 36.867188 | 280 | py |
MRE-ISE | MRE-ISE-main/VSG/VG_parser/models/train_rels.py | """
Training script for scene graph detection. Integrated with my faster rcnn setup
"""
from dataloaders.visual_genome import VGDataLoader, VG
import numpy as np
from torch import optim
import torch
import pandas as pd
import time
import os
from config import ModelConfig, BOX_SCALE, IM_SCALE
from torch.nn import func... | 8,782 | 41.225962 | 130 | py |
MRE-ISE | MRE-ISE-main/VSG/VG_parser/dataloaders/visual_genome.py | """
File that involves dataloaders for the Visual Genome example_dataset.
"""
import json
import os
import h5py
import numpy as np
import torch
from PIL import Image
from torch.utils.data import Dataset
from torchvision.transforms import Resize, Compose, ToTensor, Normalize
from dataloaders.blob import Blob
from lib.... | 16,373 | 37.527059 | 129 | py |
MRE-ISE | MRE-ISE-main/VSG/VG_parser/dataloaders/blob.py | """
Data blob, hopefully to make collating less painful and MGPU training possible
"""
from lib.fpn.anchor_targets import anchor_target_layer
import numpy as np
import torch
from torch.autograd import Variable
class Blob(object):
def __init__(self, mode='det', is_train=False, num_gpus=1, primary_gpu=0, batch_size... | 9,073 | 38.281385 | 118 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.