id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
143,984 | import os
import re
import subprocess
import tempfile
import shutil
import einops
import tqdm
from sys import platform
from typing import List
from PIL import Image
from collections import OrderedDict
import math
import functools
import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
from... | Upconv layer |
143,985 | import os
import re
import subprocess
import tempfile
import shutil
import einops
import tqdm
from sys import platform
from typing import List
from PIL import Image
from collections import OrderedDict
import math
import functools
import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
from... | Make layers by stacking the same blocks. Args: basic_block (nn.module): nn.module class for basic block. (block) num_basic_block (int): number of blocks. (n_layers) Returns: nn.Sequential: Stacked blocks in nn.Sequential. |
143,986 | import os
import re
import subprocess
import tempfile
import shutil
import einops
import tqdm
from sys import platform
from typing import List
from PIL import Image
from collections import OrderedDict
import math
import functools
import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
from... | null |
143,987 | import asyncio
import base64
import io
import cv2
from aiohttp.web_middlewares import middleware
from omegaconf import OmegaConf
import langcodes
import requests
import os
import re
import torch
import time
import logging
import numpy as np
from PIL import Image
from typing import List, Tuple, Union
from aiohttp import... | null |
143,988 | import uuid
import hashlib
import time
import aiohttp
import time
from .common import CommonTranslator, InvalidServerResponse, MissingAPIKeyException
from .keys import YOUDAO_APP_KEY, YOUDAO_SECRET_KEY
def sha256_encode(signStr):
hash_algorithm = hashlib.sha256()
hash_algorithm.update(signStr.encode('utf-8'))
... | null |
143,989 | from typing import Callable, List
import py3langid as langid
from .common import OfflineTranslator, ISO_639_1_TO_VALID_LANGUAGES
from .m2m100 import M2M100Translator
from .sugoi import SugoiTranslator
get_translator: Callable[[str], OfflineTranslator] = None
class OfflineTranslator(CommonTranslator, ModelWrapper):
... | null |
143,990 | import os
from PIL import Image
from abc import abstractmethod
from .rendering.gimp_render import gimp_render
from .utils import Context
OUTPUT_FORMATS = {}
def register_format(format_cls):
for fmt in format_cls.SUPPORTED_FORMATS:
if fmt in OUTPUT_FORMATS:
raise Exception(f'Tried to register mu... | null |
143,991 | import os
from PIL import Image
from abc import abstractmethod
from .rendering.gimp_render import gimp_render
from .utils import Context
class FormatNotSupportedException(Exception):
def __init__(self, fmt: str):
super().__init__(f'Format {fmt} is not supported.')
OUTPUT_FORMATS = {}
class ExportFormat():
... | null |
143,992 | import io
import os
import sys
import re
import shutil
import mimetypes
import time
import asyncio
import subprocess
import secrets
from io import BytesIO
from PIL import Image
from aiohttp import web
from collections import deque
from imagehash import phash
SERVER_DIR_PATH = os.path.dirname(os.path.realpath(__file__))... | null |
143,993 | import io
import os
import sys
import re
import shutil
import mimetypes
import time
import asyncio
import subprocess
import secrets
from io import BytesIO
from PIL import Image
from aiohttp import web
from collections import deque
from imagehash import phash
SERVER_DIR_PATH = os.path.dirname(os.path.realpath(__file__))... | null |
143,994 | import io
import os
import sys
import re
import shutil
import mimetypes
import time
import asyncio
import subprocess
import secrets
from io import BytesIO
from PIL import Image
from aiohttp import web
from collections import deque
from imagehash import phash
FORMAT = ''
async def result_async(request):
global FORM... | null |
143,995 | import io
import os
import sys
import re
import shutil
import mimetypes
import time
import asyncio
import subprocess
import secrets
from io import BytesIO
from PIL import Image
from aiohttp import web
from collections import deque
from imagehash import phash
FORMAT = ''
async def file_type_async(request):
global F... | null |
143,996 | import io
import os
import sys
import re
import shutil
import mimetypes
import time
import asyncio
import subprocess
import secrets
from io import BytesIO
from PIL import Image
from aiohttp import web
from collections import deque
from imagehash import phash
QUEUE = deque()
async def queue_size_async(request):
ret... | null |
143,997 | import io
import os
import sys
import re
import shutil
import mimetypes
import time
import asyncio
import subprocess
import secrets
from io import BytesIO
from PIL import Image
from aiohttp import web
from collections import deque
from imagehash import phash
QUEUE = deque()
TASK_DATA = {}
TASK_STATES = {}
FORMAT = ''
a... | null |
143,998 | import io
import os
import sys
import re
import shutil
import mimetypes
import time
import asyncio
import subprocess
import secrets
from io import BytesIO
from PIL import Image
from aiohttp import web
from collections import deque
from imagehash import phash
VALID_TRANSLATORS = [
'youdao',
'baidu',
'google'... | null |
143,999 | import io
import os
import sys
import re
import shutil
import mimetypes
import time
import asyncio
import subprocess
import secrets
from io import BytesIO
from PIL import Image
from aiohttp import web
from collections import deque
from imagehash import phash
MAX_ONGOING_TASKS = 1
ONGOING_TASKS = []
NONCE = ''
QUEUE = d... | Called by the translator to get a translation task. |
144,000 | import io
import os
import sys
import re
import shutil
import mimetypes
import time
import asyncio
import subprocess
import secrets
from io import BytesIO
from PIL import Image
from aiohttp import web
from collections import deque
from imagehash import phash
TASK_DATA = {}
TASK_STATES = {}
async def cancel_manual_tran... | null |
144,001 | import io
import os
import sys
import re
import shutil
import mimetypes
import time
import asyncio
import subprocess
import secrets
from io import BytesIO
from PIL import Image
from aiohttp import web
from collections import deque
from imagehash import phash
TASK_DATA = {}
TASK_STATES = {}
async def post_translation_r... | null |
144,002 | import io
import os
import sys
import re
import shutil
import mimetypes
import time
import asyncio
import subprocess
import secrets
from io import BytesIO
from PIL import Image
from aiohttp import web
from collections import deque
from imagehash import phash
NONCE = ''
TASK_DATA = {}
def constant_compare(a, b):
if ... | null |
144,003 | import io
import os
import sys
import re
import shutil
import mimetypes
import time
import asyncio
import subprocess
import secrets
from io import BytesIO
from PIL import Image
from aiohttp import web
from collections import deque
from imagehash import phash
NONCE = ''
TASK_DATA = {}
def constant_compare(a, b):
if ... | null |
144,004 | import io
import os
import sys
import re
import shutil
import mimetypes
import time
import asyncio
import subprocess
import secrets
from io import BytesIO
from PIL import Image
from aiohttp import web
from collections import deque
from imagehash import phash
QUEUE = deque()
TASK_DATA = {}
TASK_STATES = {}
The provided... | Web API for getting the state of an on-going translation task from the website. Is periodically called from ui.html. Once it returns a finished state, the web client will try to fetch the corresponding image through /result/<task_id> |
144,005 | import io
import os
import sys
import re
import shutil
import mimetypes
import time
import asyncio
import subprocess
import secrets
from io import BytesIO
from PIL import Image
from aiohttp import web
from collections import deque
from imagehash import phash
ONGOING_TASKS = []
FINISHED_TASKS = []
NONCE = ''
TASK_DATA =... | Lets the translator update the task state it is working on. |
144,006 | import io
import os
import sys
import re
import shutil
import mimetypes
import time
import asyncio
import subprocess
import secrets
from io import BytesIO
from PIL import Image
from aiohttp import web
from collections import deque
from imagehash import phash
QUEUE = deque()
TASK_DATA = {}
TASK_STATES = {}
FORMAT = ''
a... | Adds new task to the queue. Called by web client in ui.html when submitting an image. |
144,007 | import io
import os
import sys
import re
import shutil
import mimetypes
import time
import asyncio
import subprocess
import secrets
from io import BytesIO
from PIL import Image
from aiohttp import web
from collections import deque
from imagehash import phash
QUEUE = deque()
TASK_DATA = {}
TASK_STATES = {}
async def han... | null |
144,008 | import io
import os
import sys
import re
import shutil
import mimetypes
import time
import asyncio
import subprocess
import secrets
from io import BytesIO
from PIL import Image
from aiohttp import web
from collections import deque
from imagehash import phash
WEB_CLIENT_TIMEOUT = -1
FINISHED_TASK_REMOVE_TIMEOUT = 1800
D... | null |
144,009 | import os
from typing import List, Callable, Tuple
import numpy as np
import cv2
import functools
from PIL import Image
import tqdm
import requests
import sys
import hashlib
import re
import einops
import unicodedata
import json
from shapely import affinity
from shapely.geometry import Polygon, MultiPoint
def atoi(text... | null |
144,010 | import os
from typing import List, Callable, Tuple
import numpy as np
import cv2
import functools
from PIL import Image
import tqdm
import requests
import sys
import hashlib
import re
import einops
import unicodedata
import json
from shapely import affinity
from shapely.geometry import Polygon, MultiPoint
The provided... | Extracts repeating sequence from string. Example: 'abcabca' -> 'abc'. |
144,011 | import os
from typing import List, Callable, Tuple
import numpy as np
import cv2
import functools
from PIL import Image
import tqdm
import requests
import sys
import hashlib
import re
import einops
import unicodedata
import json
from shapely import affinity
from shapely.geometry import Polygon, MultiPoint
def is_valuab... | null |
144,012 | import os
from typing import List, Callable, Tuple
import numpy as np
import cv2
import functools
from PIL import Image
import tqdm
import requests
import sys
import hashlib
import re
import einops
import unicodedata
import json
from shapely import affinity
from shapely.geometry import Polygon, MultiPoint
def is_valuab... | null |
144,013 | import os
from typing import List, Callable, Tuple
import numpy as np
import cv2
import functools
from PIL import Image
import tqdm
import requests
import sys
import hashlib
import re
import einops
import unicodedata
import json
from shapely import affinity
from shapely.geometry import Polygon, MultiPoint
The provided... | Checks whether the char belongs to a right to left alphabet. |
144,014 | import os
from typing import List, Callable, Tuple
import numpy as np
import cv2
import functools
from PIL import Image
import tqdm
import requests
import sys
import hashlib
import re
import einops
import unicodedata
import json
from shapely import affinity
from shapely.geometry import Polygon, MultiPoint
def replace_... | null |
144,015 | import os
from typing import List, Callable, Tuple
import numpy as np
import cv2
import functools
from PIL import Image
import tqdm
import requests
import sys
import hashlib
import re
import einops
import unicodedata
import json
from shapely import affinity
from shapely.geometry import Polygon, MultiPoint
The provided... | Yield successive n-sized chunks from lst. |
144,016 | import os
from typing import List, Callable, Tuple
import numpy as np
import cv2
import functools
from PIL import Image
import tqdm
import requests
import sys
import hashlib
import re
import einops
import unicodedata
import json
from shapely import affinity
from shapely.geometry import Polygon, MultiPoint
def get_dige... | null |
144,017 | import os
from typing import List, Callable, Tuple
import numpy as np
import cv2
import functools
from PIL import Image
import tqdm
import requests
import sys
import hashlib
import re
import einops
import unicodedata
import json
from shapely import affinity
from shapely.geometry import Polygon, MultiPoint
def get_filen... | null |
144,018 | import os
from typing import List, Callable, Tuple
import numpy as np
import cv2
import functools
from PIL import Image
import tqdm
import requests
import sys
import hashlib
import re
import einops
import unicodedata
import json
from shapely import affinity
from shapely.geometry import Polygon, MultiPoint
def prompt_y... | null |
144,019 | import os
from typing import List, Callable, Tuple
import numpy as np
import cv2
import functools
from PIL import Image
import tqdm
import requests
import sys
import hashlib
import re
import einops
import unicodedata
import json
from shapely import affinity
from shapely.geometry import Polygon, MultiPoint
def load_ima... | null |
144,020 | import os
from typing import List, Callable, Tuple
import numpy as np
import cv2
import functools
from PIL import Image
import tqdm
import requests
import sys
import hashlib
import re
import einops
import unicodedata
import json
from shapely import affinity
from shapely.geometry import Polygon, MultiPoint
def dump_ima... | null |
144,021 | import os
from typing import List, Callable, Tuple
import numpy as np
import cv2
import functools
from PIL import Image
import tqdm
import requests
import sys
import hashlib
import re
import einops
import unicodedata
import json
from shapely import affinity
from shapely.geometry import Polygon, MultiPoint
def resize_k... | null |
144,022 | import os
from typing import List, Callable, Tuple
import numpy as np
import cv2
import functools
from PIL import Image
import tqdm
import requests
import sys
import hashlib
import re
import einops
import unicodedata
import json
from shapely import affinity
from shapely.geometry import Polygon, MultiPoint
def image_re... | null |
144,023 | import os
from typing import List, Callable, Tuple
import numpy as np
import cv2
import functools
from PIL import Image
import tqdm
import requests
import sys
import hashlib
import re
import einops
import unicodedata
import json
from shapely import affinity
from shapely.geometry import Polygon, MultiPoint
def resize_p... | null |
144,024 | import os
from typing import List, Callable, Tuple
import numpy as np
import cv2
import functools
from PIL import Image
import tqdm
import requests
import sys
import hashlib
import re
import einops
import unicodedata
import json
from shapely import affinity
from shapely.geometry import Polygon, MultiPoint
def dist(x1, ... | null |
144,025 | import os
from typing import List, Callable, Tuple
import numpy as np
import cv2
import functools
from PIL import Image
import tqdm
import requests
import sys
import hashlib
import re
import einops
import unicodedata
import json
from shapely import affinity
from shapely.geometry import Polygon, MultiPoint
def distance... | null |
144,026 | import os
from typing import List, Callable, Tuple
import numpy as np
import cv2
import functools
from PIL import Image
import tqdm
import requests
import sys
import hashlib
import re
import einops
import unicodedata
import json
from shapely import affinity
from shapely.geometry import Polygon, MultiPoint
def distance... | null |
144,027 | import os
from typing import List, Callable, Tuple
import numpy as np
import cv2
import functools
from PIL import Image
import tqdm
import requests
import sys
import hashlib
import re
import einops
import unicodedata
import json
from shapely import affinity
from shapely.geometry import Polygon, MultiPoint
class Quadril... | null |
144,028 | import os
from typing import List, Callable, Tuple
import numpy as np
import cv2
import functools
from PIL import Image
import tqdm
import requests
import sys
import hashlib
import re
import einops
import unicodedata
import json
from shapely import affinity
from shapely.geometry import Polygon, MultiPoint
def findNext... | null |
144,029 | import os
from typing import List, Callable, Tuple
import numpy as np
import cv2
import functools
from PIL import Image
import tqdm
import requests
import sys
import hashlib
import re
import einops
import unicodedata
import json
from shapely import affinity
from shapely.geometry import Polygon, MultiPoint
class Point:
... | null |
144,030 | import os
from typing import List, Callable, Tuple
import numpy as np
import cv2
import functools
from PIL import Image
import tqdm
import requests
import sys
import hashlib
import re
import einops
import unicodedata
import json
from shapely import affinity
from shapely.geometry import Polygon, MultiPoint
def color_di... | null |
144,031 | import os
from typing import List, Callable, Tuple
import numpy as np
import cv2
import functools
from PIL import Image
import tqdm
import requests
import sys
import hashlib
import re
import einops
import unicodedata
import json
from shapely import affinity
from shapely.geometry import Polygon, MultiPoint
def rgb2hex(... | null |
144,032 | import os
from typing import List, Callable, Tuple
import numpy as np
import cv2
import functools
from PIL import Image
import tqdm
import requests
import sys
import hashlib
import re
import einops
import unicodedata
import json
from shapely import affinity
from shapely.geometry import Polygon, MultiPoint
def hex2rgb(... | null |
144,033 | import os
from typing import List, Callable, Tuple
import numpy as np
import cv2
import functools
from PIL import Image
import tqdm
import requests
import sys
import hashlib
import re
import einops
import unicodedata
import json
from shapely import affinity
from shapely.geometry import Polygon, MultiPoint
def get_colo... | null |
144,034 | import os
from typing import List, Callable, Tuple
import numpy as np
import cv2
import functools
from PIL import Image
import tqdm
import requests
import sys
import hashlib
import re
import einops
import unicodedata
import json
from shapely import affinity
from shapely.geometry import Polygon, MultiPoint
def square_pa... | Rearrange image to square batches before feeding into network if following conditions are satisfied: \n 1. Extreme aspect ratio 2. Is too tall or wide for detect size (tgt_size) Returns: DBNet output, mask or None, None if rearrangement is not required |
144,035 | import numpy as np
import cv2
def check_color(image):
"""
Determine whether there are colors in non black, gray, white, and other gray areas in an RGB color image。
params:
image -- np.array
return:
True -- Colors with non black, gray, white, and other grayscale areas
False -- Images are all ... | Principle: Normally, white bubbles and their text boxes are mostly white, while black bubbles and their text boxes are mostly black. We calculate the ratio of white or black pixels around the text block to the total pixels, and judge whether the area is a normal bubble area or not. Based on the value of the --ignore-bu... |
144,036 | import cv2
import numpy as np
from typing import List, Tuple
from shapely.geometry import Polygon, MultiPoint
from functools import cached_property
import copy
import re
import py3langid as langid
from .generic import color_difference, is_right_to_left_char, is_valuable_char
def rotate_polygons(center, polygons, rotat... | null |
144,037 | import cv2
import numpy as np
from typing import List, Tuple
from shapely.geometry import Polygon, MultiPoint
from functools import cached_property
import copy
import re
import py3langid as langid
from .generic import color_difference, is_right_to_left_char, is_valuable_char
class TextBlock(object):
"""
Object ... | null |
144,038 | import cv2
import numpy as np
from typing import List, Tuple
from shapely.geometry import Polygon, MultiPoint
from functools import cached_property
import copy
import re
import py3langid as langid
from .generic import color_difference, is_right_to_left_char, is_valuable_char
class TextBlock(object):
"""
Object ... | null |
144,039 | import logging
import colorama
from .generic import replace_prefix
class Formatter(logging.Formatter):
def formatMessage(self, record: logging.LogRecord) -> str:
if record.levelno >= logging.ERROR:
self._style._fmt = f'{colorama.Fore.RED}%(levelname)s:{colorama.Fore.RESET} [%(name)s] %(message)s... | null |
144,040 | import logging
import colorama
from .generic import replace_prefix
root = logging.getLogger(ROOT_TAG)
def set_log_level(level):
root.setLevel(level) | null |
144,041 | import logging
import colorama
from .generic import replace_prefix
root = logging.getLogger(ROOT_TAG)
def get_logger(name: str):
return root.getChild(name) | null |
144,042 | import logging
import colorama
from .generic import replace_prefix
root = logging.getLogger(ROOT_TAG)
file_handlers = {}
def add_file_logger(path: str):
if path in file_handlers:
return
file_handlers[path] = logging.FileHandler(path, encoding='utf8')
logging.root.addHandler(file_handlers[path]) | null |
144,043 | import logging
import colorama
from .generic import replace_prefix
root = logging.getLogger(ROOT_TAG)
file_handlers = {}
def remove_file_logger(path: str):
if path in file_handlers:
logging.root.removeHandler(file_handlers[path])
file_handlers[path].close()
del file_handlers[path] | null |
144,044 | import argparse
import functools
import subprocess
def read_file(fname):
with open(fname, encoding='utf-8') as f:
return f.read() | null |
144,045 | import argparse
import functools
import subprocess
def write_file(fname, content, mode='w'):
with open(fname, mode, encoding='utf-8') as f:
return f.write(content) | null |
144,048 | import argparse
import functools
import subprocess
def run_process(*args, **kwargs):
kwargs.setdefault('text', True)
kwargs.setdefault('check', True)
kwargs.setdefault('capture_output', True)
if kwargs['text']:
kwargs.setdefault('encoding', 'utf-8')
kwargs.setdefault('errors', 'replace'... | null |
144,049 | import os
import sys
import functools
import re
from devscripts.utils import read_file, write_file
from manga_translator.args import HelpFormatter, parser
def take_section(text, start=None, end=None, *, shift=0):
return text[
text.index(start) + shift if start else None:
text.index(end) + shift if ... | null |
144,050 | import os
import sys
import functools
import re
from devscripts.utils import read_file, write_file
from manga_translator.args import HelpFormatter, parser
DISABLE_PATCH = object()
def apply_patch(text, patch):
return text if patch[0] is DISABLE_PATCH else re.sub(*patch, text) | null |
144,051 | import asyncio
from manga_translator.utils import ModelWrapper
from manga_translator.detection import DETECTORS
from manga_translator.ocr import OCRS
from manga_translator.inpainting import INPAINTERS
async def download(dict):
for key, value in dict.items():
if issubclass(value, ModelWrapper):
print(' -- D... | null |
144,052 | import tensorflow as tf
from tensorflow.contrib import slim
import cv2
import os, random
import numpy as np
def load_test_data(image_path, size=256):
img = cv2.imread(image_path, flags=cv2.IMREAD_COLOR)
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
img = cv2.resize(img, dsize=(size, size))
img = np.expa... | null |
144,053 | import tensorflow as tf
from tensorflow.contrib import slim
import cv2
import os, random
import numpy as np
def augmentation(image, augment_size):
seed = random.randint(0, 2 ** 31 - 1)
ori_image_shape = tf.shape(image)
image = tf.image.random_flip_left_right(image, seed=seed)
image = tf.image.resize_im... | null |
144,054 | import tensorflow as tf
from tensorflow.contrib import slim
import cv2
import os, random
import numpy as np
def inverse_transform(images):
return ((images+1.) / 2) * 255.0
def imsave(images, size, path):
images = merge(images, size)
images = cv2.cvtColor(images.astype('uint8'), cv2.COLOR_RGB2BGR)
return... | null |
144,055 | import tensorflow as tf
from tensorflow.contrib import slim
import cv2
import os, random
import numpy as np
def show_all_variables():
model_vars = tf.trainable_variables()
slim.model_analyzer.analyze_vars(model_vars, print_info=True) | null |
144,056 | import tensorflow as tf
from tensorflow.contrib import slim
import cv2
import os, random
import numpy as np
def check_folder(log_dir):
if not os.path.exists(log_dir):
os.makedirs(log_dir)
return log_dir | null |
144,057 | import tensorflow as tf
from tensorflow.contrib import slim
import cv2
import os, random
import numpy as np
def str2bool(x):
return x.lower() in ('true') | null |
144,058 | from UGATIT import UGATIT
import argparse
from utils import *
def check_args(args):
# --checkpoint_dir
check_folder(args.checkpoint_dir)
# --result_dir
check_folder(args.result_dir)
# --result_dir
check_folder(args.log_dir)
# --sample_dir
check_folder(args.sample_dir)
# --epoch
t... | null |
144,059 | import tensorflow as tf
import tensorflow.contrib as tf_contrib
weight_init = tf.random_normal_initializer(mean=0.0, stddev=0.02)
weight_regularizer = tf_contrib.layers.l2_regularizer(scale=0.0001)
def flatten(x) :
return tf.layers.flatten(x)
def spectral_norm(w, iteration=1):
w_shape = w.shape.as_list()
w ... | null |
144,060 | import tensorflow as tf
import tensorflow.contrib as tf_contrib
weight_init = tf.random_normal_initializer(mean=0.0, stddev=0.02)
weight_regularizer = tf_contrib.layers.l2_regularizer(scale=0.0001)
def flatten(x) :
return tf.layers.flatten(x)
def spectral_norm(w, iteration=1):
w_shape = w.shape.as_list()
w ... | null |
144,061 | import tensorflow as tf
import tensorflow.contrib as tf_contrib
def conv(x, channels, kernel=4, stride=2, pad=0, pad_type='zero', use_bias=True, sn=False, scope='conv_0'):
with tf.variable_scope(scope):
if pad > 0 :
if (kernel - stride) % 2 == 0:
pad_top = pad
pad... | null |
144,062 | import tensorflow as tf
import tensorflow.contrib as tf_contrib
def conv(x, channels, kernel=4, stride=2, pad=0, pad_type='zero', use_bias=True, sn=False, scope='conv_0'):
with tf.variable_scope(scope):
if pad > 0 :
if (kernel - stride) % 2 == 0:
pad_top = pad
pad... | null |
144,063 | import tensorflow as tf
import tensorflow.contrib as tf_contrib
def up_sample(x, scale_factor=2):
_, h, w, _ = x.get_shape().as_list()
new_size = [h * scale_factor, w * scale_factor]
return tf.image.resize_nearest_neighbor(x, size=new_size) | null |
144,064 | import tensorflow as tf
import tensorflow.contrib as tf_contrib
def global_avg_pooling(x):
gap = tf.reduce_mean(x, axis=[1, 2])
return gap | null |
144,065 | import tensorflow as tf
import tensorflow.contrib as tf_contrib
def global_max_pooling(x):
gmp = tf.reduce_max(x, axis=[1, 2])
return gmp | null |
144,066 | import tensorflow as tf
import tensorflow.contrib as tf_contrib
def lrelu(x, alpha=0.01):
# pytorch alpha is 0.01
return tf.nn.leaky_relu(x, alpha) | null |
144,067 | import tensorflow as tf
import tensorflow.contrib as tf_contrib
def tanh(x):
return tf.tanh(x) | null |
144,068 | import tensorflow as tf
import tensorflow.contrib as tf_contrib
def sigmoid(x) :
return tf.sigmoid(x) | null |
144,069 | import tensorflow as tf
import tensorflow.contrib as tf_contrib
def layer_norm(x, scope='layer_norm') :
return tf_contrib.layers.layer_norm(x,
center=True, scale=True,
scope=scope) | null |
144,070 | import tensorflow as tf
import tensorflow.contrib as tf_contrib
def layer_instance_norm(x, scope='layer_instance_norm') :
with tf.variable_scope(scope):
ch = x.shape[-1]
eps = 1e-5
ins_mean, ins_sigma = tf.nn.moments(x, axes=[1, 2], keep_dims=True)
x_ins = (x - ins_mean) / (tf.sqrt... | null |
144,071 | import tensorflow as tf
import tensorflow.contrib as tf_contrib
def L1_loss(x, y):
loss = tf.reduce_mean(tf.abs(x - y))
return loss | null |
144,072 | import tensorflow as tf
import tensorflow.contrib as tf_contrib
def cam_loss(source, non_source) :
identity_loss = tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits(labels=tf.ones_like(source), logits=source))
non_identity_loss = tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits(labels=tf.zeros_like... | null |
144,073 | import tensorflow as tf
import tensorflow.contrib as tf_contrib
The provided code snippet includes necessary dependencies for implementing the `regularization_loss` function. Write a Python function `def regularization_loss(scope_name) ` to solve the following problem:
If you want to use "Regularization" g_loss += reg... | If you want to use "Regularization" g_loss += regularization_loss('generator') d_loss += regularization_loss('discriminator') |
144,074 | import tensorflow as tf
import tensorflow.contrib as tf_contrib
def relu(x):
def discriminator_loss(loss_func, real, fake):
loss = []
real_loss = 0
fake_loss = 0
for i in range(2) :
if loss_func.__contains__('wgan') :
real_loss = -tf.reduce_mean(real[i])
fake_loss = tf.... | null |
144,075 | import tensorflow as tf
import tensorflow.contrib as tf_contrib
def generator_loss(loss_func, fake):
loss = []
fake_loss = 0
for i in range(2) :
if loss_func.__contains__('wgan') :
fake_loss = -tf.reduce_mean(fake[i])
if loss_func == 'lsgan' :
fake_loss = tf.reduce... | null |
144,076 | import streamlit as st
import os, glob
import numpy as np
from yacs import config as CONFIG
import torch
import re
from frontend import g2p_cn_en, ROOT_DIR, read_lexicon, G2p
from exp.DataBaker.config.config import Config
from models.prompt_tts_modified.jets import JETSGenerator
from models.prompt_tts_modified.simbert ... | null |
144,077 | import streamlit as st
import os, glob
import numpy as np
from yacs import config as CONFIG
import torch
import re
from frontend import g2p_cn_en, ROOT_DIR, read_lexicon, G2p
from exp.DataBaker.config.config import Config
from models.prompt_tts_modified.jets import JETSGenerator
from models.prompt_tts_modified.simbert ... | null |
144,078 | import streamlit as st
import os, glob
import numpy as np
from yacs import config as CONFIG
import torch
import re
from frontend import g2p_cn_en, ROOT_DIR, read_lexicon, G2p
from exp.DataBaker.config.config import Config
from models.prompt_tts_modified.jets import JETSGenerator
from models.prompt_tts_modified.simbert ... | null |
144,079 | import math
import os
import random
import torch
from torch import nn
import torch.nn.functional as F
import torch.utils.data
import numpy as np
import librosa
import librosa.util as librosa_util
from librosa.util import normalize, pad_center, tiny
from scipy.signal import get_window
from scipy.io.wavfile import read
f... | null |
144,081 | import math
import os
import random
import torch
from torch import nn
import torch.nn.functional as F
import torch.utils.data
import numpy as np
import librosa
import librosa.util as librosa_util
from librosa.util import normalize, pad_center, tiny
from scipy.signal import get_window
from scipy.io.wavfile import read
f... | null |
144,082 | import torch
from models.prompt_tts_modified.jets import JETSGenerator
from models.prompt_tts_modified.simbert import StyleEncoder
from transformers import AutoTokenizer
import os, sys, torch, argparse
import numpy as np
from models.hifigan.get_vocoder import MAX_WAV_VALUE
import soundfile as sf
from yacs import config... | null |
144,087 | import torch
import os
import shutil
import argparse
ROOT_DIR = os.path.dirname(os.path.abspath("__file__"))
def prepare_info(data_dir, info_dir):
import jsonlines
print('prepare_info: %s' %info_dir)
os.makedirs(info_dir, exist_ok=True)
for name in ["emotion", "energy", "pitch", "speed", "tokenlist"]:... | null |
144,088 | import torch
import os
import shutil
import argparse
ROOT_DIR = os.path.dirname(os.path.abspath("__file__"))
def prepare_config(data_dir, info_dir, exp_dir, config_dir):
print('prepare_config: %s' %config_dir)
os.makedirs(config_dir, exist_ok=True)
with open(f"{ROOT_DIR}/config/template.py") as f, \
... | null |
144,089 | import torch
import os
import shutil
import argparse
ROOT_DIR = os.path.dirname(os.path.abspath("__file__"))
def prepare_ckpt(data_dir, info_dir, ckpt_dir):
print('prepare_ckpt: %s' %ckpt_dir)
os.makedirs(ckpt_dir, exist_ok=True)
with open(f"{info_dir}/speaker") as f:
speaker_list=[line.strip(... | null |
144,090 | import logging
import os
import io
import torch
import glob
from fastapi import FastAPI, Response
from pydantic import BaseModel
from frontend import g2p_cn_en, ROOT_DIR, read_lexicon, G2p
from models.prompt_tts_modified.jets import JETSGenerator
from models.prompt_tts_modified.simbert import StyleEncoder
from transfor... | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.