Dataset map function error : TypeError: Expected list for 'input' argument to 'EagerPyFunc' Op, not Tensor
Okay, it was a very stupid mistake.
As the error message states, an input list is required.
So replacing this part of the code:
tf_string = tf.py_function(serialize_one_image, img, tf.string)

to this
tf_string = tf.py_function(serialize_one_image, [img], tf.string)

i.e. wrapping the imgobject into a list solved the problem.
Now it works as expected.
Thanks for reading anyways.