View semantic_search_with_gzip.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gzip | |
def gzip_search(query: str, candidate_chunks: list[str], top_k: int=1): | |
""" | |
文字列ベースで類似したテキストチャンクを推定するアルゴリズム. | |
`query`, `chunk`, および`query + " " + chunk`をそれぞれgzipで圧縮し、編集距離のようなものをベースに評価する. | |
Parameters: | |
query (str): 検索クエリとして使用する文字列. | |
top_k (int, optional): 返される類似チャンクの上位k個を指定する (default: 1). |
View string_match.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Author: Kyle Kastner | |
# BSD 3-Clause | |
# Thanks to jakevdp for the nice blog post on FFT | |
# https://jakevdp.github.io/blog/2013/08/28/understanding-the-fft/ | |
# Summary | |
# http://www.arazim-project.com/sites/default/files/public/lesson_sums/1fft.pdf | |
# Details on hartley and many xforms | |
# https://caxapa.ru/thumbs/455725/algorithms.pdf | |
# pg 332 http://sep.stanford.edu/data/media/public/oldreports/sep38/38_29.pdf |
View find_noise.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
import k_diffusion as K | |
from PIL import Image | |
from torch import autocast | |
from einops import rearrange, repeat | |
def pil_img_to_latent(model, img, batch_size=1, device='cuda', half=True): | |
init_image = pil_img_to_torch(img, half=half).to(device) | |
init_image = repeat(init_image, '1 ... -> b ...', b=batch_size) |
View adamw_finetune.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import torch | |
from torch import optim | |
class AdamWFinetune(optim.Optimizer): | |
r"""Implements AdamW algorithm with optional weight decay toward the starting value, to | |
prevent overfitting to the new dataset during fine-tuning. | |
The original Adam algorithm was proposed in `Adam: A Method for Stochastic Optimization`_. |
View typical_top_k_top_p.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def typical_top_k_filtering(logits, top_k=0, top_p=0.0, temperature=1.0, min_tokens_to_keep=1, filter_value=-1E12): | |
""" Filter a distribution of logits using typicality, with optional top-k and/or nucleus (top-p) filtering | |
Meister et. al. https://arxiv.org/abs/2202.00666 | |
Args: | |
logits: logits distribution shape (..., vocabulary size) | |
top_k >0: keep top k tokens with highest prob (top-k filtering). | |
top_p >0.0: keep the top p tokens which compose cumulative probability mass top_p (nucleus filtering). | |
min_tokens_to_keep >=1: always keep at least this many tokens through the top_p / nucleus sampling | |
""" | |
# https://arxiv.org/abs/2202.00666 |
View bwv101.7.C-minor-transposed.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"seconds_per_quarter": 0.5, | |
"parts_names": [ | |
"Soprano", | |
"Alto", | |
"Tenor", | |
"Bass" | |
], | |
"parts_cumulative_times": [ | |
[ |
View batch_ar_example.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
# make a minibatch of time, batch, features | |
# time length 7 | |
# batch size 2 | |
# feature dimension 4: | |
# 1:4, 10:14, 20:24, 30:34, etc for first minibatch element | |
# 5:8, 15:18, etc second minibatch el | |
n_features = 4 | |
n_timesteps = 7 |
View Kiritan singing voice synthesis demo.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View make_audiobook.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
To use: | |
1. install/set-up the google cloud api and dependencies listed on https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/texttospeech/cloud-client | |
2. install pandoc and pypandoc, also tqdm | |
3. create and download a service_account.json ("Service account key") from https://console.cloud.google.com/apis/credentials | |
4. run GOOGLE_APPLICATION_CREDENTIALS=service_account.json python make_audiobook.py book_name.epub | |
""" | |
import re | |
import sys |
View make_audiobook.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
To use: | |
1. install/set-up the google cloud api and dependencies listed on https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/texttospeech/cloud-client | |
2. install pandoc and pypandoc, also tqdm | |
3. create and download a service_account.json ("Service account key") from https://console.cloud.google.com/apis/credentials | |
4. run GOOGLE_APPLICATION_CREDENTIALS=service_account.json python make_audiobook.py book_name.epub | |
""" | |
import re | |
import sys |
NewerOlder