repo stringlengths 1 99 | file stringlengths 13 215 | code stringlengths 12 59.2M | file_length int64 12 59.2M | avg_line_length float64 3.82 1.48M | max_line_length int64 12 2.51M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
GXN | GXN-main/util.py | from __future__ import print_function
import random
import os
import numpy as np
import networkx as nx
import argparse
import torch
from sklearn.model_selection import StratifiedKFold
cmd_opt = argparse.ArgumentParser(description='Argparser for graph_classification')
cmd_opt.add_argument('-mode', default='cpu', help=... | 7,339 | 41.183908 | 153 | py |
GXN | GXN-main/ops.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import math
import numpy as np
import scipy.sparse as sp
def spec_normalize_adj(adj, high_order=False):
adj = adj.to_dense().cpu().numpy()
adj = sp.coo_matrix(adj)
rowsum = np.array(adj.sum(1))
d_inv_sqrt = np.power(rowsum, -0.5).flat... | 10,385 | 31.867089 | 107 | py |
GXN | GXN-main/mlp_dropout.py | from __future__ import print_function
from torch.autograd import Variable
import torch.nn as nn
import torch.nn.functional as F
class MLPRegression(nn.Module):
def __init__(self, input_size, hidden_size):
super(MLPRegression, self).__init__()
self.h1_weights = nn.Linear(input_size, hidden_size)
... | 1,575 | 28.735849 | 87 | py |
GXN | GXN-main/lib/pytorch_util.py | from __future__ import print_function
import os
import sys
import numpy as np
import torch
import random
from torch.autograd import Variable
from torch.nn.parameter import Parameter
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from tqdm import tqdm
from gnn_lib import GNNLIB
def ... | 1,850 | 25.070423 | 80 | py |
GXN | GXN-main/lib/gnn_lib.py | import ctypes
import numpy as np
import os
import sys
import torch
import pdb
class _gnn_lib(object):
def __init__(self, args):
dir_path = os.path.dirname(os.path.realpath(__file__))
self.lib = ctypes.CDLL('%s/build/dll/libgnn.so' % dir_path)
self.lib.GetGraphStruct.restype = ctypes.c_voi... | 3,813 | 40.912088 | 114 | py |
GXN | GXN-main/pytorch_structure2vec-master/graph_classification/main.py | import sys
import os
import torch
import random
import numpy as np
from tqdm import tqdm
from torch.autograd import Variable
from torch.nn.parameter import Parameter
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
sys.path.append('%s/../s2v_lib' % os.path.dirname(os.path.realpath(__fi... | 4,506 | 35.346774 | 116 | py |
GXN | GXN-main/pytorch_structure2vec-master/s2v_lib/s2v_lib.py | import ctypes
import numpy as np
import os
import sys
import torch
class _s2v_lib(object):
def __init__(self, args):
dir_path = os.path.dirname(os.path.realpath(__file__))
self.lib = ctypes.CDLL('%s/build/dll/libs2v.so' % dir_path)
self.lib.GetGraphStruct.restype = ctypes.c_void_p
... | 6,308 | 43.429577 | 118 | py |
GXN | GXN-main/pytorch_structure2vec-master/s2v_lib/embedding.py | from __future__ import print_function
import os
import sys
import numpy as np
import torch
import random
from torch.autograd import Variable
from torch.nn.parameter import Parameter
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from tqdm import tqdm
from s2v_lib import S2VLIB
from ... | 4,855 | 33.685714 | 91 | py |
GXN | GXN-main/pytorch_structure2vec-master/s2v_lib/pytorch_util.py | from __future__ import print_function
import os
import sys
import numpy as np
import torch
import random
from torch.autograd import Variable
from torch.nn.parameter import Parameter
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from tqdm import tqdm
from s2v_lib import S2VLIB
def ... | 1,885 | 25.194444 | 80 | py |
GXN | GXN-main/pytorch_structure2vec-master/s2v_lib/mlp.py | from __future__ import print_function
import os
import sys
import numpy as np
import torch
import random
from torch.autograd import Variable
from torch.nn.parameter import Parameter
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from tqdm import tqdm
from pytorch_util import weights... | 1,710 | 25.734375 | 80 | py |
GXN | GXN-main/pytorch_structure2vec-master/harvard_cep/main.py | import sys
import os
from mol_lib import MOLLIB, MolGraph
import torch
import random
import numpy as np
from tqdm import tqdm
from torch.autograd import Variable
from torch.nn.parameter import Parameter
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
sys.path.append('%s/../s2v_lib' % ... | 6,670 | 42.888158 | 174 | py |
GXN | GXN-main/pytorch_structure2vec-master/harvard_cep/mol_lib.py | import ctypes
import numpy as np
import os
import sys
import torch
from tqdm import tqdm
class _mol_lib(object):
def __init__(self):
dir_path = os.path.dirname(os.path.realpath(__file__))
self.lib = ctypes.CDLL('%s/build/dll/libmol.so' % dir_path)
# self.lib.Smiles2Graph.restype = ctypes.... | 4,800 | 34.828358 | 129 | py |
SeeChart | SeeChart-main/qna.py | # !pip install transformers
# !pip install datasets
# !pip install nltk
import json
import math
import os
import sys
import nltk # Here to have a nice missing dependency error message early on
import transformers
from filelock import FileLock
from transformers import (
AutoConfig,
AutoModelForSeq2SeqLM,
... | 5,738 | 30.707182 | 393 | py |
lama-cleaner | lama-cleaner-main/scripts/tool.py | import glob
import os
from typing import Dict, List, Union
import torch
from diffusers.utils import is_safetensors_available
if is_safetensors_available():
import safetensors.torch
from huggingface_hub import snapshot_download
from diffusers import DiffusionPipeline, __version__
from diffusers.schedulers.sche... | 14,778 | 39.825967 | 171 | py |
lama-cleaner | lama-cleaner-main/scripts/convert_vae_pt_to_diffusers.py | import argparse
import io
import requests
import torch
from omegaconf import OmegaConf
from diffusers import AutoencoderKL
from diffusers.pipelines.stable_diffusion.convert_from_ckpt import (
assign_to_checkpoint,
conv_attn_to_linear,
create_vae_diffusers_config,
renew_vae_attention_paths,
renew_v... | 7,961 | 33.318966 | 117 | py |
lama-cleaner | lama-cleaner-main/lama_cleaner/model_manager.py | import torch
import gc
from loguru import logger
from lama_cleaner.const import SD15_MODELS
from lama_cleaner.helper import switch_mps_device
from lama_cleaner.model.controlnet import ControlNet
from lama_cleaner.model.fcf import FcF
from lama_cleaner.model.lama import LaMa
from lama_cleaner.model.ldm import LDM
from... | 4,073 | 34.12069 | 86 | py |
lama-cleaner | lama-cleaner-main/lama_cleaner/benchmark.py | #!/usr/bin/env python3
import argparse
import os
import time
import numpy as np
import nvidia_smi
import psutil
import torch
from lama_cleaner.model_manager import ModelManager
from lama_cleaner.schema import Config, HDStrategy, SDSampler
try:
torch._C._jit_override_can_fuse_on_cpu(False)
torch._C._jit_over... | 3,215 | 28.236364 | 100 | py |
lama-cleaner | lama-cleaner-main/lama_cleaner/server.py | #!/usr/bin/env python3
import os
import hashlib
os.environ["PYTORCH_ENABLE_MPS_FALLBACK"] = "1"
import imghdr
import io
import logging
import multiprocessing
import random
import time
from pathlib import Path
import cv2
import numpy as np
import torch
from PIL import Image
from loguru import logger
from lama_cleane... | 18,878 | 29.303371 | 109 | py |
lama-cleaner | lama-cleaner-main/lama_cleaner/helper.py | import io
import os
import sys
from typing import List, Optional
from urllib.parse import urlparse
import cv2
from PIL import Image, ImageOps, PngImagePlugin
import numpy as np
import torch
from lama_cleaner.const import MPS_SUPPORT_MODELS
from loguru import logger
from torch.hub import download_url_to_file, get_dir
i... | 8,639 | 28.488055 | 165 | py |
lama-cleaner | lama-cleaner-main/lama_cleaner/runtime.py | # https://github.com/huggingface/huggingface_hub/blob/5a12851f54bf614be39614034ed3a9031922d297/src/huggingface_hub/utils/_runtime.py
import platform
import sys
import packaging.version
from rich import print
from typing import Dict, Any
_PY_VERSION: str = sys.version.split()[0].rstrip("+")
if packaging.version.Versio... | 1,374 | 25.960784 | 132 | py |
lama-cleaner | lama-cleaner-main/lama_cleaner/parse_args.py | import os
import imghdr
import argparse
from pathlib import Path
from loguru import logger
from lama_cleaner.const import *
from lama_cleaner.runtime import dump_environment_info
def parse_args():
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
parser.a... | 8,695 | 32.836576 | 116 | py |
lama-cleaner | lama-cleaner-main/lama_cleaner/plugins/gfpganer.py | import os
import torch
from facexlib.utils.face_restoration_helper import FaceRestoreHelper
from gfpgan import GFPGANv1Clean, GFPGANer
from torch.hub import get_dir
class MyGFPGANer(GFPGANer):
"""Helper for restoration with GFPGAN.
It will detect and crop faces, and then resize the faces to 512x512.
GFP... | 2,750 | 31.364706 | 110 | py |
lama-cleaner | lama-cleaner-main/lama_cleaner/plugins/anime_seg.py | import cv2
import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
from PIL import Image
from lama_cleaner.helper import load_model
from lama_cleaner.plugins.base_plugin import BasePlugin
class REBNCONV(nn.Module):
def __init__(self, in_ch=3, out_ch=3, dirate=1, stride=1):
s... | 13,465 | 28.530702 | 86 | py |
lama-cleaner | lama-cleaner-main/lama_cleaner/plugins/remove_bg.py | import os
import cv2
import numpy as np
from torch.hub import get_dir
from lama_cleaner.plugins.base_plugin import BasePlugin
class RemoveBG(BasePlugin):
name = "RemoveBG"
def __init__(self):
super().__init__()
from rembg import new_session
hub_dir = get_dir()
model_dir = os... | 1,053 | 25.35 | 87 | py |
lama-cleaner | lama-cleaner-main/lama_cleaner/plugins/segment_anything/predictor.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import numpy as np
import torch
from .modeling import Sam
from typing import Optional, Tuple
class SamPredictor:
d... | 11,845 | 40.41958 | 100 | py |
lama-cleaner | lama-cleaner-main/lama_cleaner/plugins/segment_anything/build_sam.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
from functools import partial
from .modeling import ImageEncoderViT, MaskDecoder, PromptEncoder, Sam, TwoWa... | 2,929 | 26.12963 | 89 | py |
lama-cleaner | lama-cleaner-main/lama_cleaner/plugins/segment_anything/utils/transforms.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import numpy as np
import torch
from torch.nn import functional as F
from torchvision.transforms.functional import resize,... | 4,054 | 34.884956 | 84 | py |
lama-cleaner | lama-cleaner-main/lama_cleaner/plugins/segment_anything/modeling/mask_decoder.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
from torch import nn
from torch.nn import functional as F
from typing import List, Tuple, Type
from .common... | 6,614 | 36.372881 | 123 | py |
lama-cleaner | lama-cleaner-main/lama_cleaner/plugins/segment_anything/modeling/image_encoder.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn as nn
import torch.nn.functional as F
from typing import Optional, Tuple, Type
from .common... | 14,407 | 35.383838 | 202 | py |
lama-cleaner | lama-cleaner-main/lama_cleaner/plugins/segment_anything/modeling/prompt_encoder.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import numpy as np
import torch
from torch import nn
from typing import Any, Optional, Tuple, Type
from .common import L... | 8,594 | 38.976744 | 97 | py |
lama-cleaner | lama-cleaner-main/lama_cleaner/plugins/segment_anything/modeling/transformer.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
from torch import Tensor, nn
import math
from typing import Tuple, Type
from .common import MLPBlock
clas... | 8,396 | 33.842324 | 89 | py |
lama-cleaner | lama-cleaner-main/lama_cleaner/plugins/segment_anything/modeling/common.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn as nn
from typing import Type
class MLPBlock(nn.Module):
def __init__(
self,
... | 1,479 | 32.636364 | 136 | py |
lama-cleaner | lama-cleaner-main/lama_cleaner/plugins/segment_anything/modeling/sam.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
from torch import nn
from torch.nn import functional as F
from typing import Any, Dict, List, Tuple
from .i... | 7,225 | 40.291429 | 95 | py |
lama-cleaner | lama-cleaner-main/lama_cleaner/tests/test_paint_by_example.py | from pathlib import Path
import cv2
import pytest
import torch
from PIL import Image
from lama_cleaner.model_manager import ModelManager
from lama_cleaner.schema import HDStrategy
from lama_cleaner.tests.test_model import get_config, get_data
current_dir = Path(__file__).parent.absolute().resolve()
save_dir = curren... | 3,985 | 36.252336 | 114 | py |
lama-cleaner | lama-cleaner-main/lama_cleaner/tests/test_instruct_pix2pix.py | from pathlib import Path
import pytest
import torch
from lama_cleaner.model_manager import ModelManager
from lama_cleaner.tests.test_model import get_config, assert_equal
from lama_cleaner.schema import HDStrategy
current_dir = Path(__file__).parent.absolute().resolve()
save_dir = current_dir / 'result'
save_dir.mkd... | 2,322 | 35.873016 | 119 | py |
lama-cleaner | lama-cleaner-main/lama_cleaner/tests/test_controlnet.py | import os
from lama_cleaner.const import SD_CONTROLNET_CHOICES
os.environ["PYTORCH_ENABLE_MPS_FALLBACK"] = "1"
from pathlib import Path
import pytest
import torch
from lama_cleaner.model_manager import ModelManager
from lama_cleaner.schema import HDStrategy, SDSampler
from lama_cleaner.tests.test_model import get_c... | 6,219 | 30.734694 | 85 | py |
lama-cleaner | lama-cleaner-main/lama_cleaner/tests/test_plugins.py | import hashlib
import os
import time
from lama_cleaner.plugins.anime_seg import AnimeSeg
os.environ["PYTORCH_ENABLE_MPS_FALLBACK"] = "1"
from pathlib import Path
import cv2
import pytest
import torch.cuda
from lama_cleaner.plugins import (
RemoveBG,
RealESRGANUpscaler,
GFPGANPlugin,
RestoreFormerPlu... | 2,965 | 27.519231 | 73 | py |
lama-cleaner | lama-cleaner-main/lama_cleaner/tests/test_model_md5.py | def test_load_model():
from lama_cleaner.plugins import InteractiveSeg
from lama_cleaner.model_manager import ModelManager
interactive_seg_model = InteractiveSeg('vit_l', 'cpu')
models = [
"lama",
"ldm",
"zits",
"mat",
"fcf",
"manga",
]
for m in ... | 1,505 | 29.12 | 77 | py |
lama-cleaner | lama-cleaner-main/lama_cleaner/tests/test_sd_model.py | import os
os.environ["PYTORCH_ENABLE_MPS_FALLBACK"] = "1"
from pathlib import Path
import pytest
import torch
from lama_cleaner.model_manager import ModelManager
from lama_cleaner.schema import HDStrategy, SDSampler
from lama_cleaner.tests.test_model import get_config, assert_equal
current_dir = Path(__file__).pare... | 7,647 | 30.603306 | 99 | py |
lama-cleaner | lama-cleaner-main/lama_cleaner/tests/test_model.py | from pathlib import Path
import cv2
import pytest
import torch
from lama_cleaner.model_manager import ModelManager
from lama_cleaner.schema import Config, HDStrategy, LDMSampler, SDSampler
current_dir = Path(__file__).parent.absolute().resolve()
save_dir = current_dir / "result"
save_dir.mkdir(exist_ok=True, parents... | 5,826 | 28.882051 | 91 | py |
lama-cleaner | lama-cleaner-main/lama_cleaner/model/base.py | import abc
from typing import Optional
import cv2
import torch
import numpy as np
from loguru import logger
from lama_cleaner.helper import (
boxes_from_mask,
resize_max_size,
pad_img_to_modulo,
switch_mps_device,
)
from lama_cleaner.schema import Config, HDStrategy
class InpaintModel:
name = "b... | 9,600 | 31.110368 | 107 | py |
lama-cleaner | lama-cleaner-main/lama_cleaner/model/lama.py | import os
import cv2
import numpy as np
import torch
from lama_cleaner.helper import (
norm_img,
get_cache_path_by_url,
load_jit_model,
)
from lama_cleaner.model.base import InpaintModel
from lama_cleaner.schema import Config
LAMA_MODEL_URL = os.environ.get(
"LAMA_MODEL_URL",
"https://github.com/... | 1,480 | 27.480769 | 85 | py |
lama-cleaner | lama-cleaner-main/lama_cleaner/model/controlnet.py | import gc
import PIL.Image
import cv2
import numpy as np
import torch
from diffusers import ControlNetModel
from loguru import logger
from lama_cleaner.model.base import DiffusionInpaintModel
from lama_cleaner.model.utils import torch_gc, get_scheduler
from lama_cleaner.schema import Config
class CPUTextEncoderWrap... | 10,883 | 36.531034 | 154 | py |
lama-cleaner | lama-cleaner-main/lama_cleaner/model/utils.py | import math
import random
from typing import Any
import torch
import numpy as np
import collections
from itertools import repeat
from diffusers import (
DDIMScheduler,
PNDMScheduler,
LMSDiscreteScheduler,
EulerDiscreteScheduler,
EulerAncestralDiscreteScheduler,
DPMSolverMultistepScheduler,
... | 33,811 | 34.893843 | 148 | py |
lama-cleaner | lama-cleaner-main/lama_cleaner/model/zits.py | import os
import time
import cv2
import torch
import torch.nn.functional as F
from lama_cleaner.helper import get_cache_path_by_url, load_jit_model
from lama_cleaner.schema import Config
import numpy as np
from lama_cleaner.model.base import InpaintModel
ZITS_INPAINT_MODEL_URL = os.environ.get(
"ZITS_INPAINT_MO... | 15,613 | 33.852679 | 132 | py |
lama-cleaner | lama-cleaner-main/lama_cleaner/model/ddim_sampler.py | import torch
import numpy as np
from tqdm import tqdm
from lama_cleaner.model.utils import make_ddim_timesteps, make_ddim_sampling_parameters, noise_like
from loguru import logger
class DDIMSampler(object):
def __init__(self, model, schedule="linear"):
super().__init__()
self.model = model
... | 6,873 | 34.43299 | 99 | py |
lama-cleaner | lama-cleaner-main/lama_cleaner/model/instruct_pix2pix.py | import PIL.Image
import cv2
import torch
from loguru import logger
from lama_cleaner.model.base import DiffusionInpaintModel
from lama_cleaner.model.utils import set_seed
from lama_cleaner.schema import Config
class InstructPix2Pix(DiffusionInpaintModel):
name = "instruct_pix2pix"
pad_mod = 8
min_size = ... | 3,175 | 36.809524 | 118 | py |
lama-cleaner | lama-cleaner-main/lama_cleaner/model/mat.py | import os
import random
import cv2
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.checkpoint as checkpoint
from lama_cleaner.helper import load_model, get_cache_path_by_url, norm_img
from lama_cleaner.model.base import InpaintModel
from lama_cleaner.model.util... | 62,603 | 31.336777 | 110 | py |
lama-cleaner | lama-cleaner-main/lama_cleaner/model/manga.py | import os
import random
import cv2
import numpy as np
import torch
import time
from loguru import logger
from lama_cleaner.helper import get_cache_path_by_url, load_jit_model
from lama_cleaner.model.base import InpaintModel
from lama_cleaner.schema import Config
MANGA_INPAINTOR_MODEL_URL = os.environ.get(
"MANG... | 2,884 | 30.358696 | 84 | py |
lama-cleaner | lama-cleaner-main/lama_cleaner/model/ldm.py | import os
import numpy as np
import torch
from loguru import logger
from lama_cleaner.model.base import InpaintModel
from lama_cleaner.model.ddim_sampler import DDIMSampler
from lama_cleaner.model.plms_sampler import PLMSSampler
from lama_cleaner.schema import Config, LDMSampler
torch.manual_seed(42)
import torch.nn... | 11,275 | 33.169697 | 116 | py |
lama-cleaner | lama-cleaner-main/lama_cleaner/model/paint_by_example.py | import PIL
import PIL.Image
import cv2
import torch
from diffusers import DiffusionPipeline
from loguru import logger
from lama_cleaner.model.base import DiffusionInpaintModel
from lama_cleaner.model.utils import set_seed
from lama_cleaner.schema import Config
class PaintByExample(DiffusionInpaintModel):
name = ... | 2,934 | 35.6875 | 88 | py |
lama-cleaner | lama-cleaner-main/lama_cleaner/model/plms_sampler.py | # From: https://github.com/CompVis/latent-diffusion/blob/main/ldm/models/diffusion/plms.py
import torch
import numpy as np
from lama_cleaner.model.utils import make_ddim_timesteps, make_ddim_sampling_parameters, noise_like
from tqdm import tqdm
class PLMSSampler(object):
def __init__(self, model, schedule="linear... | 11,851 | 51.442478 | 131 | py |
lama-cleaner | lama-cleaner-main/lama_cleaner/model/fcf.py | import os
import random
import cv2
import torch
import numpy as np
import torch.fft as fft
from lama_cleaner.schema import Config
from lama_cleaner.helper import (
load_model,
get_cache_path_by_url,
norm_img,
boxes_from_mask,
resize_max_size,
)
from lama_cleaner.model.base import InpaintModel
fro... | 57,098 | 31.929066 | 124 | py |
lama-cleaner | lama-cleaner-main/lama_cleaner/model/sd.py | import gc
import PIL.Image
import cv2
import numpy as np
import torch
from loguru import logger
from lama_cleaner.model.base import DiffusionInpaintModel
from lama_cleaner.model.utils import torch_gc, get_scheduler
from lama_cleaner.schema import Config
class CPUTextEncoderWrapper:
def __init__(self, text_encod... | 6,644 | 33.252577 | 154 | py |
lama-cleaner | lama-cleaner-main/lama_cleaner/model/pipeline/pipeline_stable_diffusion_controlnet_inpaint.py | # Copyright 2023 The HuggingFace Team. 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... | 28,155 | 47.047782 | 146 | py |
pygcn | pygcn-master/setup.py | from setuptools import setup
from setuptools import find_packages
setup(name='pygcn',
version='0.1',
description='Graph Convolutional Networks in PyTorch',
author='Thomas Kipf',
author_email='thomas.kipf@gmail.com',
url='https://tkipf.github.io',
download_url='https://github.com/tki... | 553 | 31.588235 | 60 | py |
pygcn | pygcn-master/pygcn/utils.py | import numpy as np
import scipy.sparse as sp
import torch
def encode_onehot(labels):
classes = set(labels)
classes_dict = {c: np.identity(len(classes))[i, :] for i, c in
enumerate(classes)}
labels_onehot = np.array(list(map(classes_dict.get, labels)),
dtype... | 2,848 | 34.17284 | 78 | py |
pygcn | pygcn-master/pygcn/layers.py | import math
import torch
from torch.nn.parameter import Parameter
from torch.nn.modules.module import Module
class GraphConvolution(Module):
"""
Simple GCN layer, similar to https://arxiv.org/abs/1609.02907
"""
def __init__(self, in_features, out_features, bias=True):
super(GraphConvolution... | 1,297 | 29.186047 | 77 | py |
pygcn | pygcn-master/pygcn/models.py | import torch.nn as nn
import torch.nn.functional as F
from pygcn.layers import GraphConvolution
class GCN(nn.Module):
def __init__(self, nfeat, nhid, nclass, dropout):
super(GCN, self).__init__()
self.gc1 = GraphConvolution(nfeat, nhid)
self.gc2 = GraphConvolution(nhid, nclass)
se... | 541 | 27.526316 | 62 | py |
pygcn | pygcn-master/pygcn/train.py | from __future__ import division
from __future__ import print_function
import time
import argparse
import numpy as np
import torch
import torch.nn.functional as F
import torch.optim as optim
from pygcn.utils import load_data, accuracy
from pygcn.models import GCN
# Training settings
parser = argparse.ArgumentParser(... | 3,427 | 31.037383 | 72 | py |
r_em | r_em-master/training/nn_fcns_local.py | #-*- coding: utf-8 -*-
"""
Created on Sun Feb 17 22:30:18 2019
__author__ = "Ivan Lobato"
"""
from __future__ import absolute_import, division, print_function, unicode_literals
import os
import numpy as np
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import sys
sys.path.append('E:/Neural_... | 52,012 | 34.215301 | 204 | py |
r_em | r_em-master/tk_r_em/tk_r_em.py | """
r_em network suites designed to restore different modalities of electron microscopy data
Author: Ivan Lobato
Email: Ivanlh20@gmail.com
"""
import os
import pathlib
from typing import Tuple
import h5py
import numpy as np
import tensorflow as tf
def expand_dimensions(x):
if x.ndim == 2:
return np.expan... | 8,852 | 32.534091 | 136 | py |
pyRVtest | pyRVtest-main/docs/conf.py | """Sphinx configuration."""
import ast
import copy
import json
import os
from pathlib import Path
import re
import shutil
from typing import Any, Optional, Tuple
import astunparse
import sphinx.application
# get the location of the source directory
source_path = Path(__file__).resolve().parent
# project information... | 6,312 | 39.729032 | 119 | py |
MCSE | MCSE-master/simcse_to_huggingface.py | """
Convert SimCSE's checkpoints to Huggingface style.
code from https://github.com/princeton-nlp/SimCSE
"""
import argparse
import torch
import os
import json
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--path", type=str, help="Path of SimCSE checkpoint folder")
args = parser.par... | 1,340 | 29.477273 | 107 | py |
MCSE | MCSE-master/src/utils.py | import sys
import torch
# Set path to SentEval
PATH_TO_SENTEVAL = './SentEval'
PATH_TO_DATA = './SentEval/data'
# Import SentEval
sys.path.insert(0, PATH_TO_SENTEVAL)
import senteval
def evaluate(model, tokenizer):
def prepare(params, samples):
return
def batcher(params, batch):
sentences = [... | 1,592 | 30.235294 | 84 | py |
MCSE | MCSE-master/src/model.py | import torch
import torch.nn as nn
from transformers.models.bert.modeling_bert import BertPreTrainedModel, BertModel, BertLMPredictionHead
from transformers.models.roberta.modeling_roberta import RobertaPreTrainedModel, RobertaModel, RobertaLMHead
from transformers.modeling_outputs import SequenceClassifierOutput, Base... | 7,235 | 35.730964 | 137 | py |
MCSE | MCSE-master/src/data.py | import torch
from torch.utils.data import Dataset
import h5py
import numpy as np
from torchvision.datasets.folder import default_loader
class ImgSentDataset(Dataset):
def __init__(self,
text_file,
feature_file=None,
shuffle_imgs=False,
random_img... | 1,990 | 25.905405 | 65 | py |
MCSE | MCSE-master/src/evaluation.py | import sys
import os
import logging
import argparse
from prettytable import PrettyTable
import torch
from transformers import AutoModel, AutoTokenizer
# Set PATHs
PATH_TO_SENTEVAL = './SentEval'
PATH_TO_DATA = './SentEval/data'
# Import SentEval
sys.path.insert(0, PATH_TO_SENTEVAL)
import senteval
def print_full_ta... | 9,443 | 39.706897 | 155 | py |
MCSE | MCSE-master/src/train.py | import argparse
import logging
import math
import os
import random
import datasets
from torch.utils.data.dataloader import DataLoader
import torch
from tqdm.auto import tqdm
import transformers
from accelerate import Accelerator
from transformers import (
AdamW,
AutoConfig,
AutoModelForSequenceClassifica... | 15,256 | 34.399072 | 155 | py |
MCSE | MCSE-master/src/train_mix.py | import argparse
import logging
import math
import os
import datasets
from torch.utils.data.dataloader import DataLoader
import torch
from tqdm.auto import tqdm
import transformers
from accelerate import Accelerator
from transformers import (
AdamW,
AutoConfig,
AutoModelForSequenceClassification,
Auto... | 16,025 | 34.852349 | 155 | py |
MCSE | MCSE-master/preprocess/extract_visn_feature.py | import os.path as osp
import h5py
import tqdm
import torch
import torch.nn as nn
import torchvision.transforms as transforms
import torchvision.models as models
from torchvision.datasets.folder import default_loader
def get_visn_arch(arch):
try:
return getattr(models, arch)
except AttributeError as e... | 3,518 | 32.198113 | 112 | py |
MCSE | MCSE-master/SentEval/examples/infersent.py | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
"""
InferSent models. See https://github.com/facebookresearch/InferSent.
"""
from __future__ import absolute_import, division,... | 2,462 | 30.987013 | 92 | py |
MCSE | MCSE-master/SentEval/examples/bow.py | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
from __future__ import absolute_import, division, unicode_literals
import sys
import io
import numpy as np
import logging
# ... | 3,423 | 29.300885 | 82 | py |
MCSE | MCSE-master/SentEval/examples/googleuse.py | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
from __future__ import absolute_import, division
import os
import sys
import logging
import tensorflow as tf
import tensorflow... | 2,205 | 31.441176 | 86 | py |
MCSE | MCSE-master/SentEval/examples/models.py | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
"""
This file contains the definition of encoders used in https://arxiv.org/pdf/1705.02364.pdf
"""
import numpy as np
import t... | 9,875 | 36.12782 | 94 | py |
MCSE | MCSE-master/SentEval/examples/gensen.py | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
"""
Clone GenSen repo here: https://github.com/Maluuba/gensen.git
And follow instructions for loading the model used in batcher... | 2,429 | 31.4 | 82 | py |
MCSE | MCSE-master/SentEval/examples/skipthought.py | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
from __future__ import absolute_import, division, unicode_literals
"""
Example of file for SkipThought in SentEval
"""
import ... | 2,048 | 32.048387 | 97 | py |
MCSE | MCSE-master/SentEval/senteval/engine.py | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
'''
Generic sentence evaluation scripts wrapper
'''
from __future__ import absolute_import, division, unicode_literals
from ... | 6,525 | 49.2 | 139 | py |
MCSE | MCSE-master/SentEval/senteval/rank.py | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
'''
Image-Caption Retrieval with COCO dataset
'''
from __future__ import absolute_import, division, unicode_literals
import os... | 4,643 | 41.605505 | 129 | py |
MCSE | MCSE-master/SentEval/senteval/snli.py | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
'''
SNLI - Entailment
'''
from __future__ import absolute_import, division, unicode_literals
import codecs
import os
import io... | 4,577 | 39.157895 | 75 | py |
MCSE | MCSE-master/SentEval/senteval/utils.py | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
from __future__ import absolute_import, division, unicode_literals
import numpy as np
import re
import inspect
from torch impo... | 2,713 | 27.270833 | 79 | py |
MCSE | MCSE-master/SentEval/senteval/binary.py | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
'''
Binary classifier and corresponding datasets : MR, CR, SUBJ, MPQA
'''
from __future__ import absolute_import, division, uni... | 3,712 | 38.924731 | 79 | py |
MCSE | MCSE-master/SentEval/senteval/mrpc.py | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
'''
MRPC : Microsoft Research Paraphrase (detection) Corpus
'''
from __future__ import absolute_import, division, unicode_liter... | 4,202 | 39.028571 | 80 | py |
MCSE | MCSE-master/SentEval/senteval/sts.py | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
'''
STS-{2012,2013,2014,2015,2016} (unsupervised) and
STS-benchmark (supervised) tasks
'''
from __future__ import absolute_imp... | 12,674 | 42.407534 | 129 | py |
MCSE | MCSE-master/SentEval/senteval/probing.py | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
'''
probing tasks
'''
from __future__ import absolute_import, division, unicode_literals
import os
import io
import copy
impo... | 6,786 | 38.459302 | 120 | py |
MCSE | MCSE-master/SentEval/senteval/sick.py | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
'''
SICK Relatedness and Entailment
'''
from __future__ import absolute_import, division, unicode_literals
import os
import io... | 9,243 | 41.599078 | 80 | py |
MCSE | MCSE-master/SentEval/senteval/trec.py | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
'''
TREC question-type classification
'''
from __future__ import absolute_import, division, unicode_literals
import os
import... | 3,565 | 38.622222 | 79 | py |
MCSE | MCSE-master/SentEval/senteval/sst.py | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
'''
SST - binary classification
'''
from __future__ import absolute_import, division, unicode_literals
import os
import io
im... | 3,946 | 39.690722 | 94 | py |
MCSE | MCSE-master/SentEval/senteval/tools/relatedness.py | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
"""
Semantic Relatedness (supervised) with Pytorch
"""
from __future__ import absolute_import, division, unicode_literals
impo... | 4,552 | 32.725926 | 100 | py |
MCSE | MCSE-master/SentEval/senteval/tools/validation.py | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
"""
Validation and classification
(train) : inner-kfold classifier
(train, test) : kfold classifier
(train, d... | 10,358 | 40.939271 | 93 | py |
MCSE | MCSE-master/SentEval/senteval/tools/classifier.py | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
"""
Pytorch Classifier class in the style of scikit-learn
Classifiers include Logistic Regression and MLP
"""
from __future__ ... | 7,737 | 37.118227 | 94 | py |
MCSE | MCSE-master/SentEval/senteval/tools/ranking.py | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
"""
Image Annotation/Search for COCO with Pytorch
"""
from __future__ import absolute_import, division, unicode_literals
impor... | 15,275 | 41.433333 | 109 | py |
openqasm | openqasm-main/source/conf.py | # Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If ex... | 4,580 | 35.943548 | 100 | py |
ULR | ULR-main/dual-encoder/L2/eval_downstream_task.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. 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 cop... | 23,469 | 39.25729 | 164 | py |
ULR | ULR-main/dual-encoder/L2/train_natcat.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. 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 cop... | 33,817 | 41.753477 | 177 | py |
ULR | ULR-main/dual-encoder/cosine/eval_downstream_task.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. 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 cop... | 22,345 | 39.190647 | 164 | py |
ULR | ULR-main/dual-encoder/cosine/train_natcat.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. 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 cop... | 34,036 | 41.813836 | 177 | py |
ULR | ULR-main/single-encoder/eval_downstream_task.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. 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 cop... | 22,069 | 38.981884 | 150 | py |
ULR | ULR-main/single-encoder/train_natcat.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. 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 cop... | 31,833 | 41.902965 | 177 | py |
interactive-image2video-synthesis | interactive-image2video-synthesis-main/main.py | import argparse
from os import path, makedirs
from experiments import select_experiment
import torch
import yaml
import os
def create_dir_structure(config):
subdirs = ["ckpt", "config", "generated", "log"]
structure = {subdir: path.join(config["base_dir"],config["experiment"],subdir,config["project_name"]) for... | 4,862 | 44.448598 | 188 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.