How to write code for both input and output which is form of photo

I would recommend using Uplink (more info in the documentation), and checking out this tutorial:

Here, the notebook is Deepnote rather than Google Colab, but the principle is the same.

I hope this helps.