A Vue-based image gallery with AI-powered search using Tesseract OCR + BLIP-2 image captioning.
https://nitinkc.github.io/thinkorama/
- πΈ Paginated image gallery with lightbox viewer
- π AI-powered search (Tesseract OCR + BLIP-2 image captioning)
- π― Filter by category/folder
- πΌοΈ Quick view all thumbnails with navigation
- π¬ Fullscreen screensaver mode with speed controls
- π₯ Fullscreen mode for lightbox images
βΆοΈ Start screensaver from any image- π― Highlight animation when navigating from quick view
- β±οΈ Configurable screensaver intervals (30s to 10m) with progress bar
-
Install Tesseract OCR
# macOS brew install tesseract # Ubuntu/Debian sudo apt-get install tesseract-ocr # Windows # Download from https://github.com/UB-Mannheim/tesseract/wiki
Verify:
tesseract --version -
Create Virtual Environment and Install Dependencies
Each developer should create their own:
# Create virtual environment
python3 -m venv venv
# Activate (macOS/Linux)
source venv/bin/activate
# Activate (Windows)
venv\Scripts\activate
# Install dependencies
pip install -r requirements.txtNote: BLIP-2 model (~990MB) downloads automatically on first run.
-
Generate image list
python3 gen_images_json.py
-
Generate AI-powered search metadata
source venv/bin/activate python gen_images_metadata_ai.pyβ οΈ First run: ~5-10 minutes for 198 images (includes model download) -
Run local server
python -m http.server 8000
Open: http://localhost:8000
-
Add images to
images/folder (organize in subfolders) -
Update image list:
python gen_images_json.py -
Generate metadata (choose one):
Option A: Incremental (recommended for new images)
source venv/bin/activate python gen_images_metadata_ai.py --incremental- β Only processes new images
- β Preserves manual edits in existing metadata
- β Faster for adding a few images
Option B: Full Regeneration
source venv/bin/activate python gen_images_metadata_ai.py- Creates automatic backup (
images-metadata.backup.TIMESTAMP.json) - Regenerates metadata for all images
- Use when you want to reprocess everything
-
Test locally:
python -m http.server 8000
If you have PDF files you want to include in the gallery:
-
Install ImageMagick
# macOS brew install imagemagick # Ubuntu/Debian sudo apt-get install imagemagick # Windows # Download from https://imagemagick.org/script/download.php
-
Convert PDF to JPG images
# Single PDF (creates one image per page) convert -density 300 path/to/document.pdf -quality 90 images/pdfs/document-%d.jpg # Batch convert all PDFs in a folder for pdf in pdfs/*.pdf; do filename=$(basename "$pdf" .pdf) convert -density 300 "$pdf" -quality 90 "images/pdfs/${filename}-%d.jpg" done
Options explained:
-density 300- High resolution (300 DPI)-quality 90- JPG quality (0-100, 90 is good balance)%d- Page number placeholder (creates file-0.jpg, file-1.jpg, etc.)
-
Update image list and generate metadata
python gen_images_json.py source venv/bin/activate python gen_images_metadata_ai.py --incremental
Note: Each PDF page becomes a searchable image with OCR + AI captioning.
# Incremental: Only process new images (preserves manual edits)
python gen_images_metadata_ai.py --incremental
# Full: Regenerate all (creates backup automatically)
python gen_images_metadata_ai.py
# Sample: Test with 10 images
python gen_images_metadata_ai.py --sample 10
# Help
python gen_images_metadata_ai.py --helpIf an image has poor OCR results, regenerate it individually with enhanced preprocessing:
source venv/bin/activate
python gen_single_image_metadata.py path/to/image.jpgThis script:
- Tries 5 different OCR strategies (default, preprocessed, PSM 6, PSM 11, PSM 3)
- Shows all results side-by-side
- Lets you choose whether to update the metadata file
- Useful for debugging or improving specific images
Example:
python gen_single_image_metadata.py mind/Gj5Xi5ZXkAAL2u_.jpg- Static HTML (
index.html) loads Vue 3 and lightGallery from CDNs - No build step - plain JavaScript components
- Client-side search - all filtering happens in the browser
Two-tier AI approach for maximum searchability:
- Tesseract OCR - Extracts actual text visible in images (book titles, quotes, diagrams)
- BLIP-2 Image Captioning - AI-generated descriptions of image content and scenes
Process:
- Run OCR + AI captioning locally on all images (one-time)
- Generate
images-metadata.jsonwith extracted text + captions - Client-side search filters images in real-time
- Commit metadata to repo, zero runtime cost
Searchable by:
- π Extracted OCR text from images
- π€ AI-generated scene descriptions
- π Folder names
- π Filenames
{
"path": "books/book1.jpg",
"text": "books book1 Thinking Fast and Slow Daniel Kahneman a book cover with text",
"ocr": "Thinking Fast and Slow Daniel Kahneman",
"caption": "a book cover with text and a blue background",
"folder": "books",
"filename": "book1.jpg"
}- Pagination - Browse images 12 per page with smart page number display
- Quick View - Click "β Quick View" to see all thumbnails in a modal
- Highlight Animation - When navigating from Quick View, the target image pulses with a blue border for easy identification
When you click an image thumbnail:
- Zoom - Click zoom icon to zoom in/out
- Fullscreen - Click βΆ icon to view in fullscreen mode
- Start Screensaver - Click βΆ icon to start screensaver from that image
- Navigate - Use arrow buttons or swipe (mobile) to browse
Start from header button or from any lightbox image:
- Auto-advance - Images change automatically at set intervals
- Progress Bar - Blue bar at bottom shows countdown to next image
- Speed Controls - Move mouse to show speed panel (top-right)
- Options: 30s, 1m, 2m, 3m, 5m (default), 10m
- Active speed highlighted in blue
- Panel auto-hides after 3 seconds
- Manual Navigation - Use β β arrow keys to browse
- Exit - Press Escape or click anywhere
- Text Search - Find images by OCR text, AI captions, or filenames
- Folder Filter - Dropdown to filter by category (books, management, etc.)
- Clear - X button to reset search and show all images
gen_images_json.py- Scansimages/folder, createsimages.jsongen_images_metadata_ai.py- OCR + BLIP-2 captioning for all imagesgen_single_image_metadata.py- Enhanced OCR for individual images (5 strategies)
thinkorama/
βββ index.html # Main entry point
βββ style.css # All styles
βββ images/ # Image files (organized by folder)
βββ js/
β βββ app.js # Vue app initialization
β βββ gallery.js # Gallery component with pagination
β βββ search.js # Search bar component
β βββ quickview.js # Thumbnail modal
β βββ screensaver.js # Fullscreen slideshow
βββ images.json # Generated: list of image paths
βββ images-metadata.json # Generated: OCR + AI captions
βββ venv/ # Python virtual environment
- Ensure Tesseract is installed:
tesseract --version - On macOS, restart terminal after
brew install
- Activate virtual environment:
source venv/bin/activate - Install dependencies:
pip install -r requirements.txt
- Check browser console for errors
- Ensure
images-metadata.jsonexists - Verify metadata was generated:
python gen_images_metadata_ai.py
- Use
gen_single_image_metadata.pyfor specific images - Tesseract works best with clear, high-contrast text
- Some artistic/low-resolution images may not yield good results
Edit gen_images_metadata_ai.py to add preprocessing:
from PIL import ImageEnhance, ImageFilter
# In extract_text_from_image function:
img = img.convert('L') # Grayscale
img = ImageEnhance.Contrast(img).enhance(2) # Increase contrast
text = pytesseract.image_to_string(img, config='--psm 6')# Larger model (better quality, slower):
processor = BlipProcessor.from_pretrained("Salesforce/blip-image-captioning-large")
model = BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image-captioning-large")Test with fewer images:
python gen_images_metadata_ai.py --sample 10GitHub Pages / Static Hosting:
- Generate metadata locally:
source venv/bin/activate python gen_images_metadata_ai.py - Commit
images.jsonandimages-metadata.json - Push and deploy
Benefits:
- β Zero server-side processing
- β Instant client-side search
- β Works offline after initial load
- β Free hosting
- OCR: ~0.5-1 second per image
- BLIP-2 captioning: ~0.5-1 second per image
- Total: ~1-2 seconds per image
- 198 images: ~5-10 minutes
- β Instant filtering in browser
- β No server required
- β Scales to thousands of images
- Frontend: Vue 3 (CDN), Bootstrap 5, lightGallery
- AI/ML: Tesseract OCR, BLIP-2 (Salesforce)
- Hosting: Static files (GitHub Pages compatible)
- No build tools: Plain JavaScript, no bundler required