Skip to content

Instantly share code, notes, and snippets.

@city96
city96 / ffmpeg.md
Created February 28, 2023 17:35
FFmpeg video to/from image sequence

FFmpeg video to/from image sequence

Placeholders:

  • raw.mp4 - Your input video
  • out.mp4 - Your output video
  • -r 30 - The framerate of your videos.
  • %04d - The format of your image sequence.
  • images - The folder with your image sequence

Video -> Image sequence

@city96
city96 / gimp-openpose-mask.py
Created February 28, 2023 18:29
GIMP Python-Fu script to create masks from OpenPose images.
# GIMP Python-Fu script to create (rough) masks from OpenPose images.
# Not recommended for singe images, mainly useful for animations/batches.
# Requires a uniform black background to work.
# Edit input/output folders, then paste into Filters->Python-Fu->Console.
import gimpcolor
import os
in_dir = r"O:\example\raw" # Input folder
out_dir = r"O:\example\out" # Output folder
grow_size = 48 # Main mask size
@city96
city96 / sd_meta_sorter.py
Created August 2, 2023 23:16
SD-sort-images-by-UI
#
# Sort stable diffusion images by the UI they were generated in.
#
import os
import json
import argparse
from PIL import Image
from tqdm import tqdm
from shutil import copyfile
@city96
city96 / rife_deflicker.py
Created August 5, 2023 15:39
rife_deflicker
#
# Deflicker videos by only grabbing the interpolated frames.
# Helps to smoothe over AI animations, at least somewhat.
# Edit the cmd on line 40 to change the model from whatever the default is.
#
# You'll need this in the same folder https://github.com/nihui/rife-ncnn-vulkan + ffmpeg in path
#
import os
from shutil import copyfile
@city96
city96 / SimpleAnimeSeg.py
Created December 3, 2023 17:26
ComfyUI anime segmentation custom node
#
# Simple custom node to segment anime images using https://github.com/SkyTNT/anime-segmentation
# To install the custom node, copy this file to your `ComfyUI/custom_nodes` folder
# To install the requirements, run `pip install onnxruntime huggingface-hub` inside your VENV
# If using the standalone, navigate to the folder where your .bat file is and run this command:
# .\python_embeded\python.exe -m pip install onnxruntime huggingface-hub
#
import torch
import numpy as np
@city96
city96 / test_hidden_bg.py
Created April 18, 2024 18:01
Test if PNG contains background hidden by alpha channel
# Find images with content hidden by alpha channel
# Ref https://github.com/kohya-ss/sd-scripts/issues/1269
# City96 | 2024
import os
import torch
import torchvision
from tqdm import tqdm
from torch.multiprocessing import Pool
# Path to source image dataset