id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
35,701 | import torch
import numpy as np
from torch.utils.data import IterableDataset, get_worker_info
import pyarrow.parquet as pq
import orjson
from ochat.training_deepspeed.multipack_sampler import MultipackDistributedSampler
def _find_multiple(a, b):
return (-(a // -b)) * b | null |
35,702 | import numpy as np
import numba
def ffd_check(a: np.ndarray, c: int, n: int):
# First-fit-decreasing bin packing
# Check if a[] could fit in n bins with capacity c
# https://en.wikipedia.org/wiki/First-fit-decreasing_bin_packing
a = np.sort(a)[::-1]
bins = np.full((n, ), c, dtype=a.dtype)
for si... | null |
35,703 | import argparse
import asyncio
from http import HTTPStatus
import json
import time
import logging
from logging.handlers import RotatingFileHandler
from typing import AsyncGenerator, Optional
from dataclasses import dataclass
import fastapi
from fastapi import BackgroundTasks, Request
from fastapi.exceptions import Requ... | null |
35,704 | import argparse
import asyncio
from http import HTTPStatus
import json
import time
import logging
from logging.handlers import RotatingFileHandler
from typing import AsyncGenerator, Optional
from dataclasses import dataclass
import fastapi
from fastapi import BackgroundTasks, Request
from fastapi.exceptions import Requ... | null |
35,705 | import argparse
import asyncio
from http import HTTPStatus
import json
import time
import logging
from logging.handlers import RotatingFileHandler
from typing import AsyncGenerator, Optional
from dataclasses import dataclass
import fastapi
from fastapi import BackgroundTasks, Request
from fastapi.exceptions import Requ... | Show available models. Right now we only have one model. |
35,706 | import argparse
import asyncio
from http import HTTPStatus
import json
import time
import logging
from logging.handlers import RotatingFileHandler
from typing import AsyncGenerator, Optional
from dataclasses import dataclass
import fastapi
from fastapi import BackgroundTasks, Request
from fastapi.exceptions import Requ... | Completion API similar to OpenAI's API. See https://platform.openai.com/docs/api-reference/chat/create for the API specification. This API mimics the OpenAI ChatCompletion API. NOTE: Currently we do not support the following features: - function_call (Users should implement this by themselves) - logit_bias (to be suppo... |
35,707 | import argparse
import os
import gc
import random
import ray
import orjson
import pyarrow
from pyarrow import parquet
def generate_epoch(seed: int, model_type: str, model_path: str, in_filename: str, out_filename: str, per_sequence_loss: bool):
# schema
metadata = {
"model_type": model_type
}
sc... | null |
35,708 | from typing import Optional
import argparse
import os
import asyncio
from glob import glob
import orjson
import openai
from tqdm import tqdm
from openai.error import RateLimitError, ServiceUnavailableError
from tenacity import retry, stop_after_attempt, wait_random_exponential, retry_if_exception_type
from vllm import ... | null |
35,709 | import argparse
import os
from pathlib import Path
import orjson
import pandas as pd
from glob import glob
def view_results(result_path: str):
# Read results
eval_results = []
for filename in glob(os.path.join(result_path, "*.json")):
with open(filename, "rb") as f:
questions = orjson.l... | null |
35,710 | from typing import OrderedDict
import signal
import os
import json
import subprocess
import argparse
import time
import requests
import re
import coolname
def find_models(path, prefix, ep_filter):
run_name = '_'.join(coolname.generate(2))
def generate_model_name(root, ep_number):
return f"{prefix}{os.... | null |
35,711 | from typing import OrderedDict
import signal
import os
import json
import subprocess
import argparse
import time
import requests
import re
import coolname
MAX_CONTEXT = 4096
def run_mt_bench(mt_bench_path, model_name):
working_dir = os.path.join(mt_bench_path, "fastchat", "llm_judge")
# Skip if result exists
... | null |
35,712 | from typing import OrderedDict
import signal
import os
import json
import subprocess
import argparse
import time
import requests
import re
import coolname
MAX_CONTEXT = 4096
def run_vicuna_bench(mt_bench_path, model_name):
working_dir = os.path.join(mt_bench_path, "fastchat", "llm_judge")
# Skip if result exi... | null |
35,713 | from typing import OrderedDict
import signal
import os
import json
import subprocess
import argparse
import time
import requests
import re
import coolname
def create_alpaca_eval_config(alpacaeval_path, model_name):
config_dir = os.path.join(alpacaeval_path, "src", "alpaca_eval", "models_configs", model_name.lower()... | null |
35,714 | from typing import OrderedDict
import signal
import os
import json
import subprocess
import argparse
import time
import requests
import re
import coolname
def wait_for_server(url):
while True:
try:
response = requests.get(url)
if response.status_code in [200, 404]:
b... | null |
35,715 | import argparse
import os
import orjson
from glob import glob
def convert_to_evalplus(results_path: str, output_path: str):
os.makedirs(output_path, exist_ok=True)
for filename in glob(os.path.join(results_path, "*.json")):
# read eval results
with open(filename, "rb") as f:
data =... | null |
35,716 | import re
import ast
from ochat.evaluation.grading.math_grader import grade_answer
def zs_agieval_match_answer(task_data, response):
# AGIEval match first capital letter, following original paper implementation
# https://github.com/microsoft/AGIEval/blob/main/src/post_process.py
letter_set = {"A", "B", "C... | null |
35,717 | import re
import ast
from ochat.evaluation.grading.math_grader import grade_answer
def zs_bbh_mc_orca_truthfulqa_orca_match_answer(task_data, response):
# For BBH & TruthfulQA, match first option letter
for c in response:
if c in task_data["options"]:
return True, c
return False, "" | null |
35,718 | import re
import ast
from ochat.evaluation.grading.math_grader import grade_answer
def grade_answer(given_answer: str, ground_truth: str) -> bool:
"""
The answer will be considered correct if:
(a) it normalizes to the same string as the ground truth answer
OR
(b) sympy can simplify the difference b... | null |
35,719 | import re
import ast
from ochat.evaluation.grading.math_grader import grade_answer
def fs_cothub_bbh_match_answer(task_data, response):
# CoT hub match answer for BBH
# https://github.com/FranxYao/chain-of-thought-hub/blob/main/BBH/run_bbh_gpt_3.5_turbo.py
ans_line = response.split('answer is ')
# Ex... | null |
35,720 | import re
import ast
from ochat.evaluation.grading.math_grader import grade_answer
def fs_cothub_gsm8k_match_answer(task_data, response):
# CoT hub match answer for GSM8k, match last numeric value
# https://github.com/FranxYao/chain-of-thought-hub/blob/main/gsm8k/gpt3.5turbo_gsm8k_complex.ipynb
pattern = ... | null |
35,721 | import re
import ast
from ochat.evaluation.grading.math_grader import grade_answer
def fs_cothub_mmlu_match_answer(task_data, response):
ans_line = response.split('answer is')
# Expect to see 'answer is'. If not return C
if len(ans_line) == 1:
return False, "(C)"
else:
ans = ans_line[-... | null |
35,722 | import re
import ast
from ochat.evaluation.grading.math_grader import grade_answer
def coding_humaneval_match_answer(task_data, response):
# Matching utilities
def _function_exists(code, func_name):
tree = ast.parse(code)
for node in ast.walk(tree):
if isinstance(node, ast.FunctionD... | null |
35,723 | import argparse
import transformers
import torch
def add_tokens_to_embedding(added_special_tokens, embedding):
def hf_add_tokens(model_path, output_dir, added_special_tokens):
tokenizer = transformers.AutoTokenizer.from_pretrained(model_path)
model = transformers.AutoModelForCausalLM.from_pretrained(model_path... | null |
35,724 | import argparse
import transformers
import torch
def modify_eos_embeddings(model_path, output_dir):
tokenizer = transformers.AutoTokenizer.from_pretrained(model_path)
model = transformers.AutoModelForCausalLM.from_pretrained(model_path, low_cpu_mem_usage=True, torch_dtype=torch.bfloat16)
eos_token_id = to... | null |
35,725 | import copy
import logging
from dataclasses import dataclass, field
from typing import Dict, Optional, Sequence
import torch
import transformers
import utils
from torch.utils.data import Dataset
from transformers import Trainer
IGNORE_INDEX = -100
def _tokenize_fn(strings: Sequence[str], tokenizer: transformers.PreTrai... | Preprocess the data by tokenizing. |
35,726 | import copy
import logging
from dataclasses import dataclass, field
from typing import Dict, Optional, Sequence
import torch
import transformers
import utils
from torch.utils.data import Dataset
from transformers import Trainer
DEFAULT_PAD_TOKEN = "[PAD]"
DEFAULT_EOS_TOKEN = "</s>"
DEFAULT_BOS_TOKEN = "<s>"
DEFAULT_UNK... | null |
35,727 | from typing import Optional
from dataclasses import dataclass
import argparse
import json
import os
import random
import numpy as np
import transformers
from transformers.trainer_pt_utils import LabelSmoother
from ray.util.multiprocessing import Pool
def generate_split(conversations: list, tokenizer: transformers.AutoT... | null |
35,728 | from typing import Optional, Tuple
import torch
import torch.utils.checkpoint
import torch.nn.functional as F
from torch import nn
from transformers.activations import ACT2FN
from transformers.modeling_outputs import CausalLMOutputWithPast
from transformers.modeling_utils import PreTrainedModel
from transformers.utils ... | null |
35,729 | from typing import Optional, Tuple
import torch
import torch.utils.checkpoint
import torch.nn.functional as F
from torch import nn
from transformers.activations import ACT2FN
from transformers.modeling_outputs import CausalLMOutputWithPast
from transformers.modeling_utils import PreTrainedModel
from transformers.utils ... | null |
35,730 | from typing import Optional, Tuple
import torch
import torch.utils.checkpoint
import torch.nn.functional as F
from torch import nn
from transformers.activations import ACT2FN
from transformers.modeling_outputs import CausalLMOutputWithPast
from transformers.modeling_utils import PreTrainedModel
from transformers.utils ... | null |
35,731 | from typing import Optional, Tuple
import torch
import torch.utils.checkpoint
from torch import nn
from transformers.activations import ACT2FN
from transformers.modeling_outputs import CausalLMOutputWithPast
from transformers.modeling_utils import PreTrainedModel
from transformers.utils import logging
from transformers... | null |
35,732 | from typing import Optional, Tuple
import torch
import torch.utils.checkpoint
from torch import nn
from transformers.activations import ACT2FN
from transformers.modeling_outputs import CausalLMOutputWithPast
from transformers.modeling_utils import PreTrainedModel
from transformers.utils import logging
from transformers... | null |
35,733 | from typing import Optional, Tuple
import torch
import torch.utils.checkpoint
from torch import nn
from transformers.activations import ACT2FN
from transformers.modeling_outputs import CausalLMOutputWithPast
from transformers.modeling_utils import PreTrainedModel
from transformers.utils import logging
from transformers... | null |
35,734 | from typing import Optional, Tuple
import torch
import torch.utils.checkpoint
from torch import nn
from transformers.activations import ACT2FN
from transformers.modeling_outputs import CausalLMOutputWithPast
from transformers.modeling_utils import PreTrainedModel
from transformers.utils import logging
from transformers... | null |
35,735 | from typing import Optional, Tuple
import torch
import torch.utils.checkpoint
from torch import nn
from transformers.activations import ACT2FN
from transformers.modeling_outputs import CausalLMOutputWithPast
from transformers.modeling_utils import PreTrainedModel
from transformers.utils import logging
from transformers... | null |
35,736 | from typing import Optional, Tuple
import torch
import torch.utils.checkpoint
from torch import nn
from transformers.activations import ACT2FN
from transformers.modeling_outputs import CausalLMOutputWithPast
from transformers.modeling_utils import PreTrainedModel
from transformers.utils import logging
from transformers... | null |
35,737 | from typing import Optional, Tuple
import torch
import torch.utils.checkpoint
from torch import nn
from transformers.activations import ACT2FN
from transformers.modeling_outputs import CausalLMOutputWithPast
from transformers.modeling_utils import PreTrainedModel
from transformers.utils import logging
from transformers... | null |
35,738 | from typing import Optional, Tuple
import torch
import torch.utils.checkpoint
from torch import nn
from transformers.activations import ACT2FN
from transformers.modeling_outputs import CausalLMOutputWithPast
from transformers.modeling_utils import PreTrainedModel
from transformers.utils import logging
from transformers... | null |
35,739 | from os.path import dirname, join, basename, isfile
from tqdm import tqdm
from models import SyncNet_color as SyncNet
from models import Wav2Lip, Wav2Lip_disc_qual
import audio
import torch
from torch import nn
from torch.nn import functional as F
from torch import optim
import torch.backends.cudnn as cudnn
from torch.... | null |
35,740 | from os.path import dirname, join, basename, isfile
from tqdm import tqdm
from models import SyncNet_color as SyncNet
from models import Wav2Lip, Wav2Lip_disc_qual
import audio
import torch
from torch import nn
from torch.nn import functional as F
from torch import optim
import torch.backends.cudnn as cudnn
from torch.... | null |
35,741 | from os.path import dirname, join, basename, isfile
from tqdm import tqdm
from models import SyncNet_color as SyncNet
import audio
import torch
from torch import nn
from torch import optim
import torch.backends.cudnn as cudnn
from torch.utils import data as data_utils
import numpy as np
from glob import glob
import os,... | null |
35,742 | from os.path import dirname, join, basename, isfile
from tqdm import tqdm
from models import SyncNet_color as SyncNet
import audio
import torch
from torch import nn
from torch import optim
import torch.backends.cudnn as cudnn
from torch.utils import data as data_utils
import numpy as np
from glob import glob
import os,... | null |
35,743 | from os import listdir, path
import numpy as np
import scipy, cv2, os, sys, argparse, audio
import json, subprocess, random, string
from tqdm import tqdm
from glob import glob
import torch, face_detection
from models import Wav2Lip
import platform
args = parser.parse_args()
args.img_size = 96
def face_detect(images):
... | null |
35,744 | from os import listdir, path
import numpy as np
import scipy, cv2, os, sys, argparse, audio
import json, subprocess, random, string
from tqdm import tqdm
from glob import glob
import torch, face_detection
from models import Wav2Lip
import platform
device = 'cuda' if torch.cuda.is_available() else 'cpu'
print('Using {} ... | null |
35,745 | import sys
from os import listdir, path
if not path.isfile('face_detection/detection/sfd/s3fd.pth'):
raise FileNotFoundError('Save the s3fd model to face_detection/detection/sfd/s3fd.pth \
before running this script!')
import multiprocessing as mp
from concurrent.futures import ThreadPoolExecutor, as_completed
... | null |
35,746 | import sys
from os import listdir, path
import multiprocessing as mp
from concurrent.futures import ThreadPoolExecutor, as_completed
import numpy as np
import argparse, os, cv2, traceback, subprocess
from tqdm import tqdm
from glob import glob
import audio
from hparams import hparams as hp
import face_detection
args = ... | null |
35,747 | from os.path import dirname, join, basename, isfile
from tqdm import tqdm
from models import SyncNet_color as SyncNet
from models import Wav2Lip as Wav2Lip
import audio
import torch
from torch import nn
from torch import optim
import torch.backends.cudnn as cudnn
from torch.utils import data as data_utils
import numpy ... | null |
35,748 | from os.path import dirname, join, basename, isfile
from tqdm import tqdm
from models import SyncNet_color as SyncNet
from models import Wav2Lip as Wav2Lip
import audio
import torch
from torch import nn
from torch import optim
import torch.backends.cudnn as cudnn
from torch.utils import data as data_utils
import numpy ... | null |
35,749 | from os import listdir, path
import numpy as np
import scipy, cv2, os, sys, argparse
import dlib, json, subprocess
from tqdm import tqdm
from glob import glob
import torch
import audio
import face_detection
from models import Wav2Lip
args = parser.parse_args()
args.img_size = 96
def get_smoothened_boxes(boxes, T):
for... | null |
35,750 | from os import listdir, path
import numpy as np
import scipy, cv2, os, sys, argparse
import dlib, json, subprocess
from tqdm import tqdm
from glob import glob
import torch
import audio
import face_detection
from models import Wav2Lip
args = parser.parse_args()
args.img_size = 96
def datagen(frames, face_det_results, m... | null |
35,751 | from os import listdir, path
import numpy as np
import scipy, cv2, os, sys, argparse
import dlib, json, subprocess
from tqdm import tqdm
from glob import glob
import torch
import audio
import face_detection
from models import Wav2Lip
def increase_frames(frames, l):
## evenly duplicating frames to increase length of v... | null |
35,752 | from os import listdir, path
import numpy as np
import scipy, cv2, os, sys, argparse
import dlib, json, subprocess
from tqdm import tqdm
from glob import glob
import torch
import audio
import face_detection
from models import Wav2Lip
device = 'cuda' if torch.cuda.is_available() else 'cpu'
print('Using {} for inference.... | null |
35,753 | from os import listdir, path
import numpy as np
import scipy, cv2, os, sys, argparse
import dlib, json, subprocess
from tqdm import tqdm
from glob import glob
import torch
import audio
import face_detection
from models import Wav2Lip
args = parser.parse_args()
args.img_size = 96
def get_smoothened_boxes(boxes, T):
for... | null |
35,755 | from os import listdir, path
import numpy as np
import scipy, cv2, os, sys, argparse
import dlib, json, subprocess
from tqdm import tqdm
from glob import glob
import torch
import audio
import face_detection
from models import Wav2Lip
device = 'cuda' if torch.cuda.is_available() else 'cpu'
print('Using {} for inference.... | null |
35,756 | import torch
import numpy
import time, pdb, argparse, subprocess, os, math, glob
import cv2
import python_speech_features
from scipy import signal
from scipy.io import wavfile
from SyncNetModel import *
from shutil import rmtree
def calc_pdist(feat1, feat2, vshift=10):
win_size = vshift*2+1
feat2p = torc... | null |
35,757 | import librosa
import librosa.filters
import numpy as np
from scipy import signal
from scipy.io import wavfile
from hparams import hparams as hp
def load_wav(path, sr):
return librosa.core.load(path, sr=sr)[0] | null |
35,758 | import librosa
import librosa.filters
import numpy as np
from scipy import signal
from scipy.io import wavfile
from hparams import hparams as hp
def save_wav(wav, path, sr):
wav *= 32767 / max(0.01, np.max(np.abs(wav)))
#proposed by @dsmiller
wavfile.write(path, sr, wav.astype(np.int16)) | null |
35,759 | import librosa
import librosa.filters
import numpy as np
from scipy import signal
from scipy.io import wavfile
from hparams import hparams as hp
def save_wavenet_wav(wav, path, sr):
librosa.output.write_wav(path, wav, sr=sr) | null |
35,760 | import librosa
import librosa.filters
import numpy as np
from scipy import signal
from scipy.io import wavfile
from hparams import hparams as hp
def inv_preemphasis(wav, k, inv_preemphasize=True):
if inv_preemphasize:
return signal.lfilter([1], [1, -k], wav)
return wav | null |
35,761 | import librosa
import librosa.filters
import numpy as np
from scipy import signal
from scipy.io import wavfile
from hparams import hparams as hp
def preemphasis(wav, k, preemphasize=True):
if preemphasize:
return signal.lfilter([1, -k], [1], wav)
return wav
def _stft(y):
if hp.use_lws:
retur... | null |
35,762 | import librosa
import librosa.filters
import numpy as np
from scipy import signal
from scipy.io import wavfile
from hparams import hparams as hp
def preemphasis(wav, k, preemphasize=True):
if preemphasize:
return signal.lfilter([1, -k], [1], wav)
return wav
def _stft(y):
if hp.use_lws:
retur... | null |
35,763 | import librosa
import librosa.filters
import numpy as np
from scipy import signal
from scipy.io import wavfile
from hparams import hparams as hp
def num_frames(length, fsize, fshift):
"""Compute number of time frames of spectrogram
"""
pad = (fsize - fshift)
if length % fshift == 0:
M = (length ... | Compute left and right padding |
35,764 | import librosa
import librosa.filters
import numpy as np
from scipy import signal
from scipy.io import wavfile
from hparams import hparams as hp
def librosa_pad_lr(x, fsize, fshift):
return 0, (x.shape[0] // fshift + 1) * fshift - x.shape[0] | null |
35,765 | import librosa
import librosa.filters
import numpy as np
from scipy import signal
from scipy.io import wavfile
from hparams import hparams as hp
def _db_to_amp(x):
return np.power(10.0, (x) * 0.05) | null |
35,766 | import librosa
import librosa.filters
import numpy as np
from scipy import signal
from scipy.io import wavfile
from hparams import hparams as hp
def _denormalize(D):
if hp.allow_clipping_in_normalization:
if hp.symmetric_mels:
return (((np.clip(D, -hp.max_abs_value,
... | null |
35,767 | from __future__ import print_function
import os
import sys
import time
import torch
import math
import numpy as np
import cv2
def _gaussian(
size=3, sigma=0.25, amplitude=1, normalize=False, width=None,
height=None, sigma_horz=None, sigma_vert=None, mean_horz=0.5,
mean_vert=0.5):
# handle so... | null |
35,768 | from __future__ import print_function
import os
import sys
import time
import torch
import math
import numpy as np
import cv2
def transform(point, center, scale, resolution, invert=False):
"""Generate and affine transformation matrix.
Given a set of points, a center, a scale and a targer resolution, the
fun... | Center crops an image or set of heatmaps Arguments: image {numpy.array} -- an rgb image center {numpy.array} -- the center of the object, usually the same as of the bounding box scale {float} -- scale of the face Keyword Arguments: resolution {float} -- the size of the output cropped image (default: {256.0}) Returns: [... |
35,769 | from __future__ import print_function
import os
import sys
import time
import torch
import math
import numpy as np
import cv2
def transform(point, center, scale, resolution, invert=False):
"""Generate and affine transformation matrix.
Given a set of points, a center, a scale and a targer resolution, the
fun... | Obtain (x,y) coordinates given a set of N heatmaps. If the center and the scale is provided the function will return the points also in the original coordinate frame. Arguments: hm {torch.tensor} -- the predicted heatmaps, of shape [B, N, W, H] Keyword Arguments: center {torch.tensor} -- the center of the bounding box ... |
35,770 | from __future__ import print_function
import os
import sys
import time
import torch
import math
import numpy as np
import cv2
def transform(point, center, scale, resolution, invert=False):
"""Generate and affine transformation matrix.
Given a set of points, a center, a scale and a targer resolution, the
fun... | Obtain (x,y) coordinates given a set of N heatmaps. If the centers and the scales is provided the function will return the points also in the original coordinate frame. Arguments: hm {torch.tensor} -- the predicted heatmaps, of shape [B, N, W, H] Keyword Arguments: centers {torch.tensor} -- the centers of the bounding ... |
35,771 | from __future__ import print_function
import os
import sys
import time
import torch
import math
import numpy as np
import cv2
def shuffle_lr(parts, pairs=None):
"""Shuffle the points left-right according to the axis of symmetry
of the object.
Arguments:
parts {torch.tensor} -- a 3D or 4D object cont... | Flip an image or a set of heatmaps left-right Arguments: tensor {numpy.array or torch.tensor} -- [the input image or heatmaps] Keyword Arguments: is_label {bool} -- [denote wherever the input is an image or a set of heatmaps ] (default: {False}) |
35,772 | from __future__ import print_function
import os
import sys
import time
import torch
import math
import numpy as np
import cv2
The provided code snippet includes necessary dependencies for implementing the `appdata_dir` function. Write a Python function `def appdata_dir(appname=None, roaming=False)` to solve the follow... | appdata_dir(appname=None, roaming=False) Get the path to the application directory, where applications are allowed to write user specific files (e.g. configurations). For non-user specific data, consider using common_appdata_dir(). If appname is given, a subdir is appended (and created if necessary). If roaming is True... |
35,773 | import torch
import torch.nn as nn
import torch.nn.functional as F
import math
The provided code snippet includes necessary dependencies for implementing the `conv3x3` function. Write a Python function `def conv3x3(in_planes, out_planes, strd=1, padding=1, bias=False)` to solve the following problem:
3x3 convolution w... | 3x3 convolution with padding |
35,774 | from __future__ import print_function
import os
import sys
import cv2
import random
import datetime
import time
import math
import argparse
import numpy as np
import torch
def IOU(ax1, ay1, ax2, ay2, bx1, by1, bx2, by2):
sa = abs((ax2 - ax1) * (ay2 - ay1))
sb = abs((bx2 - bx1) * (by2 - by1))
x1... | null |
35,775 | from __future__ import print_function
import os
import sys
import cv2
import random
import datetime
import time
import math
import argparse
import numpy as np
import torch
def bboxlog(x1, y1, x2, y2, axc, ayc, aww, ahh):
xc, yc, ww, hh = (x2 + x1) / 2, (y2 + y1) / 2, x2 - x1, y2 - y1
dx, dy = (xc - axc) / aww,... | null |
35,776 | from __future__ import print_function
import os
import sys
import cv2
import random
import datetime
import time
import math
import argparse
import numpy as np
import torch
def bboxloginv(dx, dy, dw, dh, axc, ayc, aww, ahh):
xc, yc = dx * aww + axc, dy * ahh + ayc
ww, hh = math.exp(dw) * aww, math.exp(dh) * ahh... | null |
35,777 | from __future__ import print_function
import os
import sys
import cv2
import random
import datetime
import time
import math
import argparse
import numpy as np
import torch
def nms(dets, thresh):
if 0 == len(dets):
return []
x1, y1, x2, y2, scores = dets[:, 0], dets[:, 1], dets[:, 2], dets[:, 3], dets[:... | null |
35,778 | from __future__ import print_function
import os
import sys
import cv2
import random
import datetime
import time
import math
import argparse
import numpy as np
import torch
The provided code snippet includes necessary dependencies for implementing the `encode` function. Write a Python function `def encode(matched, prio... | Encode the variances from the priorbox layers into the ground truth boxes we have matched (based on jaccard overlap) with the prior boxes. Args: matched: (tensor) Coords of ground truth for each prior in point-form Shape: [num_priors, 4]. priors: (tensor) Prior boxes in center-offset form Shape: [num_priors,4]. varianc... |
35,779 | import torch
import torch.nn.functional as F
import os
import sys
import cv2
import random
import datetime
import math
import argparse
import numpy as np
import scipy.io as sio
import zipfile
from .net_s3fd import s3fd
from .bbox import *
import numpy as np
import torch
def batch_decode(loc, priors, varian... | null |
35,780 | import torch
import torch.nn.functional as F
import os
import sys
import cv2
import random
import datetime
import math
import argparse
import numpy as np
import scipy.io as sio
import zipfile
from .net_s3fd import s3fd
from .bbox import *
def detect(net, img, device):
img = img - np.array([104, 117, 123])
img =... | null |
35,781 | import torch
import torch.nn.functional as F
import os
import sys
import cv2
import random
import datetime
import math
import argparse
import numpy as np
import scipy.io as sio
import zipfile
from .net_s3fd import s3fd
from .bbox import *
def pts_to_bb(pts):
min_x, min_y = np.min(pts, axis=0)
max_x, max_y = np... | null |
35,782 | from glob import glob
import os
def get_image_list(data_root, split):
filelist = []
with open('filelists/{}.txt'.format(split)) as f:
for line in f:
line = line.strip()
if ' ' in line: line = line.split()[0]
filelist.append(os.path.join(data_root, line))
return filelist | null |
35,783 | from glob import glob
import os
hparams = HParams(
num_mels=80, # Number of mel-spectrogram channels and local conditioning dimensionality
# network
rescale=True, # Whether to rescale audio prior to preprocessing
rescaling_max=0.9, # Rescaling value
# Use LWS (https://github.com/Jonathan-LeRoux/lws) for STFT a... | null |
35,784 | import sys
from shutil import rmtree as remove_directory
from timeit import default_timer as timer
from webbrowser import open as open_browser
from subprocess import run as subprocess_run
from time import sleep
from typing import Callable
from threading import Thread
from multiprocessing.pool import Thre... | null |
35,785 | import sys
from shutil import rmtree as remove_directory
from timeit import default_timer as timer
from webbrowser import open as open_browser
from subprocess import run as subprocess_run
from time import sleep
from typing import Callable
from threading import Thread
from multiprocessing.pool import Thre... | null |
35,786 | import sys
from shutil import rmtree as remove_directory
from timeit import default_timer as timer
from webbrowser import open as open_browser
from subprocess import run as subprocess_run
from time import sleep
from typing import Callable
from threading import Thread
from multiprocessing.pool import Thre... | null |
35,787 | import sys
from shutil import rmtree as remove_directory
from timeit import default_timer as timer
from webbrowser import open as open_browser
from subprocess import run as subprocess_run
from time import sleep
from typing import Callable
from threading import Thread
from multiprocessing.pool import Thre... | null |
35,788 | import sys
from shutil import rmtree as remove_directory
from timeit import default_timer as timer
from webbrowser import open as open_browser
from subprocess import run as subprocess_run
from time import sleep
from typing import Callable
from threading import Thread
from multiprocessing.pool import Thre... | null |
35,789 | import sys
from shutil import rmtree as remove_directory
from timeit import default_timer as timer
from webbrowser import open as open_browser
from subprocess import run as subprocess_run
from time import sleep
from typing import Callable
from threading import Thread
from multiprocessing.pool import Thre... | null |
35,790 | import sys
from shutil import rmtree as remove_directory
from timeit import default_timer as timer
from webbrowser import open as open_browser
from subprocess import run as subprocess_run
from time import sleep
from typing import Callable
from threading import Thread
from multiprocessing.pool import Thre... | null |
35,791 | import sys
from shutil import rmtree as remove_directory
from timeit import default_timer as timer
from webbrowser import open as open_browser
from subprocess import run as subprocess_run
from time import sleep
from typing import Callable
from threading import Thread
from multiprocessing.pool import Thre... | null |
35,792 | import sys
from shutil import rmtree as remove_directory
from timeit import default_timer as timer
from webbrowser import open as open_browser
from subprocess import run as subprocess_run
from time import sleep
from typing import Callable
from threading import Thread
from multiprocessing.pool import Thre... | null |
35,793 | import sys
from shutil import rmtree as remove_directory
from timeit import default_timer as timer
from webbrowser import open as open_browser
from subprocess import run as subprocess_run
from time import sleep
from typing import Callable
from threading import Thread
from multiprocessing.pool import Thre... | null |
35,794 | import sys
from shutil import rmtree as remove_directory
from timeit import default_timer as timer
from webbrowser import open as open_browser
from subprocess import run as subprocess_run
from time import sleep
from typing import Callable
from threading import Thread
from multiprocessing.pool import Thre... | null |
35,795 | import sys
from shutil import rmtree as remove_directory
from timeit import default_timer as timer
from webbrowser import open as open_browser
from subprocess import run as subprocess_run
from time import sleep
from typing import Callable
from threading import Thread
from multiprocessing.pool import Thre... | null |
35,796 | import sys
from shutil import rmtree as remove_directory
from timeit import default_timer as timer
from webbrowser import open as open_browser
from subprocess import run as subprocess_run
from time import sleep
from typing import Callable
from threading import Thread
from multiprocessing.pool import Thre... | null |
35,797 | import sys
from shutil import rmtree as remove_directory
from timeit import default_timer as timer
from webbrowser import open as open_browser
from subprocess import run as subprocess_run
from time import sleep
from typing import Callable
from threading import Thread
from multiprocessing.pool import Thre... | null |
35,798 | import sys
from shutil import rmtree as remove_directory
from timeit import default_timer as timer
from webbrowser import open as open_browser
from subprocess import run as subprocess_run
from time import sleep
from typing import Callable
from threading import Thread
from multiprocessing.pool import Thre... | null |
35,799 | import numpy as np
from blankly import trunc
from blankly import Strategy, StrategyState, Interface
from blankly import CoinbasePro
from blankly.indicators import rsi, sma
from sklearn.neural_network import MLPClassifier
from sklearn.datasets import make_classification
from sklearn.preprocessing import MinMaxScaler
fro... | null |
35,800 | import numpy as np
from blankly import trunc
from blankly import Strategy, StrategyState, Interface
from blankly import CoinbasePro
from blankly.indicators import rsi, sma
from sklearn.neural_network import MLPClassifier
from sklearn.datasets import make_classification
from sklearn.preprocessing import MinMaxScaler
fro... | null |
35,801 | import blankly
def price_event(price, symbol, state: blankly.FuturesStrategyState):
state.interface.market_order(symbol, side='buy', position='short', size=1) | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.