Johns Hopkins case study

IronClad

Face identification for facility access, from one camera frame to a short list of names, on CPU.

Program
MS in Artificial Intelligence, Johns Hopkins, fall 2026
Domain
Visual search for access control
Stack
Python, PyTorch, facenet-pytorch, FAISS, Flask, Docker
01

The problem

IronClad is the second case study in the AI program I am taking at Johns Hopkins in fall 2026; the first was TechTrack. The scenario is a secure facility that wants to replace a badge check at the door with a camera. One frame of the person's face is matched against a gallery of enrolled employees, and the system hands the guard a short list of likely identities. It has to identify a person from a single frame, hold up when the lighting and the image quality change, scale to a gallery of millions, and let administrators add and remove people without retraining anything.

The access decision is made on the top name, so I score every experiment on whether the right person is at rank 1 first and on whether they are in the top N second. A wrong name waved through is the expensive error. A right person refused costs a retake at the door, and I kept that trade in front of me when I set the thresholds.

02

What I built

I built the retrieval service in Python around a pretrained FaceNet embedding, then the evaluation and enrolment pieces around it.

  • A preprocessing stage with MTCNN face detection and cropping, then an InceptionResnetV1 embedding, all on CPU
  • Three FAISS index wrappers (exact brute force, HNSW, LSH) that serialise to disk, and a search module over Euclidean, cosine, and dot-product measures
  • A Flask API with an enrol endpoint for new or existing identities and an identify endpoint that ranks the gallery for a probe, packaged in Docker with the gallery on a mounted volume
  • A catalog builder that embeds the gallery once at enrolment and caches the vectors, so only the probe is embedded at request time
  • Ranking metrics (hit at N, reciprocal rank, average precision) with identity-level deduplication and bootstrap intervals
03

The design analysis

Both candidate weight sets (casia-webface and vggface2) arrived trained, so the analysis tunes the system around them rather than the network: the preprocessing, the index, the number of names returned, and how many images to enrol per person. The gallery holds 1,000 identities and 2,265 images, one to ten per person with a median of one, and the probe set is 999 images of 999 of those people, with no probe sharing a file with the gallery. I embedded everything once, cached the vectors, and made every experiment a re-read of that cache. That also mirrors the deployed system, where the gallery is embedded at enrolment and only the probe is embedded at the door. Every headline number carries a 95 percent bootstrap interval over probes, and every difference between two settings is a paired bootstrap on the same probes.

  1. Model comparison

    On the pipeline as I received it (the whole frame resized to 160 pixels, ImageNet normalisation), vggface2 found the right person at rank 1 for 50.7 percent of probes and casia-webface for 9.3, a paired gap of 41 points that held under every degradation I applied. Cosine and Euclidean gave the same ranking because the network normalises its output, so the similarity measure was never a decision. The surprise was brightness. Brightening a probe by 25 percent cost vggface2 23.5 points while darkening it by the same amount cost 5.6, and I read that asymmetry as the normalisation clipping bright pixels rather than as a property of faces. Neither model could support an acceptance threshold at this stage: holding simulated impostors to 1 percent admitted 5 percent of genuine employees.

    Three line charts of rank-1 hit rate against blur, resize, and brightness for both models on the starting pipeline, with bootstrap bands. vggface2 sits above casia-webface everywhere and both fall steeply under heavy blur, a 40 pixel resize, and brightening.
    I degraded each probe before embedding and left the gallery clean, which is the situation at the door: enrolment photos are controlled and the camera is not. Blur of one pixel and a resize to 80 cost nothing a bootstrap can see. A resize to 40 and a brightening of 50 percent each take 30 to 40 points off vggface2, and the brightness curve is lopsided, which pointed me at the preprocessing before I trusted any robustness number.
    Show the numbers
    probe conditioncasia-webface hit@1vggface2 hit@1gap (95% interval)
    clean9.350.741.3 (38.0 to 44.7)
    blur sigma 19.250.441.1 (37.8 to 44.5)
    blur sigma 25.944.538.6 (35.5 to 41.6)
    blur sigma 41.411.610.2 (8.1 to 12.1)
    resized to 806.746.339.6 (36.5 to 42.7)
    resized to 401.918.616.7 (14.3 to 19.0)
    resized to 200.70.70.0 (-0.8 to 0.7)
    brightness 0.51.317.816.5 (14.3 to 18.9)
    brightness 0.756.945.038.1 (35.0 to 41.2)
    brightness 1.256.427.120.7 (18.0 to 23.6)
    brightness 1.54.410.66.2 (4.2 to 8.4)
    True accept rate against false accept rate on a log axis for both models on the starting pipeline. At the 1 percent line vggface2 accepts about 5 percent of genuine probes and casia-webface under 1 percent.
    The shipped data has nobody who is not in the gallery, so I simulated intruders by holding out 20 percent of identities in five draws and turning their probes into impostors. The rule is a threshold on the top-1 cosine similarity. On this pipeline the genuine and impostor similarities overlap almost completely, and I could not give either model a threshold worth deploying.
    Show the numbers
    model at target false accept ratethresholdtrue acceptfalse rejectfalse accept
    casia-webface at 1%0.9580.598.60.80
    casia-webface at 0.1%0.9670.299.50.00
    vggface2 at 1%0.8485.493.51.00
    vggface2 at 0.1%0.8951.798.20.00
  2. Face detection as preprocessing

    I put MTCNN in front of the embedding to crop the face with a 20 pixel margin, and then replaced the ImageNet normalisation with the fixed standardisation the weights were trained with, (x minus 127.5) divided by 128. The crop alone added 34.5 points of rank-1 hit rate for vggface2 and 70.9 for casia-webface, and the normalisation added another 8 to 11 on top. Together they took vggface2 from 50.7 to 93.3 percent and casia-webface from 9.3 to 90.9, the brightness penalty disappeared, and the model gap shrank from 41 points to 2.4. Gating the crop on detector confidence bought nothing at 0.95 or 0.99 and cost 3 to 7 points at 0.999, so I log the confidence and treat a frame with no face as a retake instead. The detector costs 25 ms per frame on my CPU against 21 ms for the embedding. The acceptance rule moved from unusable to measurable: at a 1 percent false accept rate the final pipeline admits 69 percent of genuine employees and refuses 31, four fifths of them people the ranking had already identified.

    The same three degradation charts on the final pipeline with the crop and the trained normalisation. Both models sit above 0.9 across the brightness range and only heavy blur and the 40 pixel resize separate them.
    I repeated the whole degradation sweep on the final pipeline before I let the model decision stand, because a choice made on the starting pipeline would be a choice made on the wrong system. Between half and one and a half times the original brightness, hit@1 moves by at most 2.5 points for either model. Where vggface2 earns its keep is heavy blur (29.7 points) and the 40 pixel resize (23.3 points), the conditions a distant or cheap camera produces. Resolution is the one degradation nothing here fixes, so the camera has to guarantee the face spans well over 80 pixels.
    Show the numbers
    probe conditioncasia-webface hit@1vggface2 hit@1gap (95% interval)
    clean90.993.32.4 (1.2 to 3.7)
    blur sigma 189.892.72.9 (1.6 to 4.3)
    blur sigma 283.687.33.7 (1.7 to 5.6)
    blur sigma 411.240.929.7 (26.5 to 32.7)
    resized to 8085.687.82.2 (0.2 to 4.0)
    resized to 4024.647.923.3 (19.9 to 26.7)
    resized to 200.20.80.6 (0.0 to 1.3)
    brightness 0.589.392.43.1 (1.7 to 4.6)
    brightness 0.7590.592.41.9 (0.5 to 3.4)
    brightness 1.2590.592.92.4 (1.0 to 3.9)
    brightness 1.588.091.43.4 (1.7 to 5.1)
    Histogram of MTCNN detection confidence for probes and gallery on a log count axis. Almost every image sits above 0.99 and a handful of gallery images fall between 0.90 and 0.98.
    The detector found a face in every probe and in all but one of the 2,265 gallery images, and 99 percent of probe confidences sit above 0.992, so this is not a fragile stage on these frames. The table shows why the two preprocessing changes compound: the crop puts the face where the network expects it and the normalisation puts the pixel values where it expects them, and each one is worth more when the other is already in place.
    Show the numbers
    modelcropnormalisationhit@1hit@5MRR
    casia-webfacenoneImageNet9.316.313.2
    casia-webfacenonefixed22.735.629.4
    casia-webfaceMTCNNImageNet80.288.984.0
    casia-webfaceMTCNNfixed90.994.092.2
    vggface2noneImageNet50.767.658.3
    vggface2nonefixed82.392.286.7
    vggface2MTCNNImageNet85.291.588.1
    vggface2MTCNNfixed93.395.194.1
  3. Index choice as the gallery grows

    The gallery has 2,265 vectors and the target is millions, so I grew it synthetically. Each new entry is a convex mix of two real embeddings plus a little noise, renormalised, which keeps it near real faces instead of in empty space where it would never compete. I checked that rather than assumed it: a synthetic vector's nearest real neighbour sits at a median cosine of 0.72, against 0.81 for a real image's nearest real neighbour and 0.14 for a random vector. I built brute force, HNSW, and LSH at 2,265, 20,000, 100,000, and 500,000 vectors on one CPU thread and measured build time, size, latency, recall of the exact top 10, and hit rate on the real probes. Brute force stays exact and under half a millisecond at 500,000 but grows linearly. HNSW at efSearch 64 answers in 0.16 ms with 93 percent of the exact top 10 and the same hit@1, with a latency exponent of about 0.2. LSH was slower and less accurate than the alternative with the same memory at every size. I also measured the inverted-file family: IVF-Flat reaches 0.98 recall in under a millisecond but stores full vectors, and IVFPQ compresses to 76 bytes per vector, 76 GB at a billion against 2.3 TB for HNSW, at a cost of 6 points of hit@1 untuned.

    Three charts against gallery size on a log axis: query latency per probe on a log scale, hit@1 on the real probes, and recall@10 against exact search, one line per index. HNSW latency flattens while brute force and LSH rise; LSH at 256 bits falls to 0.7 hit@1 and 0.4 recall at 500,000.
    I read the ratios between indexes from these curves, not the absolute times, because they are single-core numbers on a laptop. The identification rate itself falls from 93.3 to 90.0 percent as 500,000 synthetic identities crowd the gallery with exact search, so about a tenth of the loss at scale comes from the approximate search and nine tenths from the crowding. That is a property of the embedding space, and it is the number to watch as the real gallery grows.
    Show the numbers
    indexquery ms at 500,000recall@10 at 500,000hit@1 at 500,000latency exponentindex GB at one billion
    brute force0.4271.00090.00.872,048
    HNSW M=32, efSearch 160.0720.87689.80.242,320
    HNSW M=32, efSearch 640.1640.92690.20.202,320
    HNSW M=32, efSearch 2560.5760.96290.30.222,320
    LSH 256 bits0.9500.39170.40.9233
    LSH 1024 bits1.8930.63886.30.97132
    LSH 4096 bits4.8640.79689.80.97529
    IVF-Flat nprobe 320.9130.98189.6not fitted2,059
    IVFPQ 64x8 bits, nprobe 320.4250.62584.1not fitted76
  4. How many names to return

    N is the number of candidate identities handed to the guard, and every name past the first is a human comparison. I picked N as the smallest value where one more name adds less than half a point of hit rate. On the shipped gallery that rule gives 2 for vggface2 and 4 for casia-webface; on the 500,000-vector gallery it gives 3 to 4. The ceiling matters more than the slope. 4.6 percent of probes are not in the top 20, and no N recovers them. When I typed the 67 rank-1 misses for vggface2, 15 sat at rank 2 or 3, 6 at rank 4 to 20, and 46 beyond 20, and 59 of the 67 belonged to people enrolled with a single image. I set N to 3, which matches the HNSW choice at 500,000 and so survives the index change.

    Line chart of the share of probes with the true identity in the top N against N from 1 to 20, for both models and three indexes. The curves rise steeply to N=3 and are flat past N=10, with vggface2 at 95.4 percent and casia-webface at 95.0.
    The curves saturate fast. For vggface2 the second name adds 1.1 points and nothing after the fifth adds anything; casia-webface is worth four names, and five under LSH, because the approximate index pushes the right person down more often. Offline, N moves hit@N. Online, it moves the seconds a guard spends per entrant and the queue at the door, and I would read those two numbers together once the system is running.
    Show the numbers
    model and indexN=1N=2N=3N=5N=10N=20chosen N
    casia-webface, brute force90.992.493.094.094.895.04
    casia-webface, HNSW90.992.493.094.094.895.04
    casia-webface, LSH89.191.792.393.894.495.05
    vggface2, brute force93.394.494.895.195.495.42
    vggface2, HNSW93.394.494.895.195.495.42
    vggface2, LSH91.994.294.594.895.195.42
    where the right identity landsvggface2of which single-image identitycasia-webfaceof which single-image identity
    rank 1932570908552
    rank 2 to 315132114
    rank 4 to 20662019
    beyond rank 2046405044
  5. Images per identity

    The gallery holds one to ten images per person, and the question is how many are worth enrolling. I took the 123 identities with at least five images, enrolled each with m images drawn at random (m from 1 to 5, ten draws), kept everyone else in the gallery as a fixed background, and scored only those 123 probes. The second image is the one that matters: it adds 5.3 points for vggface2 and every draw agrees on the sign. The third adds 1.1, and the fourth and fifth add 0.2 each, inside the draw spread. Which single image gets enrolled moves the hit rate by several points on its own, and the medoid of a person's embeddings beats a random pick by 3.8 points. The acceptance rule told a second story. Enrolling everyone's images lifted true accept at a 1 percent false accept rate from 70 to 85 percent for the people with three or more images, but every added image gives an impostor one more chance at a near miss, so the threshold rose from 0.726 to 0.759 and the people still at one image fell from 71 to 63 percent. Enrolment has to be uniform before the threshold is reset.

    Line chart of rank-1 hit rate on the 123 eligible probes against the number of images enrolled per identity, 1 to 5, with error bars over ten random draws. vggface2 climbs from 92 to 98.5 by three images and flattens; casia-webface climbs from 88 to 97.
    I read the identity-level bootstrap here rather than the probe bootstrap, because pooling ten draws of the same probes makes the interval too narrow. The eligible identities are not a soft subset: with one image each they identify at 91.9 percent against 91.2 for everyone else, so the curve should transfer to the rest of the gallery. The extra images of a public figure span years and photographers, which is more variation than a badge office collects in one sitting, so I treat the per-image gain as an upper bound.
    Show the numbers
    images per identity, mcasia-webface hit@1 (sd over draws)identity bootstrapvggface2 hit@1 (sd over draws)identity bootstrap
    187.8 (1.6)83.7 to 91.492.1 (1.5)88.7 to 94.9
    295.0 (1.1)91.7 to 97.897.4 (0.9)95.0 to 99.2
    396.9 (0.9)93.8 to 99.298.5 (0.5)96.3 to 100.0
    497.6 (0.7)94.7 to 99.798.7 (0.4)96.6 to 100.0
    598.0 (0.4)95.3 to 100.098.9 (0.4)96.7 to 100.0
    enrolment (vggface2)gallery vectorsthreshold at 1% false accepttrue accepttrue accept, 3+ imagestrue accept, the restmedian genuine similaritymedian impostor similarity
    m=1, random image1,0000.72670.870.471.00.8050.540
    m=1, medoid image1,0000.72175.383.972.40.8110.539
    m=21,3710.73174.082.771.10.8170.549
    m=31,6240.74172.384.668.10.8210.553
    all images2,2650.75968.885.263.20.8250.561
04

What I found

93.3%
Rank-1 identification on the final pipeline, from 50.7 on the starting one
43pts
Gained by two preprocessing changes, against 2.4 for the model choice
0.16ms
HNSW query at 500,000 vectors, with 93 percent of the exact top 10
+5.3
Points of hit rate from the second enrolled image; the fourth adds 0.2

The preprocessing was the model decision

A crop and the right normalisation gained 43 points of rank-1 identification, and the 41 point model margin that looked decisive on the starting pipeline shrank to 2.4 on the right one. The brightness asymmetry that seemed like a robustness finding was the normalisation clipping bright pixels. A robustness result on the wrong preprocessing is a result about the preprocessing.

A threshold is a property of the whole gallery

Enrolling more images lifted the people who got them from 70 to 85 percent true accept, and pushed the people who did not from 71 down to 63, because the impostor near misses rose with the gallery and the 1 percent threshold rose with them. The overall rate barely moved. Enrolment has to reach everyone before the threshold is reset, and the threshold itself stays provisional until real refused attempts can place it.

The misses a longer list cannot fix are single-image people

59 of the 67 rank-1 misses belong to identities enrolled with one photo, and 40 of the 46 that fall out of the top 20 do too. The fix is a second image at enrolment, not a longer list, and the one degradation nothing in the pipeline fixes is resolution, so the camera has to guarantee well over 80 pixels across the face.

The design, one row per decision

Every decision in the report, the measurement it rests on, the requirement it serves, and the alternative I rejected.

preprocessing
MTCNN crop, fixed standardisation
evidence50.7 to 93.3 percent rank-1 for vggface2; the brightness effect gone
servesidentify from one frame; hold up under lighting
rejectedwhole-frame resize with ImageNet normalisation; confidence-gated crop, no gain
embedding model
vggface2
evidence2.4 points better on clean frames, 23 to 30 under heavy blur and resolution loss
servesidentification under camera variation
rejectedcasia-webface, equal on brightness, weaker on blur and resolution
similarity measure
cosine
evidenceidentical ranking to Euclidean on unit vectors; a bounded scale for the threshold
servesa readable acceptance threshold
rejectedEuclidean, same ranking; Minkowski, nothing to gain on normalised vectors
index
brute force to a million, then HNSW
evidenceexact at 0.43 ms at 500,000; HNSW efSearch 64 at 0.16 ms with 93 percent recall and an exponent of 0.2
servesscale to millions, then a billion
rejectedLSH, slower and less accurate at every size; IVFPQ, 76 GB at a billion but 6 points of hit@1 untuned
identities returned
N = 3
evidencethe half-point rule gives 2 on the shipped gallery and 3 with HNSW at 500,000; the misses N cannot fix are single-image people
servesidentification against guard workload
rejected1, loses 1 to 3 points; 5 or more, nothing beyond the ceiling
images per identity
3, minimum 2
evidencesecond image +5.3 points, third +1.1, fourth within noise; the medoid +3.8 over a random single image
servesidentification; enrolment without retraining
rejected1, 6 to 9 points lower and sensitive to which image; 5 or more, no gain for the storage
acceptance threshold
cosine 0.76, provisional
evidence69 percent true accept at 1 percent false accept, four fifths of refusals people the ranking had right; the threshold rises as the gallery fills
servesrefuse people who are not in the gallery
rejectedany threshold on the starting pipeline; a looser setting bought on simulated impostors
what to monitor
hit@1, share outside top N, no-face rate
evidencedetector confidence tracks the camera and the lighting; per-person hit rate against time since enrolment tracks appearance drift; latency per gallery size
servespost-deployment monitoring
rejectedaccuracy on the enrolment set alone
05

Limits and notes

The scaling is synthetic, and the billion-vector figures are a power law fitted on four points between 2,265 and 500,000 and read three orders of magnitude past the last one, so I treat them as the order of magnitude to plan hardware around and not as a prediction. The open-set numbers come from held-out identities rather than real intruders, and the threshold stays provisional until refused badge-in attempts can place it. I held the MTCNN crop margin at 20 pixels and did not sweep it; the margin is a free parameter of the detector stage, and that sweep is the first thing I would add. The probe and gallery images come from the same source, which hides the camera-to-enrolment shift a real door would have. The timing is one laptop CPU on a single FAISS thread.

Course repositories stay private under the university's rules, so this page summarizes my results and does not link the code.