Skip to content

Instantly share code, notes, and snippets.

View YooSungHyun's full-sized avatar
👻
WARNING : Not pseudo code in this WORLD

YooSungHyun YooSungHyun

👻
WARNING : Not pseudo code in this WORLD
View GitHub Profile
import torch
import torch.nn as nn
import torch.nn.functional as F
def lengths_to_mask(lengths, max_len=None, dtype=None):
"""
Converts a "lengths" tensor to its binary mask representation.
Based on: https://discuss.pytorch.org/t/how-to-generate-variable-length-mask/23397
@sparrc
sparrc / install-ffmpeg.sh
Last active December 3, 2025 18:18
Installs ffmpeg with libaom and libx265 enabled for av1 and hevc encoding (tested on Ubuntu 16.04)
#!/usr/bin/env bash
# Installs ffmpeg from source (HEAD) with libaom and libx265, as well as a few
# other common libraries
# binary will be at ~/bin/ffmpeg
sudo apt update && sudo apt upgrade -y
mkdir -p ~/ffmpeg_sources ~/bin
export PATH="$HOME/bin:$PATH"