0

Tensorflow-Lite's Pix2Pix implementation outputs a Uint8List:

Uint8List input;
var output = await Tflite.runPix2PixOnBinary(binary: input, asynch: true);

The result now has be converted to an Image object in order to display it. This is the problem.

It seems like pictures have some kind of header or signature, which is essential for the decodeImage() function of the Image package or similar decode functions (MemoryImage, Image.memory, decodeImageFromList).

This answer offers a solution, unfortunately it is only for 256 different colors (one channel?). TfLite outputs x channels tho...

I am looking for something like the Python Pillow Package and its function

new_image = Image.fromarray(array)

or some other approach to display the Pix2Pix output.

Thanks!

abujaman
  • 156
  • 1
  • 6
  • 1
    You might need to convert the image as the format might be unsupported. What is the image format? If it is simply RGBA, you can just remove the header and use `decodeImageFromPixels`. I can write you an answer if you tell me what the image format is **precisely**. – creativecreatorormaybenot Aug 17 '19 at 23:05
  • The tflite model has a output layer of shape 256 * 256 * 3 (=196608) and returns a uint8list of length 786.432 (+7 bytes offset). For some reason the returned list length is 4 times the output layers neuron count. – abujaman Aug 17 '19 at 23:53

0 Answers0