r/computervision • u/Bulky_Specialist5739 • 20h ago
Showcase I optimized camouflage patterns with gradient descent (interactive demo)
Article: https://virostatiq.com/camouflage-gradient-descent/
Demo: https://virostatiq.com/projects/camouflage/
I grew camouflage patterns for a 3D human figure using gradient descent through a differentiable renderer. I tested them against two observers: a model of human vision, and person detectors. There's a write-up and an interactive three.js demo (links below).
Setup
- Figure: a MakeHuman figure (built with MPFB in headless Blender) in four poses: standing, walking, crouching, kneeling. Only the colours of the shirt and trousers are optimised.
- Scene: one 360° HDRI (Poly Haven, CC0) is both the backdrop and the light source. Lighting uses 9-coefficient spherical-harmonic irradiance, so the cloth is shaded as it would be on that site.
- Rendering: PyTorch3D. The geometry is fixed, so each view is rasterised once and only re-shaded at every step. A run takes about a minute on an RTX 3090 (256 px renders, 512 px texture, 400 steps).
- Held-out test: the panorama is split into six 60° sectors. The optimiser trains on three, and every reported number comes from the other three.
- Background panning: during training the background shifts randomly by up to ±12°, so the pattern can't memorise the strip of panorama that is always behind the chest.
Observer 1: a hand-built visibility loss, computed at several image scales (an image pyramid), comparing the figure with the background right behind it:
- contrast across the silhouette, relative to the background's own edges
- contour coherence
- colour difference
- texture difference, from VGG Gram matrices
Pattern constraints
- A learnable palette of 5 colours, picked from the training views.
- Either crisp patches of 5–10 cm or 1.5 cm "digital" pixels.
- A density penalty that keeps any one colour from forming patches larger than about 11 cm.
- The constrained patterns score within a few per cent of a free texture.
Observer 2: a person detector. COCO-trained Faster R-CNN is added to the loss, using its person confidence on views at 8–30 m. RetinaNet and FCOS are used only for testing transfer.
Results (held-out views; detection rates are the mean over the three detectors)
- At 30 m, the person is detected in 99% of views in the original clothes, 74% in an optimised flat colour, 48% in the patch pattern, and 21% in the pattern trained with the detector.
- Averaged over all distances, adding the detector to the loss lowers detection from 75% to 53%. The two detectors that weren't in the loss are fooled even more: at 30 m, RetinaNet finds him in 8% of views and FCOS in 14%.
- The two observers produce the two strategies biologists describe. The vision model leads to background matching. The detector leads to disruptive colouration: more contrast, plus colours the forest doesn't have (rust, tan, pale mint). The disruptive pattern is easier to spot up close.
- In rubble, every pattern does no better than one well-chosen flat colour. In deserts, the patterns don't carry over between sites: on a desert site never used in training, every trained pattern lost to the original clothes.
- "Adaptive cloth", which re-tunes its 5 colours for each viewer, cuts the far-distance outline score from 0.41 to 0.12 in the forest. It doesn't help up close in direct sun.
Demo: three.js with the optimiser's shading ported to a shader (same SH lighting and tonemapping). The pattern's evolution is recomputed on the GPU from saved snapshots and matches PyTorch to within 0.06/255 mean error. There's also a "Find him" mode.
Limitations: it's a simulation with diffuse light only (no shadows), and there's no human study yet. I compare against related work in the write-up: Owens et al. 2014, GANmouflage, the Bristol camouflage group, and adversarial clothing (AdvCaT and others).
5
u/BustTheCoin 10h ago
This is cool! How do you apply it at multiple angles? If he turns around or you move the camera around ?
2
u/bfyvfftujijg 7h ago
Nifty.
Curious why you hand-crafted the loss instead of having one model try to detect the person while another generates the camos?
Picturing the camo model produces 100 different camo patterns, which you “augment” onto 10 people and 10 background all randomized 10 times to have 100 datasets (one per camo) each with 1000 images. Then you train 100 object detection models. Your best camo is the one which resulted in the worst object detection model.
13
u/Imaginary_Belt4976 19h ago
This is so cool! Thank you for sharing!