Skip to content

Instantly share code, notes, and snippets.

View Jiayi-Pan's full-sized avatar

Jiayi Pan Jiayi-Pan

View GitHub Profile
@Jiayi-Pan
Jiayi-Pan / zombie_kill.sh
Created May 24, 2022 16:49
Kill Zombie Process After Interruptions in Torch Distributed Training
kill $(ps aux | grep SCRIPT.py | grep -v grep | awk '{print $2}')
@Jiayi-Pan
Jiayi-Pan / binary_mask_to_rle.py
Last active September 23, 2023 21:34
Vectorized Binary Mask to RLE Encoding (MSCOCO)
# Given a numpy binary mask, the following function converts it to RLE encoding that MSCOCO defines
# This implementation is highly vectorized and about 100X faster than naive python loop implmentations
def binary_mask_to_rle(binary_mask):
# Flatten the binary mask
flat_mask = binary_mask.ravel(order='F')
# Calculate the differences between consecutive elements in the flattened binary mask
diffs = np.diff(np.concatenate(([0], flat_mask, [0])))
@Jiayi-Pan
Jiayi-Pan / storagehack.ipynb
Created May 17, 2023 02:53
StorageHack.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Jiayi-Pan
Jiayi-Pan / ML_Tips.md
Last active July 28, 2023 12:55
Nice ML Debugging Tools

Interactive Stop Point

from IPython import embed
embed()

Type Ctrl-D to proceed

import lovely_tensors as lt
@Jiayi-Pan
Jiayi-Pan / Clone-Android-AVD.py
Last active December 29, 2023 05:10
Clone/duplicate an existing Android AVD
def clone_avd(src_avd_name, tar_avd_name, android_avd_home):
"""
Clone the source AVD to the target AVD.
Parameters:
- src_avd_name: The name of the source AVD folder.
- tar_avd_name: The name of the target AVD folder.
- android_avd_home: The path to the .android/avd directory.
This function copies the source AVD folder and its .ini file to a new target AVD