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 |
|---|---|---|---|---|---|---|
picsar-development | picsar-development/utils/subroutine_generators/write_gathering_routines_vec2_2d.py | # ________________________________________________________________________________________
#
# WRITE_GATHERING_ROUTINES.PY
#
# This python script generates vectorized field gathering subroutines
# with given interpolation orders.
#
# ____________________________________________________________________________________... | 28,171 | 40.127007 | 120 | py |
picsar-development | picsar-development/utils/subroutine_generators/write_gathering_routines_vect2_3d.py | # ______________________________________________________________________________
#
# WRITE_GATHERING_ROUTINES.PY
#
# This python script enables to inline the original field gathering
# subroutine in 3D
#
#
#! /usr/bin/python
from numpy import *
# Parameters
nox=2 # order of gathering
noy=2
noz=2
l_lower_order_in_v=... | 28,050 | 41.566009 | 144 | py |
picsar-development | picsar-development/utils/subroutine_generators/write_current_dep_esirkepov_vect_3d.py | #! /usr/bin/python
from numpy import *
# Parameters
nox=2 # order of gathering
noy=2
noz=2
l4symtry=False
l_particles_weight=True
final_loop_lin=0
filename="depose_jxjyjz_esirkepov_"+str(nox)+"_"+str(noy)+"_"+str(noz)+".F90"
subroutine_deposej="depose_jxjyjz_esirkepov_vecHV_"+str(nox)+"_"+str(noy)+"_"+str(noz)
indent_... | 26,128 | 45.164311 | 169 | py |
picsar-development | picsar-development/utils/subroutine_generators/write_current_dep_esirkepov_3d.py | #! /usr/bin/python
from numpy import *
# Parameters
nox=1 # order of gathering
noy=1
noz=1
l4symtry=False
l_particles_weight=True
final_loop_lin=0
filename="depose_jxjyjz_esirkepov_"+str(nox)+"_"+str(noy)+"_"+str(noz)+".F90"
subroutine_deposej="depose_jxjyjz_esirkepov_lin_"+str(nox)+"_"+str(noy)+"_"+str(noz)
indent_co... | 25,011 | 45.838951 | 169 | py |
picsar-development | picsar-development/utils/subroutine_generators/write_current_dep_esirkepov_2d.py | #! /usr/bin/python
from numpy import *
# Parameters
nox=3 # order of gathering
noz=3
l4symtry=False
l_particles_weight=True
final_loop_lin=2
filename="depose_jxjyjz_esirkepov_"+str(nox)+"_"+str(noz)+".F90"
subroutine_deposej="depose_jxjyjz_esirkepov2d_lin_"+str(nox)+"_"+str(noz)
indent_cont_1=" ... | 15,316 | 38.784416 | 124 | py |
picsar-development | picsar-development/utils/subroutine_generators/write_gathering_routines_2d.py | # ______________________________________________________________________________
#
# WRITE_GATHERING_ROUTINES.PY
#
# This python script enables to inline the original field gathering
# subroutine in 3D
#
#
#! /usr/bin/python
from numpy import *
# Parameters
nox=1 # order of gathering
noy=1
noz=1
l_lower_order_in_v... | 22,109 | 39.054348 | 138 | py |
picsar-development | picsar-development/utils/subroutine_generators/write_gathering_routines_vec_3d.py | # ______________________________________________________________________________
#
# WRITE_GATHERING_ROUTINES.PY
#
# This python script enables to inline the original field gathering
# subroutine in 3D
#
#
#! /usr/bin/python
from numpy import *
# Parameters
nox=2 # order of gathering
noy=2
noz=2
l_lower_order_in_v=... | 25,265 | 41.607083 | 161 | py |
picsar-development | picsar-development/utils/subroutine_generators/write_gathering_routines_blockvect2_3d.py | # ______________________________________________________________________________
#
# WRITE_GATHERING_ROUTINES.PY
#
# This python script enables to inline the original field gathering
# subroutine in 3D
#
#
#! /usr/bin/python
from numpy import *
# Parameters
nox=3 # order of gathering
noy=3
noz=3
l_lower_order_in_v=... | 28,244 | 41.860395 | 144 | py |
picsar-development | picsar-development/utils/forthon_parser/forthon_parser.py | """
_______________________________________________________________________________
*** Copyright Notice ***
"Particle In Cell Scalable Application Resource (PICSAR) v2", Copyright (c)
2016, The Regents of the University of California, through Lawrence Berkeley
National Laboratory (subject to receipt of any req... | 45,578 | 37.560914 | 133 | py |
picsar-development | picsar-development/utils/forthon_parser/forthon_parser_pxr_spectral_hybrid.py | """
_______________________________________________________________________________
*** Copyright Notice ***
"Particle In Cell Scalable Application Resource (PICSAR) v2", Copyright (c)
2016, The Regents of the University of California, through Lawrence Berkeley
National Laboratory (subject to receipt of any req... | 45,308 | 37.825193 | 133 | py |
picsar-development | picsar-development/performance_tests/run_alltests_1node.py | import os, sys, shutil
import argparse, re, time
# This script runs automated performance tests for WarpX.
# It runs tests in list test_list defined below, and write
# results in file performance_log.txt in warpx/performance_tests/
# ---- User's manual ----
# Before running performance tests, make sure you have the l... | 16,832 | 46.283708 | 208 | py |
picsar-development | picsar-development/Doxygen/pages/latex_theory/reformat.py | # This script takes the markdown file generated by pandoc from TeX files
# and reformats a few details of the file, so that Doxygen can render it.
import re
# Open existing file
with open('theory.md') as f:
text = f.read()
# Replace @ sign by \cite commands
text = text.replace( '@', '\cite ' )
# Replace inline ... | 1,032 | 32.322581 | 77 | py |
ocropy2 | ocropy2-master/all-lines.py | import string
import dlinputs as dli
server = "http://192.168.4.6:9000/ocr/"
class Inputs(object):
def training_data(self, **kw):
uw3 = (dli.ittarshards(server+"uw3-lines-train-@000018.tgz") |
dli.itren(input="dew.png", transcript="gt.txt", skip_missing=1))
lo = (dli.ittarshards(ser... | 1,648 | 52.193548 | 86 | py |
ocropy2 | ocropy2-master/all-pages.py | import string
import dlinputs as dli
import numpy as np
server = dli.find_url("""
http://192.168.4.6:8080/minio/ocr/
http://localhost:9000/ocr/
""")
print "server", server
keys = "input output".split()
def imexpand(image):
return np.expand_dims(image, 3)
class Inputs(object):
def training_data(self,... | 1,415 | 37.27027 | 86 | py |
ocropy2 | ocropy2-master/setup.py | #!/usr/bin/env python
from __future__ import print_function
import sys,time,urllib,traceback,glob,os,os.path
if 0:
os.system("wget -nc -nd https://storage.googleapis.com/tmbmodels/ocr-default.pt")
models = ["ocr-default.pt"]
else:
models = []
assert sys.version_info[0]==2 and sys.version_info[1]>=7,\
... | 1,009 | 29.606061 | 91 | py |
ocropy2 | ocropy2-master/uw3dew-input.py | #!/usr/bin/python
import matplotlib
import numpy as np
import pylab
import os
import glob
import time
import ocropy2
import dlinputs as dli
path = """
/work/DATABASES
""".split()
dbpath = dli.find_file(path, "uw3-dew.db")
def fix(image):
h, w = image.shape
assert h==48
assert w>0
assert np.amax(ima... | 1,093 | 22.276596 | 79 | py |
ocropy2 | ocropy2-master/seg-model.py | import dlmodels as dlm
class Model(object):
def __init__(self, **kw):
self.kw = kw
def create(self, ishape=(17, 1, 200, 48), oshape=(17, 97, 200), **params):
with dlm.specops:
template = (Check(-1, -1, -1, -1, range=(0.0,1.0)) |
Cbr(8) | Mp(2) | Cbr(16) | Mp(... | 515 | 31.25 | 78 | py |
ocropy2 | ocropy2-master/ocr.py | import dlmodels as dlm
class Model(object):
def __init__(self, **kw):
self.kw = kw
def create(self, ishape=(17, 1, 200, 48), oshape=(17, 97, 200), **params):
with dlm.specops:
template = (Check(-1, 1, -1, 48, range=(0.0,1.0)) |
Cbr(32) | Mp(2) | Cbr(128) | M... | 494 | 34.357143 | 78 | py |
ocropy2 | ocropy2-master/uw3pages-input.py | import numpy as np
import dlinputs as dli
import random as pyr
from math import pi, cos, sin
import numpy as np
import scipy.ndimage as ndi
path = """
./pages
/work/OCR/uw3-pages
""".split()
pages = dli.find_directory(path)
params = dict(translation=0.03, rotation=1.0, scale=0.03, aniso=0.03)
def random_trs(tran... | 2,079 | 27.888889 | 69 | py |
ocropy2 | ocropy2-master/ocropy2/edist.py | from scipy.ndimage import filters
from pylab import *
import re
def levenshtein(a,b):
"""Calculates the Levenshtein distance between a and b.
(Clever compact Pythonic implementation from hetland.org)"""
n, m = len(a), len(b)
if n > m: a,b = b,a; n,m = m,n
current = range(n+1)
for i in r... | 2,849 | 32.928571 | 90 | py |
ocropy2 | ocropy2-master/ocropy2/ocrnet.py | #def _patched_view_4d(*tensors):
# output = []
# for t in tensors:
# assert t.dim() == 3
# size = list(t.size())
# size.insert(2, 1)
# output += [t.contiguous().view(*size)]
# return output
#
#import torch.nn._functions.conv
#
#torch.nn._functions.conv._view4d = _patched_view_4d
fr... | 17,908 | 34.53373 | 100 | py |
ocropy2 | ocropy2-master/ocropy2/gpageseg.py | import numpy
import pylab
from numpy import *
from pylab import *
from pylab import mean
from scipy.ndimage import filters, interpolation, measurements, morphology
from scipy.ndimage.morphology import *
import logging
logger = logging.getLogger()
################################################################
# utili... | 33,714 | 31.860624 | 104 | py |
ocropy2 | ocropy2-master/ocropy2/lineest.py | from __future__ import print_function
import sys
import os
import re
from scipy import stats
from scipy.ndimage import measurements, interpolation, filters
from pylab import *
def autocrop0(image, threshold=1e-3, extra=2):
bimage = image
if image.ndim==3: bimage = sum(bimage, 2)
indexes = find(sum(bimage... | 3,364 | 35.576087 | 87 | py |
ocropy2 | ocropy2-master/ocropy2/layers.py | import sys
import numpy as np
import torch
from torch import nn
from torch.legacy import nn as legnn
from torch.autograd import Variable
sys.modules["layers"] = sys.modules["ocroseg.layers"]
BD = "BD"
LBD = "LBD"
LDB = "LDB"
BDL = "BDL"
BLD = "BLD"
BWHD = "BWHD"
BDWH = "BDWH"
BWH = "BWH"
def lbd2bdl(x):
assert... | 6,762 | 28.792952 | 105 | py |
ocropy2 | ocropy2-master/ocropy2/ocrcodecs.py | from __future__ import print_function
import numpy as np
from collections import defaultdict
import unicodedata
from scipy.ndimage import measurements
def make_target(cs,nc):
"""Given a list of target classes `cs` and a total
maximum number of classes, compute an array that has
a `1` in each column and ti... | 2,862 | 35.705128 | 95 | py |
ocropy2 | ocropy2-master/ocropy2/inputs.py | import os
import sqlite3
import math
import numpy as np
import ocrnet
from PIL import Image
from StringIO import StringIO
import glob
import os.path
import codecs
import random as pyr
import re
import pylab
import ocrcodecs
import scipy.ndimage as ndi
import lineest
verbose = True
def image(x, normalize=True, gray=Fa... | 8,389 | 30.541353 | 82 | py |
ocropy2 | ocropy2-master/ocropy2/psegutils.py | from __future__ import print_function
import os
# import sl,morph
import torch
import scipy.ndimage as ndi
from pylab import *
from scipy.ndimage import filters, morphology, interpolation
from torch.autograd import Variable
def sl_width(s):
return s.stop - s.start
def sl_area(s):
return sl_width(s[0]) * s... | 12,723 | 30.730673 | 111 | py |
ocropy2 | ocropy2-master/ocropy2/__init__.py | from ocrcodecs import *
from ocrnet import *
from lineest import *
from edist import *
from degrade import *
from psegutils import *
| 133 | 18.142857 | 23 | py |
ocropy2 | ocropy2-master/ocropy2/nlbin.py | #!/usr/bin/env python
from __future__ import print_function
from pylab import *
from numpy.ctypeslib import ndpointer
import argparse,os,os.path
from scipy.ndimage import filters,interpolation,morphology,measurements
from scipy import stats
import multiprocessing
import logging
logger = logging.getLogger()
class Str... | 5,333 | 35.285714 | 90 | py |
ocropy2 | ocropy2-master/ocropy2/degrade.py | ################################################################
### text image generation with Cairo
################################################################
from __future__ import print_function
import ctypes
from numpy import *
from scipy import *
from scipy.misc import imsave
from pylab import *
from scip... | 1,919 | 37.4 | 90 | py |
ImageNetV2 | ImageNetV2-master/code/generate_review_thresholds_pickle.py | from datetime import datetime, timezone
import getpass
import pickle
import time
import candidate_data
import imagenet
import mturk_utils
import near_duplicate_data
import utils
bucket = 'imagenet2datav2'
imgnet = imagenet.ImageNetData()
cds = candidate_data.CandidateData(exclude_blacklisted_candidates=False)
revie... | 1,008 | 31.548387 | 98 | py |
ImageNetV2 | ImageNetV2-master/code/run_near_duplicate_checker_dssim.py | from near_duplicate_checker import main
from collections import namedtuple
from timeit import default_timer as timer
Args = namedtuple('Args', ['top_k',
'input_filename',
'output_filename',
'return_ndc_results',
... | 1,438 | 32.465116 | 79 | py |
ImageNetV2 | ImageNetV2-master/code/dataset_cache.py | import json
import pathlib
def is_valid_dataset_name(name):
dataset_filepath = (pathlib.Path(__file__).parent / f'../data/datasets/{name}.json').resolve()
return dataset_filepath.is_file()
class DatasetCache:
def __init__(self, imgnet):
self.imgnet = imgnet
self.loaded_datasets = {}
... | 1,811 | 43.195122 | 112 | py |
ImageNetV2 | ImageNetV2-master/code/get_additional_pos_val_images.py | import argparse
import json
import random
import sys
import candidate_data
import imagenet
import mturk_data
import utils
parser = argparse.ArgumentParser()
parser.add_argument('--num_new_images', type=int, default=None)
parser.add_argument('--treshold', type=int, default=None)
args = parser.parse_args()
treshold = a... | 4,049 | 41.631579 | 113 | py |
ImageNetV2 | ImageNetV2-master/code/download_all_candidate_images_to_cache.py | import json
import pathlib
import click
import tqdm
import candidate_data
import image_loader
import imagenet
imgnet = imagenet.ImageNetData()
cds = candidate_data.CandidateData(exclude_blacklisted_candidates=False)
loader = image_loader.ImageLoader(imgnet, cds)
all_wnids = list(sorted(list(imgnet.class_info_by... | 715 | 26.538462 | 87 | py |
ImageNetV2 | ImageNetV2-master/code/initialize_dataset_review.py | import json
import pathlib
import click
import imagenet
@click.group()
def cli():
pass
def images_are_same(list1, list2):
if len(list1) != len(list2):
return False
set1 = set(list1)
set2 = set(list2)
assert len(list1) == len(set1)
assert len(list2) == len(set2)
for img in set1:
... | 3,354 | 35.868132 | 107 | py |
ImageNetV2 | ImageNetV2-master/code/train_imagenet_dataset_discriminator.py | import json
import pathlib
import concurrent.futures as fs
import os
import time
import math
import argparse
import random
import click
import numpy as np
import torchvision.models as models
import torchvision.transforms as transforms
import torch.optim as optim
from torch.optim import lr_scheduler
from tqdm import tq... | 8,705 | 36.852174 | 135 | py |
ImageNetV2 | ImageNetV2-master/code/near_duplicate_data.py | import hashlib
import json
import pathlib
import pickle
from timeit import default_timer as timer
try:
import networkx as nx
except:
pass
#print('importing networkx failed')
try:
import tqdm
except:
pass
#print('import tqdm failed')
import utils
metric_names = ['l2', 'fc7', 'dssim']
def che... | 15,004 | 48.035948 | 145 | py |
ImageNetV2 | ImageNetV2-master/code/mturk.py | import argparse
from collections import Counter,defaultdict
from datetime import datetime, date, time
import csv
import getpass
import inspect
import json
import sys
import time
import traceback
import uuid
from dateutil.tz import tzlocal
import boto3
import botocore
import click
import numpy as np
try:
import tqd... | 20,294 | 36.653061 | 232 | py |
ImageNetV2 | ImageNetV2-master/code/mturk_data.py | import pathlib
import pickle
import mturk_utils
import utils
main_collection_filenames_to_ignore = [
'2018-08-06_17:33_vaishaal.json',
'2018-08-17_17:24_vaishaal.json',
'vaishaal_hits_submitted_2018-08-17-18:28:33-PDT.json',
'vaishaal_hits_submitted_2018-08-17-18:50:38-PDT.json',
'vaishaal_hits_su... | 8,536 | 49.217647 | 150 | py |
ImageNetV2 | ImageNetV2-master/code/run_near_duplicate_checker_l2.py | from near_duplicate_checker import main
from collections import namedtuple
from timeit import default_timer as timer
Args = namedtuple('Args', ['top_k',
'input_filename',
'output_filename',
'return_ndc_results',
... | 1,434 | 32.372093 | 79 | py |
ImageNetV2 | ImageNetV2-master/code/download_images_from_flickr.py | import pywren
import json
import utils
import urllib
import argparse
import boto3
import ssl
import PIL
from PIL import Image
import io
import numpy as np
import skimage.transform
import imageio
import time
import candidate_data
import gc
MTURK_RESCALE_SIZE = 500
NDC_SIZE = 256
from PIL import Image, ImageFile
__all... | 8,032 | 34.544248 | 135 | py |
ImageNetV2 | ImageNetV2-master/code/make_imagenet_folders.py | import json
import pathlib
import concurrent.futures as fs
import os
import time
import math
import argparse
import random
import click
import numpy as np
import torchvision.models as models
import torchvision.transforms as transforms
import torch.optim as optim
from torch.optim import lr_scheduler
from tqdm import tq... | 2,511 | 27.545455 | 127 | py |
ImageNetV2 | ImageNetV2-master/code/download_dataset_images.py | import json
import pathlib
import click
import tqdm
import candidate_data
import image_loader
import imagenet
@click.command()
@click.argument('datasets', type=str)
@click.option('--include_val', type=bool, is_flag=True)
def download_images(datasets, include_val):
imgnet = imagenet.ImageNetData()
cds = can... | 1,728 | 33.58 | 99 | py |
ImageNetV2 | ImageNetV2-master/code/review_near_duplicates_notebook_code.py | import datetime
import math
from timeit import default_timer as timer
from IPython.display import display
from ipywidgets import widgets
import tqdm
def get_cd_metric_pairs(nn_results, reviews, thresholds, cds):
cd_metric_pairs = []
for cd, metric_dict in nn_results.items():
if cd not in cds.blacklis... | 11,141 | 46.615385 | 148 | py |
ImageNetV2 | ImageNetV2-master/code/generate_mturk_data_pickle.py | from datetime import datetime, timezone
import getpass
import pickle
import time
import mturk_utils
import utils
try:
from tqdm import tqdm
pass
except:
pass
live = True
bucket = 'imagenet2datav2'
print('Running consistency check:')
num_errors, num_warnings, local_hit_ids_missing_remotely = mturk_utils... | 2,860 | 41.073529 | 132 | py |
ImageNetV2 | ImageNetV2-master/code/utils.py | from collections import namedtuple
import concurrent
import concurrent.futures
import hashlib
import io
import json
import math
import numpy as np
import os
import pickle
import PIL.Image
import pathlib
import random
import statistics
import tarfile
import threading
import time
from time import sleep
from timeit import... | 22,873 | 37.573356 | 201 | py |
ImageNetV2 | ImageNetV2-master/code/final_dataset_inspection_notebook_code.py | from collections import Counter
import json
import pathlib
import random
from timeit import default_timer as timer
import ipywidgets as widgets
import mturk_utils
import near_duplicate_data
def get_filenames_by_wnid(data, all_wnids):
image_filenames = data['image_filenames']
filenames_by_wnid = {}
for w... | 13,643 | 46.706294 | 190 | py |
ImageNetV2 | ImageNetV2-master/code/featurize_candidates.py | import argparse
import io
import os
import pickle
import tarfile
import time
from timeit import default_timer as timer
import json
import boto3
import numpy as np
import skimage.transform
import torch
import torchvision.models as models
from torch.autograd import Variable
from torch import nn
import candidate_data
imp... | 3,328 | 39.108434 | 129 | py |
ImageNetV2 | ImageNetV2-master/code/generate_nltk_metadata.py | import imagenet
import json
import random
import nltk
nltk.download('wordnet')
from nltk.corpus import wordnet as wn
def get_similarity_sorted_wnids(q_wnid):
"""Returns a list of sorted (wnid, dist) duples in order of
most similar to least similar to the query wnid."""
q_synset = wn.synset_from_pos_and_of... | 2,400 | 34.835821 | 85 | py |
ImageNetV2 | ImageNetV2-master/code/featurize_test.py | import argparse
import io
import pickle
import tarfile
import time
from timeit import default_timer as timer
import boto3
import numpy as np
import skimage.transform
import torch
import torchvision.models as models
from torch.autograd import Variable
from torch import nn
import candidate_data
import featurize
import ... | 2,873 | 35.379747 | 119 | py |
ImageNetV2 | ImageNetV2-master/code/generate_class_info_file.py | import json
import os
import urllib.request
import imagenet
import utils
imgnet = imagenet.ImageNetData(load_class_info=False)
def lookup_wnid(wnid):
url = 'http://www.image-net.org/api/text/wordnet.synset.getwords?wnid={0}'.format(wnid)
return urllib.request.urlopen(url).read().decode().strip().split('\n')
... | 995 | 26.666667 | 91 | py |
ImageNetV2 | ImageNetV2-master/code/featurize.py | import io
import pickle
import sys
import tarfile
import time
import boto3
import imageio
import numpy as np
import skimage.transform
import torch
from torch.autograd import Variable
from torch import nn
import torchvision.models as models
import utils
def vgg16_features(images, batch_size=60, use_gpu=True):
mode... | 4,394 | 35.932773 | 96 | py |
ImageNetV2 | ImageNetV2-master/code/image_loader.py | import io
import math
import pathlib
import imageio
import PIL
import imagenet
import utils
class ImageLoader:
def __init__(self,
imagenet_loader,
candidate_loader,
cache_on_local_disk=True,
cache_root_path=None,
bucket='imagene... | 6,084 | 42.156028 | 122 | py |
ImageNetV2 | ImageNetV2-master/code/backup_mturk.py | import datetime
import getpass
import json
import time
from timeit import default_timer as timer
import tqdm
import mturk_utils
client = mturk_utils.get_mturk_client(live=True)
max_num_results = 100
api_results = []
all_hit_ids = []
print('Retrieving HITs ...')
last_hit_count_print = 0
last_hit_count_print_time ... | 2,498 | 27.724138 | 107 | py |
ImageNetV2 | ImageNetV2-master/code/sample_dataset.py | import json
import pathlib
import statistics
import click
import dataset_sampling
import imagenet
import mturk_data
@click.group()
def cli():
pass
@cli.command()
@click.option('--dataset_size', required=True, type=int)
@click.option('--seed', required=True, type=int)
@click.option('--output_filename', require... | 15,546 | 48.830128 | 168 | py |
ImageNetV2 | ImageNetV2-master/code/generate_imagenet_metadata_pickle.py | from datetime import datetime, timezone
import getpass
import json
import pathlib
import pickle
from tqdm import tqdm
import utils
#train_metadata_filename = 'metadata/imagenet_train_tar_structure.json'
#train_metadata_file_bytes = utils.get_s3_file_bytes(train_metadata_filename, cache_on_local_disk=False)
#train_ta... | 7,702 | 37.323383 | 104 | py |
ImageNetV2 | ImageNetV2-master/code/candidate_data.py | from collections import Counter
from collections import namedtuple
from collections import OrderedDict
import concurrent
import hashlib
import io
import json
import os
import pathlib
import pickle
import tarfile
import time
import urllib
import boto3
import imageio
import numpy as np
import utils
# Batches the given... | 12,346 | 41.871528 | 134 | py |
ImageNetV2 | ImageNetV2-master/code/dataset_sampling.py | from collections import OrderedDict
import copy
from datetime import datetime, timezone
import getpass
import json
import random
import numpy as np
import candidate_data
import imagenet
import mturk_data
import near_duplicate_data
standard_bins = [0.2, 0.4, 0.6, 0.8]
def build_histogram(freqs, bins):
num_bins... | 29,452 | 42.763744 | 161 | py |
ImageNetV2 | ImageNetV2-master/code/test_near_duplicate_checker.py | import datetime
import hashlib
import imageio
import io
import json
import os
import boto3
import numpy as np
import scipy
from skimage.transform import resize
import featurize
import near_duplicate_checker
import utils
import imagenet
def make_test_img(im_data, im_name, prefix, size, exact):
sha1 = hashlib.sha... | 8,130 | 40.912371 | 215 | py |
ImageNetV2 | ImageNetV2-master/code/eval.py | import json
import pathlib
import click
import numpy as np
import torchvision.models
from tqdm import tqdm
import candidate_data
import eval_utils
import image_loader
import imagenet
import pretrainedmodels
import pretrainedmodels.utils as pretrained_utils
import torch
import os
import time
torch.backends.cudnn.dete... | 7,435 | 41.735632 | 138 | py |
ImageNetV2 | ImageNetV2-master/code/flickr_search.py | import flickrapi
import flickrapi.exceptions
import flickrapi.shorturl
import imagenet
import itertools
import json
from datetime import date
import datetime
import getpass
import utils
import time
import argparse
import logging
import hashlib
import pywren
import random
import urllib.request
import numpy as np
import ... | 10,820 | 46.880531 | 133 | py |
ImageNetV2 | ImageNetV2-master/code/generate_candidate_metadata_pickle.py | from datetime import datetime, timezone
import getpass
import pickle
import time
import pywren
from pywren import wrenconfig as wc
import candidate_data
import utils
try:
from tqdm import tqdm
pass
except:
pass
bucket = 'imagenet2datav2'
num_replicas = 10
use_pywren_for_replicas = False
json_dir, json_... | 2,571 | 32.402597 | 103 | py |
ImageNetV2 | ImageNetV2-master/code/resolve_duplicate_candidates.py | import copy
from datetime import datetime, timezone
import hashlib
import json
import pickle
import time
import candidate_data
cds = candidate_data.CandidateData(exclude_blacklisted_candidates=False, verbose=True)
all_cds = list(cds.all_candidates.values()) + cds.duplicates
for c in all_cds:
assert c['search_e... | 3,313 | 35.021739 | 116 | py |
ImageNetV2 | ImageNetV2-master/code/aes.py | import base64
from Crypto import Random
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad, unpad
class AESCipher(object):
def __init__(self, key, iv):
self.key = key
self.iv = iv
def encrypt(self, raw):
raw = pad(raw, AES.block_size)
cipher = AES.new(self.key... | 596 | 24.956522 | 60 | py |
ImageNetV2 | ImageNetV2-master/code/prediction_data.py | from collections import Counter
import json
import pathlib
from timeit import default_timer as timer
import numpy as np
import dataset_cache
default_datasets_to_load = ['imagenetv2-a-44', 'imagenetv2-b-33', 'imagenetv2-c-12', 'imagenet-annotatedval20k-0']
def load_predictions_for_dataset(dataset_name, imgnet):
... | 5,849 | 49.869565 | 163 | py |
ImageNetV2 | ImageNetV2-master/code/near_duplicate_checker.py | import boto3
import imageio
import io
from collections import defaultdict
import numpy as np
import os
import pywren
from pywren import wrenconfig as wc
from skimage.measure import compare_ssim
import sys
import tarfile
import json
import argparse
from timeit import default_timer as timer
from collections import namedt... | 29,167 | 45.519936 | 147 | py |
ImageNetV2 | ImageNetV2-master/code/image_consistency_check.py | import pywren
from pywren import wrenconfig as wc
import candidate_data
import utils
pywren_config = wc.default()
pywren_config["runtime"]["s3_bucket"] = "imagenet2pywren"
pywren_config["runtime"]["s3_key"] = "pywren.runtime/pywren_runtime-3.6-imagenet2pywren.meta.json"
pwex = pywren.default_executor(config=pywren_con... | 1,407 | 26.607843 | 98 | py |
ImageNetV2 | ImageNetV2-master/code/inspect_hit_notebook_code.py | import statistics
from timeit import default_timer as timer
import ipywidgets as widgets
import mturk_utils
import utils
def generate_image_captions(hit_data, cur_assignments, cds):
frequencies = {}
for image_name in hit_data['images_all']:
frequencies[image_name] = 0
num_valid_assignments = 0
... | 4,247 | 41.059406 | 140 | py |
ImageNetV2 | ImageNetV2-master/code/get_parent_search_term.py | import json
import imagenet
import nltk
nltk.download('wordnet')
from nltk.corpus import wordnet as wn
def intersection(lst1, lst2):
return set(lst1).intersection(lst2)
def main():
with open('../data/metadata/unprocessed_wnids.json', 'r') as f:
bad_wnids = json.load(f)
#with open('../data/me... | 2,009 | 33.655172 | 96 | py |
ImageNetV2 | ImageNetV2-master/code/flatten_tarballs.py | import io
import imagenet
import pywren
from pywren import wrenconfig as wc
import tarfile
import utils
def flatten_tarball(tarball_name, prefix, bucket="imagenet2datav2", verbose=False):
tarball_bytes = utils.get_s3_file_bytes(tarball_name, cache_on_local_disk=False, verbose=verbose)
tf = tarfile.open(fileob... | 1,713 | 31.339623 | 101 | py |
ImageNetV2 | ImageNetV2-master/code/imagenet.py | from collections import namedtuple
import concurrent
import io
import json
import os
import pathlib
import pickle
import tarfile
import boto3
import imageio
import numpy as np
import utils
ClassInfo = namedtuple('ClassInfo', ['wnid', 'cid', 'synset', 'wikipedia_pages', 'gloss'])
class UnknownDataPartError(Excepti... | 16,355 | 42.5 | 115 | py |
ImageNetV2 | ImageNetV2-master/code/mturk_utils.py | from collections import namedtuple
import hashlib
import io
import json
import math
import numpy as np
import os
import pathlib
import statistics
import tarfile
from timeit import default_timer as timer
import urllib.request
from xml.dom.minidom import parseString
import boto3
import botocore
import dateutil
import PI... | 20,656 | 38.572797 | 177 | py |
ImageNetV2 | ImageNetV2-master/code/eval_utils.py | import math
from timeit import default_timer as timer
import numpy as np
import torch
import torch.backends.cudnn as cudnn
import torchvision.transforms as transforms
import tqdm
import image_loader
class ImageLoaderDataset(torch.utils.data.Dataset):
def __init__(self, filenames, imgnet, cds, size, verbose=Fals... | 3,351 | 39.878049 | 134 | py |
ImageNetV2 | ImageNetV2-master/code/generate_hit_candidates.py | import argparse
import candidate_data
from datetime import date
import datetime
import json
from near_duplicate_checker import print_nn_stats
import mturk_data
import pickle
thresholds = {
'l2' : 1e8,
'dssim' : 1e32,
'fc7' : 1e4
}
def remove_blacklist_candidates(candidates, blacklist):
new_candidates =... | 4,622 | 36.282258 | 102 | py |
ImageNetV2 | ImageNetV2-master/code/review_server.py | import datetime
import getpass
import json
import os
import pathlib
import sys
from timeit import default_timer as timer
import traceback
import click
import responder
import candidate_data
import dataset_cache
import imagenet
import mturk_data
import near_duplicate_data
import prediction_data
import problematic_imag... | 16,455 | 39.935323 | 141 | py |
ImageNetV2 | ImageNetV2-master/code/run_near_duplicate_checker_fc7.py | from near_duplicate_checker import main
from collections import namedtuple
from timeit import default_timer as timer
Args = namedtuple('Args', ['top_k',
'input_filename',
'output_filename',
'return_ndc_results',
... | 1,438 | 32.465116 | 79 | py |
ImageNetV2 | ImageNetV2-master/code/encrypt_copy_objects.py | import boto3
import argparse
import utils
from pywren import wrenconfig as wc
import pywren
def encrypt_all_keys_in_prefix(bucket, prefix, encrypt_out, strip_string, use_pywren):
keys = utils.list_all_keys(prefix)
if (use_pywren):
chunked_keys = utils.chunks(keys, 500)
def pywren_job(key_chunk)... | 1,527 | 34.534884 | 106 | py |
COV19D_3rd | COV19D_3rd-main/Seg-Exct-Classif-Pipeline-Hybrid Method.py | # -*- KENAN MORANI - IZMIR DEMOCRACY UNIVERSITY -*-
#### COV19-CT DB Database #####
### part of IEEE ICASSP 2023: AI-enabled Medical Image Analysis Workshop and Covid-19 Diagnosis Competition (AI-MIA-COV19D)
### at https://mlearn.lincoln.ac.uk/icassp-2023-ai-mia/
#### B. 3rd COV19D Competition ---- I. Covid-19 Detectio... | 65,932 | 32.215617 | 171 | py |
COV19D_3rd | COV19D_3rd-main/loading_models/Loading-Models.py |
## Image Process + CNN Model - no slcie removal
h=w=224
def make_model():
model = models.Sequential()
# Convulotional Layer 1
model.add(layers.Conv2D(16,(3,3),input_shape=(h,w,1), padding="same"))
model.add(layers.BatchNormalization())
model.add(layers.ReLU())
model.add(layers.MaxPool... | 6,156 | 28.743961 | 109 | py |
MetaSAug | MetaSAug-main/MetaSAug_LDAM_train.py | import os
import time
import argparse
import random
import copy
import torch
import torchvision
import numpy as np
import torch.nn.functional as F
from torch.autograd import Variable
import torchvision.transforms as transforms
from data_utils import *
from resnet import *
import shutil
from loss import *
parser = argp... | 12,114 | 32.559557 | 115 | py |
MetaSAug | MetaSAug-main/resnet.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import math
from torch.autograd import Variable
import torch.nn.init as init
def to_var(x, requires_grad=True):
if torch.cuda.is_available():
x = x.cuda()
return Variable(x, requires_grad=requires_grad)
class MetaModule(nn.Module):
... | 10,031 | 34.828571 | 120 | py |
MetaSAug | MetaSAug-main/loss.py | import numpy as np
import torch
import torch.nn as nn
from torch.autograd import Variable
import math
import torch.nn.functional as F
import pdb
class EstimatorCV():
def __init__(self, feature_num, class_num):
super(EstimatorCV, self).__init__()
self.class_num = class_num
self.CoVariance =... | 4,318 | 34.401639 | 128 | py |
MetaSAug | MetaSAug-main/data_utils.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.nn.parallel
import torch.backends.cudnn as cudnn
import torch.optim
import torch.utils.data
import torchvision.transforms as transforms
import torchvision
import numpy as np
import copy
np.random.seed(6)
def build_dataset(dataset,num_meta... | 3,070 | 33.897727 | 128 | py |
MetaSAug | MetaSAug-main/MetaSAug_test.py | import os
import time
import argparse
import random
import copy
import torch
import torchvision
import numpy as np
import torch.nn.functional as F
from torch.autograd import Variable
import torch.nn as nn
import torchvision.transforms as transforms
from data_utils import *
from resnet import *
import shutil
import gc
... | 4,032 | 23.295181 | 77 | py |
MetaSAug | MetaSAug-main/ImageNet_iNat/ResNet.py | from resnet_meta import *
from utils import *
from os import path
def create_model(use_selfatt=False, use_fc=False, dropout=None, stage1_weights=False, dataset=None, log_dir=None, test=False, *args):
print('Loading Scratch ResNet 50 Feature Model.')
if not use_fc:
resnet50 = FeatureMeta(Bottl... | 1,473 | 39.944444 | 133 | py |
MetaSAug | MetaSAug-main/ImageNet_iNat/test.py |
import os
import time
import argparse
import random
import copy
import torch
import torchvision
import numpy as np
import torch.nn.functional as F
from torch.autograd import Variable
import torchvision.transforms as transforms
from data_utils import *
from dataloader import load_data_distributed
import shutil
from Res... | 7,842 | 33.70354 | 177 | py |
MetaSAug | MetaSAug-main/ImageNet_iNat/dataloader.py | import numpy as np
import torchvision
from torch.utils.data import Dataset, DataLoader, ConcatDataset
from torchvision import transforms
import os
from PIL import Image
import json
# Image statistics
RGB_statistics = {
'iNaturalist18': {
'mean': [0.466, 0.471, 0.380],
'std': [0.195, 0.194, 0.192]
... | 4,682 | 28.828025 | 129 | py |
MetaSAug | MetaSAug-main/ImageNet_iNat/loss.py | # -*- coding: utf-8 -*
import numpy as np
import torch
import torch.nn as nn
from torch.autograd import Variable
import math
import torch.nn.functional as F
import pdb
def MI(outputs_target):
batch_size = outputs_target.size(0)
softmax_outs_t = nn.Softmax(dim=1)(outputs_target)
avg_softmax_outs_t = torch.... | 5,772 | 36.245161 | 130 | py |
MetaSAug | MetaSAug-main/ImageNet_iNat/utils.py | import numpy as np
import matplotlib.pyplot as plt
import torch
from sklearn.metrics import f1_score
import torch.nn.functional as F
import importlib
def source_import(file_path):
"""This function imports python module directly from source code using importlib"""
spec = importlib.util.spec_from_file_location(... | 7,719 | 32.859649 | 109 | py |
MetaSAug | MetaSAug-main/ImageNet_iNat/data_utils.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.nn.parallel
import torch.backends.cudnn as cudnn
import torch.optim
import torch.utils.data
import torchvision.transforms as transforms
import torchvision
import numpy as np
import copy
np.random.seed(6)
#random.seed(2)
def build_dataset(d... | 3,467 | 31.111111 | 86 | py |
MetaSAug | MetaSAug-main/ImageNet_iNat/train.py |
import os
import time
import argparse
import random
import copy
import torch
import torchvision
import numpy as np
import torch.nn.functional as F
from torch.autograd import Variable
import torchvision.transforms as transforms
from data_utils import *
# import resnet
from dataloader import load_data_distributed
import... | 13,612 | 38.005731 | 184 | py |
MetaSAug | MetaSAug-main/ImageNet_iNat/resnet_meta.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import math
from torch.autograd import Variable
import torch.nn.init as init
def to_var(x, requires_grad=True):
if torch.cuda.is_available():
x = x.cuda()
return Variable(x, requires_grad=requires_grad)
class MetaModule(nn.Module):
... | 18,152 | 35.306 | 120 | py |
coocmap | coocmap-main/baselines.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
import subprocess
from subprocess import check_output
import os
import embeddings
class VecMap:
"""
wrapper for vecmap https://github.com/artetxem/vecmap
assumes vecmap is in the directory ./vecmap
"""
def __init__(self, srcvec, tgtvec, dictpath,... | 3,050 | 34.068966 | 115 | py |
coocmap | coocmap-main/test_coocmap.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
import os
from dataclasses import dataclass
import wandb
import shutil
import pandas as pd
import numpy as np
import data
import match
import evaluation
import embeddings
# experimental parameters
defaults = dict(
lan1='./europarl-v7.hu-en.en',
lan2='./eur... | 5,824 | 32.285714 | 136 | py |
coocmap | coocmap-main/embeddings.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
# Copyright (C) 2016-2018 Mikel Artetxe <artetxem@gmail.com>
#
# This program 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 Licen... | 6,253 | 30.427136 | 92 | py |
coocmap | coocmap-main/data.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
import itertools
import os
import sys
import subprocess
import time
# import lzma # needed for BUCC20Corpus
import numpy as np
from tokenizers import Token, Tokenizer
from tokenizers.models import BPE, WordLevel
from tokenizers.trainers import BpeTrainer, WordLevel... | 23,162 | 42.786389 | 202 | py |
coocmap | coocmap-main/evaluation.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
from typing import Optional
import collections
import numpy as np
import pandas as pd
from tokenizers import Tokenizer
# faithfully recreate the protocol of vecmap with minimal code modifications
def vecmap_evaluate(sim: np.ndarray, tokenizer1: Tokenizer, tokeniz... | 5,552 | 34.14557 | 118 | py |
coocmap | coocmap-main/match.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
from collections import Counter
import numpy as np
import embeddings
np.set_printoptions(formatter={'float': lambda x: "{0:0.3f}".format(x)})
MAX_SVD_DIM = 5000 # maximum SVD to avoid long compute time
### initialization methods ###
def vecmap_unsup(x, z, norm_proc... | 10,281 | 32.061093 | 111 | py |
coocmap | coocmap-main/fast/setup.py | from setuptools import setup
from Cython.Build import cythonize
import numpy
# python setup.py build_ext --inplace
setup(
ext_modules=cythonize(
['cooc_count.pyx'],
annotate=True),
include_dirs=[numpy.get_include()]
) | 244 | 21.272727 | 38 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.