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
git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git | |
cd nv-codec-headers | |
vi Makefile # change the first line to PREFIX = ${CONDA_PREFIX} | |
make install | |
cd .. | |
git clone https://git.ffmpeg.org/ffmpeg.git | |
cd ffmpeg | |
git checkout n4.2.2 | |
conda install nasm |
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
# flake8: noqa: D100 D101 D102 D105 T201 | |
from dataclasses import dataclass, field | |
@dataclass | |
class BaseConfig: | |
@property | |
def envvar_prefix(self) -> str: | |
return "MLCONFIG_" |
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
# Run multiple commands in a tmux session | |
script_dir=$(dirname "$(realpath -s "$0")") | |
if [[ $# -ne 1 ]]; then | |
sess=session_name | |
else | |
sess="$1" | |
fi | |
tmux new -d -s "$sess" -c "$script_dir" # Use default directory as this script directory |
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 argparse | |
from rich_argparse import ArgumentDefaultsRichHelpFormatter | |
def get_parser(): | |
parser = argparse.ArgumentParser( | |
description="Example of argparse usage, with default values printed in help.", | |
formatter_class=ArgumentDefaultsRichHelpFormatter, | |
) |
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
from torch import nn | |
def _addindent(s_, numSpaces): | |
s = s_.split("\n") | |
# don't do anything for single-line stuff | |
if len(s) == 1: | |
return s_ | |
first = s.pop(0) | |
s = [(numSpaces * " ") + line for line in s] |
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
#include <sys/ioctl.h> | |
#include <stdio.h> | |
#include <unistd.h> | |
#include <termios.h> | |
enum { | |
KEYSTATE_NONE = 1024, | |
KEYSTATE_ESCAPE, | |
KEYSTATE_CONTROL, | |
KEYSTATE_MOUSE_PROPS |
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
from rich.progress import ( | |
Progress, | |
ProgressColumn, | |
SpinnerColumn, | |
Task, | |
TextColumn, | |
TimeElapsedColumn, | |
) | |
from rich.text import Text |
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 tensorrt as trt | |
import torch | |
import tqdm | |
logger = trt.Logger(trt.Logger.WARNING) | |
runtime = trt.Runtime(logger) | |
with open("vae_encoder_engine.trt", "rb") as f: | |
serialized_engine = f.read() |
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 | |
from pathlib import Path | |
from safetensors.torch import load_file | |
def summarize_tensor(x): | |
if x is None: | |
return "None" | |
x = x.float() | |
return f"({x.min().item():.3f}, {x.mean().item():.3f}, {x.max().item():.3f})" |
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
""" | |
This will make pptx slides containing images. | |
It assumes your images are square shaped. | |
""" | |
from glob import glob | |
from pptx import Presentation | |
from pptx.dml.color import RGBColor | |
from pptx.util import Inches |
NewerOlder