I think your question has a few answers because you've addressed two different parties: strangers and family members. I'll add a third: acquaintances/colleagues
If it's truly a random stranger making a comment, you don't owe any response. Personally, I think a blank stare is most appropriate. I view discussing a stranger's weight as a boundary violation that should be met with a wall.
With friends/fam, you may choose to respond with the "think you for your concern; it's something I'm working on" or, if you think that will bring on too much food-gawking, you could skip the "it's something I'm working on" part and replace it with, "you have always been so kind [to me]."
The gray area is a casual acquaintance. If you're trying to determine if the person is a friendly, you could try, "oh, why do you say that?" That would tease out whether they're truly concerned, jealous, think you're a freak, etc., and you could respond accordingly. If that's too much work (and it would be for me), I fall back on "Yep, that's just how I am" and change the subject.
Full disclosure: what I say in my head is very different