r/computervision • • 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).

153 Upvotes

9 comments sorted by

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/Bulky_Specialist5739 3h ago

It's optimized from multiple angles, directions and poses at once: the model is draped in "cloth", then the pattern is changed until there is acceptably low perceptual difference from background for all perspectives. I used PyTorch3D and one of those spherical photos,

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.

1

u/Bulky_Specialist5739 2h ago

Good question, and that kind of setup would answer a different one. The 100 × 1000-image version is a black-box search: every candidate costs a full detector training, you only ever compare 100 points of pattern space, and the run-to-run noise of training a detector is probably larger than the differences between camos. Here the renderer is differentiable, so I get a gradient for every texel of the cloth from a single forward pass.

There is a second model trying to find him: the disruptive pattern was optimised with Faster R-CNN in the loss, and it transferred to RetinaNet and FCOS, which never took part (8–14 % detection at 30 m).

The hand-crafted part is the model of human vision, because the observer I care about is a person, and detectors don't see like we do: the pattern that fools them most is easier for a human to spot up close.

What your setup measures is a detector that's been trained on my uniform. That's a real threat model, but any fixed pattern eventually becomes a signature once the adversary has seen enough of it. An alternating loop (generator vs. a detector being fine-tuned against it) would be the interesting follow-up, more of an arms race than a single answer.

1

u/WhatALoserUserLMAO 2h ago

Personally I doubt the camo generator could ever beat the person detector because the pattern is imperfect. One pattern for many backgrounds could never make the person completely disappear. Maybe you could try handicapping the detector really badly idk. There needs to be some way of preventing the detector from just looking for the person's outline which camo cannot fully hide.

2

u/Bulky_Specialist5739 2h ago

Yeah I doubt that as well. The whole exercise was meant to help me understand limitations such as this out of curiosity. I'd spend a lot more time on this if I were the one in "production".

2

u/WhatALoserUserLMAO 2h ago

Hey I actually missed the part in your post where you explain there actually is a person detector used. I'm surprised at how well the camo hides from the detector. Was the 30m distance how you got around the easy detection problem? How big does the person look in the image at that distance? Very cool project.

13

u/Imaginary_Belt4976 19h ago

This is so cool! Thank you for sharing!