Skip to content

About

Batch-process insect RAW photos: a full-frame mask finds the subject, then crop, exposure and sharpening are written as a Lightroom .xmp that applies on import. For macro and ecology record shots.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

iKun Insect Studio

iKun = Improve · Keep · Unmistakably · Natural

Download — Windows (3 parts) and macOS arm64 (GitHub first) · Netdisk mirror (code 8848) · Manual · Technical report · 中文

iKun Insect Studio, English interface, a batch just finished

A tool that does the boring, repetitive part for you: find the insect, place the crop, set the exposure.

A day out shooting means one record frame per individual. Only a handful are worth a full edit; the other ninety are records — and in macro work the insect is always small in the frame (hand-holding, not enough magnification, it will not let you closer). Uncroped, they are "a bug somewhere in the middle". The hours go into the ninety, not the five.

This app does those two jobs and writes the result as a sidecar .xmp your editor already reads.

Crop and exposure can both be wrong. Nothing here is 100%. The value is not accuracy, it is turning a hundred repetitive edits into a few minutes — you glance at the misses and fix them.

Built against Lightroom and Adobe Camera Raw (ACR) as references. .xmp is Adobe's standard: Lightroom, Camera Raw, Bridge and Photoshop all read the same file.


What it does

  • Crop — a full-frame mask finds the insect, measures a body box and a whole box, and a 105-term model predicts the crop. Hold-out IoU 0.865. Usually usable as-is, sometimes off.
  • Exposure — two p95 brightness numbers (inside the mask / background inside the box) into one straight line; hold-out MAE 0.29 EV (constant baseline 0.41). An estimate: treat it as a start.
  • Sharpening — by aperture, strictly increasing (20 → 65).
  • Learns your framing — point it at a folder of your own finished JPEGs and the crop model refits to your composition. No originals, no XMP: an export already is the crop, so the app measures how much of the frame the insect takes and inverts that into a box. Bring RAW+XMP sidecars instead if you still have the edits.

Writes a sidecar .xmp: the RAW stays as shot, and your white balance, colour and contrast carry over as they are — everything applies on import.

The interface

A finished batch: the queue on the left gives EV, crop width and sharpening per photo; the preview on the right shows mask (red), whole box (orange), body box (blue), crop (green) and head point (white ring); the contact sheet below is the same list, clickable.

Process tab: queue, preview and contact sheet

For the ones it got wrong, drag the green box edges to re-crop, drag the white ring to move the head point, then hit Apply — it writes back to the same .xmp:

Manual crop and head-point edit

Train: refit on your own finished JPEGs About: version, updates, what each module actually uses
Train tab About tab

Quick start (Windows)

  1. Download the release: …zip.001, .002, .003 and join-parts.bat into one folder, run the bat to merge them into a single zip, then unzip. The BiRefNet model is inside the package — no download, no GPU toolkit needed beyond the CUDA build that ships with torch.
  2. Double-click iKunInsectStudio.exe (keep the whole folder together).
  3. Drop a folder or a batch of RAWs, pick a mode, press Start. Then import into your editor — the .xmp is read on import. If the batch is already in Lightroom, click Read Metadata from File once there instead.

Models preload in the background for ~10–20 s; you can queue photos meanwhile.

macOS (Apple silicon, M1 and up): download iKunInsectStudio_macOS_arm64.zip, unzip, drag the .app into Applications. On first launch, if macOS says it cannot verify the developer, right-click the icon and choose Open, or run xattr -dr com.apple.quarantine /Applications/iKunInsectStudio.app once. The bundle is unsigned; that only clears the quarantine flag. Intel Macs will not run it — PyTorch no longer ships Intel macOS binaries.

Pick the mask tier by free VRAM, or it will crawl

The desktop takes 1.2–2 GB of VRAM before the app gets any. Choosing a tier that does not fit does not raise an error — Windows silently pages it through system memory and each photo goes from 0.8 s to over 3 s, with the fan pinned.

Free VRAM Tier Per photo
≥ 2.6 GB 768 0.77 s
≥ 1.8 GB 512 ← 4 GB cards (GTX 1650 / RTX 3050 laptop) 0.50 s
≥ 1.2 GB 384 0.39 s

Check Task Manager → Performance → GPU → Dedicated GPU memory: if it sits near full, drop one tier. Details in the manual.

How it works, in one paragraph

Each photo is segmented once at 768² with BiRefNet. The mask gives two boxes (body via morphological opening, whole via bounding box). A self-trained ResNet50 turns a 256² crop of the body box into a 64×64 heat map, and soft-argmax turns it into a head point. Those numbers — 13 of them — become 105 terms that predict the crop centre and width; two brightness percentiles become the exposure; the aperture looks up the sharpening. Nothing else is estimated.

Report

docs/report.md — every scheme that was tried, why it was rejected, and a full teardown of the one that survived. English.

Numbers

Module Metric
Crop hold-out IoU median 0.865; 80-photo blind test 0.902
Exposure hold-out MAE 0.29 EV (constant baseline 0.41)
Head point median error 0.12 × core width
White balance a constant, MAE 163 K — the best this approach reaches

Metrics are hold-out: the model never sees the folders it is scored on.

Repository layout

app/        engine (mask, crop, exposure, sharpening, XMP)
ui/         desktop UI (PySide6)
skill/      algorithm package: scripts + method notes + reference docs
docs/       bilingual manual + analysis reports
figures/    zh/ and en/ versions of every figure

Model weights (head_kp_v2.pth, 95 MB) and the Windows build live in Releases, not in git.

Build from source

python -m venv .venv && .venv/Scripts/activate
pip install -r requirements.txt
python run.py                 # dev run
python build.py               # PyInstaller one-folder build

License

MIT — see LICENSE.

© 2026 Zheng Tianyu · Laboratory of Systematics and Evolutionary Entomology, China Agricultural University.

About

Batch-process insect RAW photos: a full-frame mask finds the subject, then crop, exposure and sharpening are written as a Lightroom .xmp that applies on import. For macro and ecology record shots.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages