I'm going through something similar, where I went completely off track for nearly three weeks. I was down to 185 in late September, then Binged nearly every day for two and a half weeks. I got brave last week and hopped on the scale to face the music and I was up to 191.4. I thought I had gained more than that, so I was happy...and celebrated by eating all weekend
So I'm probably up a total of seven or eight pounds. Which I hate. But this time is different because in the past I would have given up and declared myself a failure. But instead, I got back on plan and am back to exercising and eating better. I wish I hadn't derailed but I have realized that I won't be perfect. My weight may go up a bit, and I may have lazy weeks where I don't exercise as much as I normally do, but I know that this is a marathon not a sprint. Eventually, I will drop back to 185, then 175, then 164. I just have to be patient.
I also kept picturing myself going back to 331 lbs, and I felt so much fear. That fear also helped me get back on plan.
You can get past this. Do your best to forgive yourself and don't dwell on what has already happened because you can't change it.