This is expected behavior.
Normally TensorFlow can handle shapes with unknown dimensions. It really can’t handle shapes with an unknown number of dimensions.
tf.data.Dataset.from_generator, and tf.py_function get results from python code, those could be anything. You need to specify the shapes for tensorflow. from_generator gives you the option to specify the output_signature. tf.py_function should do the same, ideally someone would fix that. But until someone does, this is how you do it.
For your specific case, this function could help:

  
      

      TensorFlow
  

  
    

tfio.experimental.image.decode_tiff  |  TensorFlow I/O 7

  Decode a TIFF-encoded image to a uint8 tensor.