r/computervision • u/kevinpl07 • 21d ago
Showcase Weight editing for computer vision tested
Side project from this week. ResNet-50 learned some shortcuts on ImageNet, and I wanted to see if you can remove them by editing the last layer directly instead of retraining. Claude did the edits from the raw weights, about 5,000 weights changed, no gradients.
Two cases that worked really well:
Seat belt: the model says "seat belt" for basically any photo taken inside a car, because it learned car interiors instead of the belt. After the edit, a selfie in a car with no belt went from 98% "seat belt" to under 1%, and a dog actually wearing a seat belt still gets "seat belt" at 99%.
Snorkel: anything underwater got called "snorkel". After the edit, a swimmer with no snorkel went from 100% to under 1%.
Not free though, some real photos break and a proper retraining method (DFR) still does better overall. Second image has the comparison.
Code: https://github.com/kevinpl07/weight-patching
Write-up: https://kevinpl07.github.io/weight-patching/#vision


1
u/Stonemanner 20d ago
Really interesting. Did you do or do you know of an evaluation of how many classes in ImageNet have these high correlation? Could there be a systematic approach to target those classes?
Also, I'm sorry to say, but in the first image the seatbelt of the backseat is clearly visible left of the eye between the front passenger seat and its headrest. :D. So I wouldn't count that as a win for the weight editing ;).
1
u/bfyvfftujijg 20d ago
Is DFR something?
-12
u/Particular_Fruit_968 20d ago
Explain what is meant by "weight editing". We already do this with gradient descent and backprop btw. This is a dumb idea and if i look into it i bet 100% i will find that its tampered results