Skip to content

BuggyButLearning/LoRA-Image-Prep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

LoRA Image Prep

AI-powered image preparation tool for LoRA training datasets. Automatically analyzes and crops images to optimal dimensions while preserving important subjects like faces and bodies.

Features

🎯 Smart AI Cropping

  • Analyzes images to identify main subjects (faces, people, objects, animals)
  • Prioritizes important elements (faces > bodies > objects > backgrounds)
  • Suggests optimal crop regions automatically

πŸ“ Optimal Sizes for LoRA Training

  • 1024Γ—1024 - Square (ideal for most training)
  • 768Γ—1024 - Portrait
  • 1024Γ—768 - Landscape

πŸ€– Multiple AI Providers

Provider Default Model Description
Claude claude-opus-4-5-20251101 Anthropic's most intelligent model (Nov 2025)
OpenAI gpt-4.1 1M token context, excellent vision (Apr 2025)
Gemini gemini-2.5-flash Fast and reliable stable release
Ollama Auto-detected Local vision models
Demo N/A Simulated responses for testing

All model fields are editable - you can use any compatible model version.

✨ Additional Features

  • Batch or Sequential Processing - Process all at once or review one-by-one
  • Manual Adjustments - Drag to adjust crop region with live preview
  • Multiple Output Formats - PNG, JPG (with quality control), or keep original
  • Batch Renaming - Rename all exported files with a consistent base name
  • Dark Mode UI - Easy on the eyes during long editing sessions

Quick Start

Prerequisites

  • Node.js 18+ - Download
  • npm (comes with Node.js)

Installation

# 1. Extract the project
unzip lora-project.zip
cd lora-project

# 2. Install dependencies
npm install

# 3. Start the development server
npm run dev

The app will open at http://localhost:3000


AI Provider Setup

Claude (Anthropic)

  1. Get an API key from console.anthropic.com
  2. Open Settings (gear icon) in the app
  3. Select Claude (Anthropic)
  4. Paste your API key
  5. Model defaults to claude-opus-4-5-20251101 (editable)

Alternative models: claude-sonnet-4-5-20250929, claude-haiku-4-5-20251001

OpenAI

  1. Get an API key from platform.openai.com
  2. Open Settings in the app
  3. Select OpenAI
  4. Paste your API key
  5. Model defaults to gpt-4.1 (editable)

Alternative models: gpt-4.1-mini, gpt-4.1-nano, gpt-4o

Google Gemini

  1. Get an API key from Google AI Studio
  2. Open Settings in the app
  3. Select Google Gemini
  4. Paste your API key
  5. Model defaults to gemini-2.5-flash (editable)

Alternative models: gemini-2.5-pro, gemini-2.0-flash

Ollama (Local)

Run AI models locally on your computer.

  1. Install Ollama: ollama.ai

  2. Pull a vision model:

    # Recommended - good balance of speed and quality
    ollama pull llava
    
    # Better quality, slower
    ollama pull llava:13b
    
    # Alternative vision model
    ollama pull bakllava
  3. Start Ollama (if not already running):

    ollama serve
  4. Open Settings in the app

  5. Select Ollama (Local)

  6. Your installed models will be auto-detected in the dropdown

Demo Mode

No setup required! Uses simulated AI responses for testing the interface. Great for:

  • Learning how the app works
  • Testing without API costs
  • Offline development

Usage Guide

Basic Workflow

  1. Prepare: Drop images or click to browse
  2. Configure: Choose processing mode and output format
  3. Process: Click "Start Processing"
  4. Review: Check results, adjust crops if needed
  5. Export: Download all processed images

Processing Modes

Mode Description Best For
Batch Process all images, review after Large batches, confident in AI
One-by-one Approve each before continuing Critical images, learning the tool

Manual Crop Adjustment

In the Editor view:

  • Drag inside the crop box to move it
  • Drag corners to resize (maintains aspect ratio)
  • Use Target Shape buttons to switch between square/portrait/landscape
  • Click Reset to AI to restore the AI's suggestion

Output Formats

Format Quality File Size Best For
PNG Lossless Larger Maximum quality
JPG Adjustable (50-100%) Smaller Storage efficiency
Original Keeps source format Varies Mixed batches

Batch Renaming

In Settings, you can enable "Rename all files" to give all exported images a consistent name:

  1. Check "Rename all files"
  2. Enter a base name (e.g., Anime)
  3. Files will be exported as:
    • Single image: Anime_lora.png
    • Multiple images: Anime_lora_1.png, Anime_lora_2.png, etc.

This is perfect for organizing training datasets with consistent naming conventions.


Status Indicators

Color Status Meaning
🟒 Green Success AI confident, ready to export
🟑 Orange Review AI uncertain, manual check recommended
πŸ”΄ Red Failed AI couldn't identify subject

Building for Production

# Create optimized build
npm run build

# Preview production build
npm run preview

Output will be in the dist folder. You can deploy this to any static hosting.


Deployment (GitHub Pages)

This project is configured to deploy to GitHub Pages at:

https://buggybutlearning.github.io/LoRA-Image-Prep/

Deployment is handled automatically by GitHub Actions whenever you push to the main branch.

One-time setup

  1. Make sure the repo is created on GitHub:
    • https://github.com/BuggyButLearning/LoRA-Image-Prep
  2. In Settings β†’ Pages on GitHub, make sure the source is set to GitHub Actions.

Deploying updates

  1. Make your changes locally

  2. Build and test (optional but recommended):

    npm run build
    npm run preview
  3. Commit and push to main:

    git add .
    git commit -m "Update LoRA Image Prep"
    git push origin main

GitHub Actions will:

  • Install dependencies
  • Build the Vite app
  • Publish the dist folder to GitHub Pages

The live site will update after the workflow finishes.


Troubleshooting

Ollama not connecting?

  • Ensure Ollama is running: ollama serve
  • Check the endpoint (default: http://localhost:11434)
  • Click the refresh button to rescan models
  • Make sure you have at least one vision model installed

Export not working?

  • Make sure images have been processed first (click "Start Processing")
  • Check that you have successful (green) images
  • Some browsers block rapid downloads - try fewer images
  • Check your browser's download folder

AI not detecting subjects well?

  • Try a different AI provider
  • Use the manual crop adjustment
  • Some abstract/artistic images may not have clear subjects
  • Consider using a more powerful model

API errors?

  • Verify your API key is correct
  • Check you have credits/quota remaining
  • Ensure the model name is valid
  • Check your internet connection

File Structure

lora-project/
β”œβ”€β”€ index.html          # Entry HTML
β”œβ”€β”€ package.json        # Dependencies
β”œβ”€β”€ vite.config.js      # Vite configuration
β”œβ”€β”€ README.md           # This file
└── src/
    β”œβ”€β”€ main.jsx        # React entry point
    └── App.jsx         # Main application

Tech Stack

  • React 18 - UI framework
  • Vite - Build tool
  • Canvas API - Image manipulation
  • Fetch API - AI provider communication

License

MIT License - feel free to use for personal or commercial projects.


About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published