Is Resnet50 + Encoder layers in your picture the encoder in the code?
If so, the code looks alright.
Ciccio and Pippo contain additional layers, which are not in the figure, but I guess that’s expected.