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

23 Upvotes

7 comments sorted by

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 ;).

2

u/kevinpl07 20d ago

Spurious ImageNet was made for this question!

Fair point haha

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

7

u/kevinpl07 20d ago

I quoted the original paper that “introduced” it, maybe read it before attacking me

8

u/HasFiveVowels 20d ago

Wow. Way to proclaim your ignorance in the same breath that you use it to accuse someone of academic dishonesty. Weight editing is where an LLM manually adjusts the weights