Complete guide to setting up and using AI-powered image categorization with Ollama.
- Overview
- How It Works
- Setting Up Ollama
- Choosing a Vision Model
- Usage Examples
- Auto-Detection Categories
- Custom Categories
- Performance Tuning
- Troubleshooting
- Privacy & Security
The sort command uses AI vision models running locally via Ollama to analyze and categorize images. This is completely local and private - no images are sent to external servers.
Key benefits:
- Privacy: All processing happens on your machine
- No API costs: Run unlimited images for free
- Offline capable: Works without internet after model download
- Customizable: Choose models and categories
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Image │────▶│ Ollama │────▶│ Category │
│ (base64) │ │ Vision │ │ Output │
└─────────────┘ │ Model │ └─────────────┘
└─────────────┘
│
▼
┌─────────────┐
│ "A mountain │
│ landscape │
│ at sunset" │
└─────────────┘
│
▼
┌─────────────┐
│ Keyword │
│ Matching │──▶ Category: "mountains"
│ (mountain) │
└─────────────┘
- Image is converted to base64
- Sent to local Ollama API with prompt "Describe this image"
- Vision model returns description
- Keywords extracted to determine category
- Image moved to category folder
# Linux/macOS (official installer)
curl -fsSL https://ollama.ai/install.sh | sh
# Or via package managers:
# macOS (Homebrew)
brew install ollama
# Arch Linux
yay -S ollama
# NixOS
nix-env -iA nixpkgs.ollama# Start the Ollama service
ollama serve
# Or run in background
ollama serve &
# Check if running
curl http://localhost:11434/api/tags# Default model (recommended for most users)
ollama pull moondream:1.8b
# Alternative models (see comparison below)
ollama pull llava:7b
ollama pull llava:13b
ollama pull llama3.2-vision:11b| Model | Size | Speed | Accuracy | VRAM | Best For |
|---|---|---|---|---|---|
moondream:1.8b |
1.7GB | Fast | Good | 4GB | Default, low-end hardware |
llava:7b |
4.5GB | Medium | Better | 8GB | Balanced performance |
llava:13b |
8GB | Slow | Best | 16GB | Maximum accuracy |
llama3.2-vision:11b |
7GB | Medium | Excellent | 12GB | Latest tech |
Low-end hardware (4-8GB RAM, no GPU):
ollama pull moondream:1.8b
imtools sort --model moondream:1.8b --workers 1Mid-range (16GB RAM, RTX 3060+):
ollama pull llava:7b
imtools sort --model llava:7b --workers 4High-end (32GB RAM, RTX 4080+):
ollama pull llava:13b
imtools sort --model llava:13b --workers 8cd ~/wallpapers
# Preview what would happen
imtools sort --dry-run
# Actually sort images
imtools sort# Sort images into a separate "sorted" folder
imtools sort --output ./sorted-wallpapers# Only sort into these specific categories
imtools sort --categories "nature,anime,abstract,city,space,gaming"# Use more accurate (but slower) model
imtools sort --model llava:13b# Faster (more parallel workers)
imtools sort --workers 8 --cooldown 200
# Slower but gentler on system
imtools sort --workers 1 --cooldown 5000# Download some wallpapers first
imtools download --query "aesthetic landscape" --limit 50
# Sort them with AI
cd wallpapers
imtools sort \
--categories "mountains,ocean,forest,sunset,city,abstract" \
--model llava:7b \
--workers 4 \
--cooldown 1000When you don't specify --categories, imtools automatically detects from 50+ categories:
| Category | Keywords Detected |
|---|---|
mountains |
mountain, peak, cliff, canyon, volcano |
forest |
forest, woods, jungle, trees |
ocean |
ocean, sea, waves, underwater, coral |
beach |
beach, coast, shore, tropical, island |
lake |
lake, pond |
river |
river, stream |
waterfall |
waterfall, cascade |
sunset |
sunset, dusk, golden hour |
sunrise |
sunrise, dawn |
flowers |
flower, bloom, blossom, rose, garden |
winter |
snow, ice, frozen, glacier, blizzard |
desert |
desert, dune, sand, oasis |
sky |
sky, clouds, horizon |
| Category | Keywords Detected |
|---|---|
space |
galaxy, nebula, planet, cosmos, astronaut, satellite |
scifi |
robot, android, cyborg, futuristic, alien, laser |
cyberpunk |
cyberpunk, neon lights, hologram, dystopia |
| Category | Keywords Detected |
|---|---|
anime |
anime, manga, waifu, chibi, kawaii |
fantasy |
dragon, wizard, elf, unicorn, castle, magical |
abstract |
fractal, geometric, spiral, kaleidoscope, pattern |
minimalist |
minimalist, minimal, simple, clean |
retro |
retro, vintage, nostalgic |
| Category | Keywords Detected |
|---|---|
city |
skyline, skyscraper, downtown, cityscape, urban |
street |
street, alley, road |
architecture |
cathedral, church, temple, palace, bridge, monument |
| Category | Keywords Detected |
|---|---|
animals |
specific animals (wolf, eagle, etc.) or generic "animal" |
vehicles |
car, motorcycle, plane, ship, train |
horror |
skull, zombie, vampire, ghost, haunted |
gaming |
gaming, game, video game, controller |
tech |
circuit, computer, programming, code, matrix |
music |
guitar, piano, violin, concert |
portrait |
woman, man, person, face, character |
night |
night, midnight, starry, moonlit |
neon |
neon, glowing, luminous |
dark |
dark, moody, gloomy, shadow |
colorful |
colorful, rainbow, vibrant |
Images that don't match any category go to uncategorized/.
imtools sort --categories "nature,anime,abstract"The AI will try to match descriptions to your categories.
Broad categories (easier to match):
--categories "nature,art,urban,space"Specific categories (more precise):
--categories "mountains,beach,sunset,anime,cyberpunk,minimalist"- Use lowercase - matching is case-insensitive
- Be specific - "forest" is better than "green"
- Match keywords - categories should match words the AI might say
- Include fallback - consider adding "misc" or "other"
Controls parallel image processing:
--workers 1 # Sequential, lowest resource usage
--workers 4 # Default, good balance
--workers 8 # Faster, needs more VRAM
--workers 16 # Maximum, high-end systems onlyDelay between batches (in milliseconds):
--cooldown 500 # Fast, may overwhelm slower systems
--cooldown 2000 # Default, balanced
--cooldown 5000 # Gentle, for background processing| Workers | Approximate VRAM Usage |
|---|---|
| 1 | Base model size |
| 2-4 | +1-2GB |
| 8 | +3-4GB |
| 16 | +6-8GB |
Background processing (laptop):
imtools sort --workers 1 --cooldown 5000 --model moondream:1.8bActive processing (desktop):
imtools sort --workers 4 --cooldown 1000 --model llava:7bBatch processing (server):
imtools sort --workers 8 --cooldown 200 --model llava:13bError: Ollama is not available at http://localhost:11434
Solutions:
- Start Ollama:
ollama serve - Check if running:
curl http://localhost:11434/api/tags - Check port: ensure nothing else uses 11434
Error analyzing image
Solution: Pull the model first:
ollama pull moondream:1.8b- Use smaller model:
--model moondream:1.8b - Reduce workers:
--workers 1 - Increase cooldown:
--cooldown 5000 - Check system resources:
htopornvidia-smi
The AI couldn't match the description to any category.
Solutions:
- Use
--dry-runto see AI descriptions - Add more categories that match the descriptions
- Use broader category names
- Try a more accurate model
CUDA out of memory
Solutions:
- Use smaller model
- Reduce workers:
--workers 1 - Close other GPU applications
- Use CPU-only mode (slower)
- All images are processed locally
- Image data never leaves your machine
- No telemetry or analytics
- No internet required after model download
The only network activity is:
- Initial model download from Ollama
- Local HTTP to
localhost:11434
# Check Ollama is only listening locally
netstat -tlnp | grep 11434
# Should show 127.0.0.1:11434
# Monitor network during sorting
# (should show no external connections)For maximum security:
- Download model on connected system
- Copy model files to air-gapped system
- Run Ollama and imtools offline
- Command Reference - All sort options
- Architecture - How the AI integration works
- Packaging - Include Ollama as dependency