It is a slightly modified version of the torpedo sight fitted to FAA aircraft like the Swordfish and Albacore.
The torpedo was meant to run straight when dropped. So the pilot had to aim ahead of the target. To do that he needed to estimate its speed. The horizontal bar carried lights. The pilot estimated the speed placed the relevant light on the target and dropped the torpedo at the correct range. Hopefully, if he estimated correctly, the torpedo would run in the direction the aircraft was pointing and torpedo & target would connect.
I think the second photo has the same device, but due to the angle the photo was taken from, and its poor quality, the horizontal bar can't be seen, just the supporting struts.
Here is a diagram of the Swordfish cockpit. The torpedo sight is item 24.
View attachment 772082
It can also be seen here ahead of an Albacore cockpit. Single bar like the Wellington in the first photo.
View attachment 772085View attachment 772086
Until 38 squadron became operational on torpedo carrying Wellingtons in Jan 1942, the only torpedo droppers in the Med were the shore based FAA Swordfish and Albacore squadrons. So the knowledge and equipment was already in theatre for the RAF to adopt.