Skip to content

Instantly share code, notes, and snippets.

View Kei-jan's full-sized avatar
🎯
Focusing

Kei-jan Kei-jan

🎯
Focusing
View GitHub Profile
@Kei-jan
Kei-jan / AdaIN.py
Last active February 20, 2023 11:59
AdaIN plugin for any tensor size and origin code backup
'''
AdaIN
url: https://gist.github.com/Kei-jan/2cb4200ca0a5d136ed72c03a929e353c
usage:
normalized_feat = adaptive_instance_normalization(content_feat, style_feat)
content_feat: Tensor[B,C,*,]
style_feat: Tensor[B,C,*]
normalized_feat: Tensor[B,C,*] (equal to content_feat)
@Kei-jan
Kei-jan / Med_type_trans.py
Last active February 23, 2023 08:32
Medical image data type transform.
def type2type(sourcepath:str,savepath:str,sourcetype:str,savetype:str):
'''
See sub-files
sourcepath:
'''
pass
from tqdm import tqdm
import time
for i in tqdm(range(100)):
for j in tqdm(range(100)):
tqdm.write(f'epoch{j}\nwithin{i}')
#tqdm.external_write_mode(print("Epoch: {}",i))
time.sleep(1)
# note : use f string has the better use of tqdm.write method as this could escape from the error happens when wanna print structuralized string with args.
@Kei-jan
Kei-jan / .md
Created June 1, 2024 13:36
Update CUDA

update cuda

  1. get sudo

  2. get linux version

nvidia-smi: highest cuda supportable installed
uname -smr: linux version
cat /etc/os-release: system version
@Kei-jan
Kei-jan / barchart1.py
Created June 8, 2024 12:02
barcharts
import matplotlib.pyplot as plt
import random
import matplotlib
import numpy as np
def generate_random_decimal_list(x):
return [round(random.uniform(0, 1), 4) for _ in range(x)]
#matplotlib.rc('font', family='SimHei', weight='bold')
rsync -avz -e "ssh -p [port]" /path/to/source/ user@ipaddress:/path/to/target/
@Kei-jan
Kei-jan / hfd.sh
Created July 13, 2024 02:58
huggingface download script
#!/bin/bash
# Set the environment variable
HF_ENDPOINT="https://hf-mirror.com"
# Define the maximum number of retries, e.g., retry up to 5 times
MAX_RETRIES=5
RETRIES=0
# Loop until we either succeed or reach the maximum number of retries