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
PLRDiff
PLRDiff-main/guided_diffusion/core.py
''' copied from https://github.com/sanghyun-son/bicubic_pytorch A standalone PyTorch implementation for fast and efficient bicubic resampling. The resulting values are the same to MATLAB function imresize('bicubic'). ## Author: Sanghyun Son ## Email: sonsang35@gmail.com (primary), thstkdgus35@snu.ac.kr (s...
13,613
27.904459
84
py
PLRDiff
PLRDiff-main/guided_diffusion/rsfac_gaussian_diffusion.py
""" This code started out as a PyTorch port of the following: https://github.com/HJ-harry/MCG_diffusion/blob/main/guided_diffusion/gaussian_diffusion.py The conditions are changed and coefficient matrix estimation is added. """ import enum import math import numpy as np import torch as th from torch.autograd import ...
16,226
34.900442
129
py
PLRDiff
PLRDiff-main/guided_diffusion/utils.py
""" Logger copied from OpenAI baselines to avoid extra RL-based dependencies: https://github.com/openai/baselines/blob/ea25b9e8b234e6ee1bca43083f8f3cf974143998/baselines/logger.py """ import os import os.path as osp import json import datetime from collections import OrderedDict def mkdirs(paths): if isinstance(p...
1,545
23.935484
101
py
PLRDiff
PLRDiff-main/guided_diffusion/create.py
from . import rsfac_gaussian_diffusion as gd def create_model_and_diffusion_RS(opt): model = define_G(opt['model']) opt2 = opt['diffusion'] diffusion = create_gaussian_diffusion( beta_schedule= opt2['beta_schedule'], beta_linear_start= opt2['beta_linear_start'], beta_linear_end = op...
1,601
26.62069
102
py
PLRDiff
PLRDiff-main/guided_diffusion/__init__.py
""" Codebase for "Improved Denoising Diffusion Probabilistic Models". """
74
17.75
65
py
PLRDiff
PLRDiff-main/guided_diffusion/sr3_modules/unet.py
import math import torch from torch import nn import torch.nn.functional as F from inspect import isfunction def exists(x): return x is not None def default(val, d): if exists(val): return val return d() if isfunction(d) else d # PositionalEncoding Source: https://github.com/lmnt-com/wavegrad/b...
9,347
31.8
150
py
Defensive_Diffusion-testing
Defensive_Diffusion-testing/diffusion.py
import torch import torchvision from torch import nn from torch.nn import functional as F from torch.utils.data import DataLoader from diffusers import DDPMScheduler, UNet2DModel from matplotlib import pyplot as plt from diffusers import DDIMScheduler, DDPMPipeline from data.dataset import data_loader import wandb impo...
4,562
32.551471
152
py
Defensive_Diffusion-testing
Defensive_Diffusion-testing/test.py
import argparse import torch from tqdm import tqdm import os from models import mlp from data.dataset import data_loader from data.dataset import data_loader_attacks root_dir = "./data/attack-data/0.03" def test_vit(model, dataloader_test): """ This function used to test ViT. Args: model: ViT...
2,645
31.666667
94
py
Defensive_Diffusion-testing
Defensive_Diffusion-testing/aabb.py
import numpy as np import torch import torch.nn.functional as F import torchvision from diffusers import DDIMScheduler, DDPMPipeline from matplotlib import pyplot as plt from PIL import Image from torchvision import transforms from tqdm.auto import tqdm from torchvision.datasets import ImageFolder from torch.utils.dat...
1,250
29.512195
93
py
Defensive_Diffusion-testing
Defensive_Diffusion-testing/attack.py
import foolbox as fb import torch import torch.nn as nn from autoattack import AutoAttack class Attack(): """ This class used to generate adversarial images. when create object specify epsilon: float, attack_type: 'FGSM, CW, BIM, L2PGD, PGD, LinfBIM'. generate method return images and success tens...
7,000
34.358586
99
py
Defensive_Diffusion-testing
Defensive_Diffusion-testing/mlp.py
import torch.nn as nn import torch from utils import get_classifiers_list class Classifier(nn.Module): """ MLP classifier. Args: num_classes -> number of classes in_feature -> features dimension return logits. """ def __init__(self,num_classes=2 ,in_features = 768*196...
2,262
33.815385
152
py
Defensive_Diffusion-testing
Defensive_Diffusion-testing/utils.py
import os import torch from attack import Attack import numpy as np import matplotlib.pyplot as plt from torchvision.utils import save_image from autoattack import AutoAttack def generate_save_attacks(attack_names, model, samples, classes ,attack_image_dir, epsilon = 0.03, batch_size=30): """ it saves att...
6,033
37.433121
177
py
Defensive_Diffusion-testing
Defensive_Diffusion-testing/majority_voting.py
import os import torch import argparse import numpy as np from utils import * from data.dataset import data_loader, data_loader_attacks import mlp def majority_voting(data_loader, model, mlps_list): """ SEViT performance with majority voting. Args: data_loader: loader of test samples for clean i...
2,732
30.77907
122
py
Defensive_Diffusion-testing
Defensive_Diffusion-testing/finetuning_diffusion_model.py
import numpy as np import torch import torch.nn.functional as F import torchvision from diffusers import DDIMScheduler, DDPMPipeline from matplotlib import pyplot as plt from PIL import Image from torchvision import transforms from diffusers import DDPMScheduler, UNet2DModel from tqdm.auto import tqdm from torchvision....
4,351
30.766423
156
py
Defensive_Diffusion-testing
Defensive_Diffusion-testing/generate_attacks.py
import torch import argparse from attack import Attack from utils import * from data.dataset import data_loader from mlp import Big_model parser = argparse.ArgumentParser(description='Generate Attack from ViT') parser.add_argument('--epsilons', type=float , help='Perturbations Size') parser.add...
1,179
28.5
72
py
Defensive_Diffusion-testing
Defensive_Diffusion-testing/adversarial_detection.py
import torch import numpy as np from utils import * import argparse from data.dataset import data_loader, data_loader_attacks parser = argparse.ArgumentParser(description='ROC For Attack') parser.add_argument('--clean_image_folder_path', type=str , help='Path to root directory of images') parse...
1,975
36.283019
132
py
Defensive_Diffusion-testing
Defensive_Diffusion-testing/models/mlp.py
import torch.nn as nn import torch class Classifier(nn.Module): """ MLP classifier. Args: num_classes -> number of classes in_feature -> features dimension return logits. """ def __init__(self,num_classes=2 ,in_features = 768*196): super().__init__() ...
911
30.448276
78
py
Defensive_Diffusion-testing
Defensive_Diffusion-testing/data/dataset.py
import os from torchvision.datasets import ImageFolder from torch.utils.data import DataLoader import torchvision.transforms as transforms # DataLoader and Dataset (Clean Samples) def data_loader( root_dir, image_size = (224,224), batch_size= 15, train_dir = 'training',test_dir = 'testing', vald_dir = 'validatio...
4,070
36.694444
139
py
stylegan-encoder
stylegan-encoder-master/train_effnet.py
""" Trains a modified EfficientNet to generate approximate dlatents using examples from a trained StyleGAN. Props to @SimJeg on GitHub for the original code this is based on, from this thread: https://github.com/Puzer/stylegan-encoder/issues/1#issuecomment-490469454 """ import os import math import numpy as np import p...
16,451
47.674556
213
py
stylegan-encoder
stylegan-encoder-master/pretrained_example.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # This work is licensed under the Creative Commons Attribution-NonCommercial # 4.0 International License. To view a copy of this license, visit # http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to # Creative Commons, PO Box 1866, Mountain ...
6,422
30.79703
116
py
stylegan-encoder
stylegan-encoder-master/generate_figures.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # This work is licensed under the Creative Commons Attribution-NonCommercial # 4.0 International License. To view a copy of this license, visit # http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to # Creative Commons, PO Box 1866, Mountain ...
9,563
58.037037
257
py
stylegan-encoder
stylegan-encoder-master/adaptive.py
# coding=utf-8 # Copyright 2019 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
19,790
48.4775
89
py
stylegan-encoder
stylegan-encoder-master/train_resnet.py
""" Trains a modified Resnet to generate approximate dlatents using examples from a trained StyleGAN. Props to @SimJeg on GitHub for the original code this is based on, from this thread: https://github.com/Puzer/stylegan-encoder/issues/1#issuecomment-490469454 """ import os import math import numpy as np import pickle ...
13,439
49.337079
289
py
stylegan-encoder
stylegan-encoder-master/config.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # This work is licensed under the Creative Commons Attribution-NonCommercial # 4.0 International License. To view a copy of this license, visit # http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to # Creative Commons, PO Box 1866, Mountain ...
762
32.173913
77
py
stylegan-encoder
stylegan-encoder-master/run_metrics.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # This work is licensed under the Creative Commons Attribution-NonCommercial # 4.0 International License. To view a copy of this license, visit # http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to # Creative Commons, PO Box 1866, Mountain ...
4,374
40.273585
262
py
stylegan-encoder
stylegan-encoder-master/align_images.py
import os import sys import bz2 import argparse from keras.utils import get_file from ffhq_dataset.face_alignment import image_align from ffhq_dataset.landmarks_detector import LandmarksDetector import multiprocessing LANDMARKS_MODEL_URL = 'http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2' def unpack_...
3,050
48.209677
200
py
stylegan-encoder
stylegan-encoder-master/swa.py
""" Stochastic Weight Averaging: https://arxiv.org/abs/1803.05407 See: https://github.com/kristpapadopoulos/keras-stochastic-weight-averaging """ import os import glob import pickle import argparse from dnnlib.tflib import init_tf filepath = 'output.pkl' def fetch_models_from_files(model_list): for fn in model_li...
2,025
31.15873
139
py
stylegan-encoder
stylegan-encoder-master/dataset_tool.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # This work is licensed under the Creative Commons Attribution-NonCommercial # 4.0 International License. To view a copy of this license, visit # http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to # Creative Commons, PO Box 1866, Mountain ...
42,105
45.372247
163
py
stylegan-encoder
stylegan-encoder-master/train.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # This work is licensed under the Creative Commons Attribution-NonCommercial # 4.0 International License. To view a copy of this license, visit # http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to # Creative Commons, PO Box 1866, Mountain ...
17,124
84.625
302
py
stylegan-encoder
stylegan-encoder-master/encode_images.py
import os import argparse import pickle from tqdm import tqdm import PIL.Image from PIL import ImageFilter import numpy as np import dnnlib import dnnlib.tflib as tflib import config from encoder.generator_model import Generator from encoder.perceptual_model import PerceptualModel, load_images #from tensorflow.keras.mo...
15,281
62.14876
211
py
stylegan-encoder
stylegan-encoder-master/robust_loss/distribution.py
# coding=utf-8 # Copyright 2019 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
13,191
41.554839
80
py
stylegan-encoder
stylegan-encoder-master/robust_loss/wavelet.py
# coding=utf-8 # Copyright 2019 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
19,892
40.357588
80
py
stylegan-encoder
stylegan-encoder-master/robust_loss/cubic_spline.py
# coding=utf-8 # Copyright 2019 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
4,068
39.287129
79
py
stylegan-encoder
stylegan-encoder-master/robust_loss/util.py
# coding=utf-8 # Copyright 2019 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
5,688
29.918478
80
py
stylegan-encoder
stylegan-encoder-master/robust_loss/general.py
# coding=utf-8 # Copyright 2019 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
5,863
44.107692
80
py
stylegan-encoder
stylegan-encoder-master/training/networks_stylegan.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # This work is licensed under the Creative Commons Attribution-NonCommercial # 4.0 International License. To view a copy of this license, visit # http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to # Creative Commons, PO Box 1866, Mountain...
36,721
48.557355
191
py
stylegan-encoder
stylegan-encoder-master/training/networks_progan.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # This work is licensed under the Creative Commons Attribution-NonCommercial # 4.0 International License. To view a copy of this license, visit # http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to # Creative Commons, PO Box 1866, Mountain ...
17,575
53.414861
191
py
stylegan-encoder
stylegan-encoder-master/training/loss.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # This work is licensed under the Creative Commons Attribution-NonCommercial # 4.0 International License. To view a copy of this license, visit # http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to # Creative Commons, PO Box 1866, Mountain ...
10,416
57.522472
154
py
stylegan-encoder
stylegan-encoder-master/training/misc.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # This work is licensed under the Creative Commons Attribution-NonCommercial # 4.0 International License. To view a copy of this license, visit # http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to # Creative Commons, PO Box 1866, Mountain ...
10,406
39.972441
136
py
stylegan-encoder
stylegan-encoder-master/training/dataset.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # This work is licensed under the Creative Commons Attribution-NonCommercial # 4.0 International License. To view a copy of this license, visit # http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to # Creative Commons, PO Box 1866, Mountain ...
12,220
49.5
135
py
stylegan-encoder
stylegan-encoder-master/training/__init__.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # This work is licensed under the Creative Commons Attribution-NonCommercial # 4.0 International License. To view a copy of this license, visit # http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to # Creative Commons, PO Box 1866, Mountain ...
350
38
76
py
stylegan-encoder
stylegan-encoder-master/training/training_loop.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # This work is licensed under the Creative Commons Attribution-NonCommercial # 4.0 International License. To view a copy of this license, visit # http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to # Creative Commons, PO Box 1866, Mountain ...
16,910
54.084691
185
py
stylegan-encoder
stylegan-encoder-master/ffhq_dataset/landmarks_detector.py
import dlib class LandmarksDetector: def __init__(self, predictor_model_path): """ :param predictor_model_path: path to shape_predictor_68_face_landmarks.dat file """ self.detector = dlib.get_frontal_face_detector() # cnn_face_detection_model_v1 also can be used self.shape_...
760
33.590909
108
py
stylegan-encoder
stylegan-encoder-master/ffhq_dataset/__init__.py
0
0
0
py
stylegan-encoder
stylegan-encoder-master/ffhq_dataset/face_alignment.py
import numpy as np import scipy.ndimage import os import PIL.Image def image_align(src_file, dst_file, face_landmarks, output_size=1024, transform_size=4096, enable_padding=True, x_scale=1, y_scale=1, em_scale=0.1, alpha=False): # Align function from FFHQ dataset pre-processing step # https://github.c...
4,533
47.752688
169
py
stylegan-encoder
stylegan-encoder-master/metrics/frechet_inception_distance.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # This work is licensed under the Creative Commons Attribution-NonCommercial # 4.0 International License. To view a copy of this license, visit # http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to # Creative Commons, PO Box 1866, Mountain ...
3,335
44.69863
129
py
stylegan-encoder
stylegan-encoder-master/metrics/metric_base.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # This work is licensed under the Creative Commons Attribution-NonCommercial # 4.0 International License. To view a copy of this license, visit # http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to # Creative Commons, PO Box 1866, Mountain ...
6,479
44.314685
177
py
stylegan-encoder
stylegan-encoder-master/metrics/perceptual_path_length.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # This work is licensed under the Creative Commons Attribution-NonCommercial # 4.0 International License. To view a copy of this license, visit # http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to # Creative Commons, PO Box 1866, Mountain ...
5,225
46.944954
145
py
stylegan-encoder
stylegan-encoder-master/metrics/linear_separability.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # This work is licensed under the Creative Commons Attribution-NonCommercial # 4.0 International License. To view a copy of this license, visit # http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to # Creative Commons, PO Box 1866, Mountain ...
10,313
56.94382
140
py
stylegan-encoder
stylegan-encoder-master/metrics/__init__.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # This work is licensed under the Creative Commons Attribution-NonCommercial # 4.0 International License. To view a copy of this license, visit # http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to # Creative Commons, PO Box 1866, Mountain ...
350
38
76
py
stylegan-encoder
stylegan-encoder-master/dnnlib/util.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # This work is licensed under the Creative Commons Attribution-NonCommercial # 4.0 International License. To view a copy of this license, visit # http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to # Creative Commons, PO Box 1866, Mountain ...
13,836
32.831296
151
py
stylegan-encoder
stylegan-encoder-master/dnnlib/__init__.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # This work is licensed under the Creative Commons Attribution-NonCommercial # 4.0 International License. To view a copy of this license, visit # http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to # Creative Commons, PO Box 1866, Mountain...
797
37
126
py
stylegan-encoder
stylegan-encoder-master/dnnlib/tflib/tfutil.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # This work is licensed under the Creative Commons Attribution-NonCommercial # 4.0 International License. To view a copy of this license, visit # http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to # Creative Commons, PO Box 1866, Mountain...
9,325
37.378601
173
py
stylegan-encoder
stylegan-encoder-master/dnnlib/tflib/autosummary.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # This work is licensed under the Creative Commons Attribution-NonCommercial # 4.0 International License. To view a copy of this license, visit # http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to # Creative Commons, PO Box 1866, Mountain...
7,535
39.735135
127
py
stylegan-encoder
stylegan-encoder-master/dnnlib/tflib/network.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # This work is licensed under the Creative Commons Attribution-NonCommercial # 4.0 International License. To view a copy of this license, visit # http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to # Creative Commons, PO Box 1866, Mountain ...
32,314
50.375199
165
py
stylegan-encoder
stylegan-encoder-master/dnnlib/tflib/__init__.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # This work is licensed under the Creative Commons Attribution-NonCommercial # 4.0 International License. To view a copy of this license, visit # http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to # Creative Commons, PO Box 1866, Mountain...
522
29.764706
76
py
stylegan-encoder
stylegan-encoder-master/dnnlib/tflib/optimizer.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # This work is licensed under the Creative Commons Attribution-NonCommercial # 4.0 International License. To view a copy of this license, visit # http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to # Creative Commons, PO Box 1866, Mountain ...
9,981
45.427907
164
py
stylegan-encoder
stylegan-encoder-master/dnnlib/submission/run_context.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # This work is licensed under the Creative Commons Attribution-NonCommercial # 4.0 International License. To view a copy of this license, visit # http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to # Creative Commons, PO Box 1866, Mountain...
4,347
42.48
213
py
stylegan-encoder
stylegan-encoder-master/dnnlib/submission/__init__.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # This work is licensed under the Creative Commons Attribution-NonCommercial # 4.0 International License. To view a copy of this license, visit # http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to # Creative Commons, PO Box 1866, Mountain...
390
38.1
76
py
stylegan-encoder
stylegan-encoder-master/dnnlib/submission/submit.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # This work is licensed under the Creative Commons Attribution-NonCommercial # 4.0 International License. To view a copy of this license, visit # http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to # Creative Commons, PO Box 1866, Mountain ...
11,185
37.439863
175
py
stylegan-encoder
stylegan-encoder-master/dnnlib/submission/_internal/run.py
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. # # This work is licensed under the Creative Commons Attribution-NonCommercial # 4.0 International License. To view a copy of this license, visit # http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to # Creative Commons, PO Box 1866, Mountain...
1,543
32.565217
98
py
stylegan-encoder
stylegan-encoder-master/encoder/generator_model.py
import math import tensorflow as tf import numpy as np import dnnlib.tflib as tflib from functools import partial def create_stub(name, batch_size): return tf.constant(0, dtype='float32', shape=(batch_size, 0)) def create_variable_for_generator(name, batch_size, tiled_dlatent, model_scale=18, tile_size = 1): ...
7,108
50.514493
148
py
stylegan-encoder
stylegan-encoder-master/encoder/perceptual_model.py
from __future__ import absolute_import, division, print_function, unicode_literals import tensorflow as tf #import tensorflow_probability as tfp #tf.enable_eager_execution() import os import bz2 import PIL.Image from PIL import ImageFilter import numpy as np from keras.models import Model from keras.utils import get_f...
15,587
49.775244
192
py
stylegan-encoder
stylegan-encoder-master/encoder/__init__.py
0
0
0
py
RocketQA
RocketQA-main/setup.py
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
1,737
36.782609
113
py
RocketQA
RocketQA-main/rocketqa/rocketqa.py
import os import sys import json import paddle import urllib import numpy as np import tarfile import warnings import hashlib from tqdm import tqdm from rocketqa.encoder.dual_encoder import DualEncoder from rocketqa.encoder.cross_encoder import CrossEncoder paddle.enable_static() warnings.simplefilter('ignore') __MOD...
7,200
40.866279
151
py
RocketQA
RocketQA-main/rocketqa/__init__.py
# Copyright (c) 2021 RocketQA Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
702
36
74
py
RocketQA
RocketQA-main/rocketqa/encoder/dual_encoder.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
15,636
38.190476
114
py
RocketQA
RocketQA-main/rocketqa/encoder/__init__.py
0
0
0
py
RocketQA
RocketQA-main/rocketqa/encoder/cross_encoder.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
13,669
38.623188
114
py
RocketQA
RocketQA-main/rocketqa/reader/reader_ce_predict.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
13,177
35.913165
103
py
RocketQA
RocketQA-main/rocketqa/reader/reader_ce_train.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
12,784
37.050595
138
py
RocketQA
RocketQA-main/rocketqa/reader/reader_de_train.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
15,595
38.887468
113
py
RocketQA
RocketQA-main/rocketqa/reader/__init__.py
0
0
0
py
RocketQA
RocketQA-main/rocketqa/reader/reader_de_predict.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
13,619
36.01087
97
py
RocketQA
RocketQA-main/rocketqa/utils/optimization.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
5,188
37.723881
84
py
RocketQA
RocketQA-main/rocketqa/utils/tokenization.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required...
14,348
32.921986
84
py
RocketQA
RocketQA-main/rocketqa/utils/args.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
3,047
34.858824
119
py
RocketQA
RocketQA-main/rocketqa/utils/finetune_args.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
8,590
68.845528
134
py
RocketQA
RocketQA-main/rocketqa/utils/init.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
2,695
34.946667
108
py
RocketQA
RocketQA-main/rocketqa/utils/batching.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
2,683
33.410256
78
py
RocketQA
RocketQA-main/rocketqa/utils/__init__.py
0
0
0
py
RocketQA
RocketQA-main/rocketqa/model/dual_encoder_predict.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
3,319
31.54902
74
py
RocketQA
RocketQA-main/rocketqa/model/cross_encoder_predict.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
4,645
33.932331
85
py
RocketQA
RocketQA-main/rocketqa/model/dual_encoder_train.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
5,659
36.733333
109
py
RocketQA
RocketQA-main/rocketqa/model/transformer_encoder.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
12,649
35.666667
91
py
RocketQA
RocketQA-main/rocketqa/model/__init__.py
0
0
0
py
RocketQA
RocketQA-main/rocketqa/model/cross_encoder_train.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
5,057
32.72
85
py
RocketQA
RocketQA-main/rocketqa/model/ernie.py
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
11,019
38.783394
92
py
RocketQA
RocketQA-main/examples/example.py
import os import sys import rocketqa def train_dual_encoder(base_model, train_set): dual_encoder = rocketqa.load_model(model=base_model, use_cuda=True, device_id=5, batch_size=16) dual_encoder.train(train_set, 2, 'de_en_models', save_steps=10, learning_rate=1e-5, log_folder='de_en_log') def train_cross_enco...
2,742
35.573333
112
py
RocketQA
RocketQA-main/examples/jina3_example/app.py
import sys import os import webbrowser from pathlib import Path from docarray import Document,DocumentArray from jina import Flow from quart import Quart,render_template def config(): os.environ.setdefault('JINA_USE_CUDA', 'False') os.environ.setdefault('JINA_PORT_EXPOSE', '8886') os.environ.setdefault('J...
4,462
32.810606
115
py
RocketQA
RocketQA-main/examples/jina3_example/rocketqa_encoder/executor.py
from jina import Executor, requests from docarray import Document,DocumentArray import numpy as np import rocketqa class RocketQADualEncoder(Executor): """ Calculate the `embedding` of the passages and questions with RocketQA Dual-Encoder models. """ def __init__(self, model, use_cuda=False, device_i...
1,651
42.473684
118
py
RocketQA
RocketQA-main/examples/jina3_example/rocketqa_reranker/executor.py
import numpy as np import rocketqa from jina import Executor, requests from docarray import Document, DocumentArray from docarray.score import NamedScore class RocketQAReranker(Executor): """ Re-rank the `matches` of a Document based on the relevance to the question stored in the `text` field with RocketQA m...
2,407
43.592593
143
py
RocketQA
RocketQA-main/examples/es_example/query.py
# -*- coding: utf-8 -*- import sys import time import numpy as np import rocketqa from elasticsearch import Elasticsearch class Querier: def __init__(self, es_client, index_name, de_model, ce_model): self.es_client = es_client self.index_name = index_name self.dual_encoder = rocketqa.loa...
2,772
27.885417
116
py
RocketQA
RocketQA-main/examples/es_example/index.py
# -*- coding: utf-8 -*- import argparse import os import sys import faiss import numpy as np import rocketqa from elasticsearch import Elasticsearch, helpers class Indexer: def __init__(self, es_client, index_name, model): self.es_client = es_client self.index_name = index_name self.dual...
2,088
27.616438
124
py
RocketQA
RocketQA-main/examples/faiss_example/rocketqa_service.py
import os import sys import json import faiss import numpy as np from tornado import web from tornado import ioloop import rocketqa class FaissTool(): """ Faiss index tools """ def __init__(self, text_filename, index_filename): self.engine = faiss.read_index(index_filename) self.id2text...
4,878
28.932515
93
py
RocketQA
RocketQA-main/examples/faiss_example/query.py
import sys import requests import json SERVICE_ADD = 'http://localhost:8888/rocketqa' TOPK = 5 while 1: query = input("please input a query:\t") if query.strip() == '': break input_data = {} input_data['query'] = query input_data['topk'] = TOPK json_str = json.dumps(input_data) r...
699
24
83
py
RocketQA
RocketQA-main/examples/faiss_example/index.py
import os import sys import numpy as np import faiss import rocketqa def build_index(encoder_conf, index_file_name, title_list, para_list): dual_encoder = rocketqa.load_model(**encoder_conf) para_embs = dual_encoder.encode_para(para=para_list, title=title_list) para_embs = np.array(list(para_embs)) ...
1,456
26.490566
84
py
RocketQA
RocketQA-main/examples/jina_example/app.py
import sys import os import webbrowser from pathlib import Path from jina import Document, Flow def config(): os.environ.setdefault('JINA_USE_CUDA', 'False') os.environ.setdefault('JINA_PORT_EXPOSE', '8886') os.environ.setdefault('JINA_WORKSPACE', './workspace') def index(file_name): def load_marco(...
3,206
29.542857
94
py
RocketQA
RocketQA-main/examples/jina_example/rocketqa_encoder/executor.py
import numpy as np from jina import Executor, requests import rocketqa class RocketQADualEncoder(Executor): """ Calculate the `embedding` of the passages and questions with RocketQA Dual-Encoder models. """ def __init__(self, model, use_cuda=False, device_id=0, batch_size=1, *args, **kwargs): ...
1,817
42.285714
118
py