Skip to content

Instantly share code, notes, and snippets.

@shirayu
shirayu / co2monitor.py
Created September 8, 2023 11:46
UD-CO2S にシリアル接続して結果をJSONで配信するウェブサーバー
#!/usr/bin/env python3
import argparse
import datetime
import json
import re
import threading
from http.server import BaseHTTPRequestHandler, HTTPServer
from pathlib import Path
import serial
@shirayu
shirayu / dl.py
Last active August 31, 2023 00:44
ReazonSpeech Dataset
#!/usr/bin/env python3
import time
from datasets import load_dataset
while True:
try:
ds = load_dataset("reazon-research/reazonspeech", "all")
except Exception as e:
#!/usr/bin/env python3
from transformers import AutoTokenizer
def main() -> None:
txt: str = "鯯を食べたい"
m1 = "rinna/japanese-gpt-neox-3.6b-instruction-ppo"
@shirayu
shirayu / Linux on WSL2.md
Last active May 27, 2023 06:52
Tips to run on Linux in Windows WSL2
@shirayu
shirayu / TensorRT + Ubuntu 22.04 (on WSL2).md
Last active April 1, 2024 01:16
TensorRT + Ubuntu 22.04 (on WSL2)

TensorRT + Ubuntu 22.04 (on WSL2)

I revolced the following warnings related to libnvinfer.so.7 and libnvinfer_plugin.so.7

W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer.so.7'; dlerror: libnvinfer.so.7: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: xxxxx
W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer_plugin.so.7'; dlerror: libnvinfer_plugin.so.7: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: xxxxx
W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Cannot dlopen some TensorRT libraries. If you would like to use Nvidia GPU with TensorRT, please make sure the missing libraries mentioned above are installed properly.
@shirayu
shirayu / bookmarklet-en.txt
Last active November 2, 2022 03:34
google meetのPIPを呼ぶ
javascript:document.querySelector('button[aria-label="More options"]').click();new MutationObserver((m,o) => { const p = Array.from(document.querySelectorAll("span")).find( (el) => el.textContent === "Open picture-in-picture mode" ); if (p) { p.click(); o.disconnect(); }}).observe(document.getElementsByTagName("body")[0], { childList: true, subtree: true,});
@shirayu
shirayu / NIN2
Last active September 13, 2022 16:04
error: `NIN` should be `INN`, `MIN`, `BIN`, `NINE`
--> ./scripts/convert_ncsnpp_original_checkpoint_to_diffusers.py:49:76
|
49 | new_layer.query.weight.data = old_checkpoint[f"all_modules.{index}.NIN_0.W"].data.T
| ^^^
|
error: `NIN` should be `INN`, `MIN`, `BIN`, `NINE`
--> ./scripts/convert_ncsnpp_original_checkpoint_to_diffusers.py:50:74
|
50 | new_layer.key.weight.data = old_checkpoint[f"all_modules.{index}.NIN_1.W"].data.T
#!/usr/bin/env python3
from pathlib import Path
import torch
from diffusers import StableDiffusionPipeline
from torch.amp.autocast_mode import autocast
def get_max_index(p: Path):
mx = 0
import csv
import fileinput
import sys
w = csv.writer(sys.stdout)
for cols in csv.reader(fileinput.input()):
w.writerow(
[cols[i] for i in [0, 1, 2, 3, 0, 4, 5, 6, 7, 8, 9, 11, 10]]
+ ["*", "*", "*", "*", "*"]
@shirayu
shirayu / variable_example.py
Last active February 28, 2022 13:43
クラス変数とインスタンス変数の違い
#!/usr/bin/env python3
# CF: https://www.python.org/dev/peps/pep-0526/#class-and-instance-variable-annotations
# https://qiita.com/7shi/items/d37493c58a8bb8d7beed
# https://gammasoft.jp/blog/python-built-in-types/
from typing import ClassVar, Dict
class MyClass: