3a45ba0f20
Implement a Python script that uses a local vision model (via Ollama) to automatically rename image files to descriptive snake_case names. - Add `rename-wallpapers.py` to handle image processing, resizing with ffmpeg, and querying the Ollama API. - Add `flake.nix` to provide a reproducible development environment including Python, Ollama, ffmpeg, and other necessary dependencies.
46 lines
1.6 KiB
Nix
46 lines
1.6 KiB
Nix
{
|
|
description = "Wallpaper renamer: auto-rename images to descriptive snake_case names using a local vision model (Ollama + llava).";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
};
|
|
|
|
outputs = { self, nixpkgs, flake-utils }:
|
|
flake-utils.lib.eachDefaultSystem (system:
|
|
let
|
|
pkgs = import nixpkgs { inherit system; };
|
|
|
|
# The rename command. It starts an Ollama server (if needed) and pulls the
|
|
# vision model on first run, so everything lives inside this shell.
|
|
rename-wallpapers = pkgs.writeScriptBin "rename-wallpapers"
|
|
(builtins.readFile ./rename-wallpapers.py);
|
|
in
|
|
{
|
|
packages.default = rename-wallpapers;
|
|
|
|
devShells.default = pkgs.mkShell {
|
|
name = "wallpaper-renamer";
|
|
packages = [
|
|
pkgs.ollama
|
|
pkgs.python3
|
|
pkgs.curl
|
|
pkgs.ffmpeg
|
|
pkgs.fzf
|
|
pkgs.chafa
|
|
rename-wallpapers
|
|
];
|
|
|
|
shellHook = ''
|
|
echo "wallpaper-renamer shell ready."
|
|
echo "Usage examples:"
|
|
echo " rename-wallpapers # rename all images in this dir"
|
|
echo " rename-wallpapers --pick # interactively choose with fzf"
|
|
echo " rename-wallpapers --dir ~/Pics # scan another directory"
|
|
echo " rename-wallpapers --dry-run *.jpg # preview without renaming"
|
|
echo "Model is pulled on first run (one-time download)."
|
|
'';
|
|
};
|
|
});
|
|
}
|