google-coral / tflite

Examples using TensorFlow Lite API to run inference on Coral devices
https://coral.withgoogle.com
Apache License 2.0
181 stars 67 forks source link

can not open resized_cat.bmp #51

Closed tyouritsugun closed 2 years ago

tyouritsugun commented 2 years ago

Hi,

I was trying classify.cc, I am using resized_cat.bmp from

https://github.com/google-coral/edgetpu/tree/master/test_data

However, I got the error below:

Cannot read image from /path/to/images/resized_cat.bmp

When I trace to the source, I found in line 54 of classify.cc

Line 53: int width = ToInt32(&info_header[4]);
Line 54: if (width < 0) return {};  // Invalid width.

The debugger says that the width is -32.

Please tell me where can I get the correct BMP file or is there any bug in ReadBmpImage?

Thank you in advance Zhang

manoj7410 commented 2 years ago

@tyouritsugun What is the PATH that you have provided for resized_cat.bmp ? Is an image available at that PATH ?

tyouritsugun commented 2 years ago

Hi

Thank you for your reply.

The line below

std::ifstream file(filename, std::ios::binary);

succeeded.

When I debug the filename, it is correct file name located in the directory I placed it to.

The problem might be the BMP info header parsing, the program says that the width of resized_cat.bmp is -32 but not 224 which is unexpected.

Zhang

manoj7410 commented 2 years ago

@tyouritsugun Did you try with any other image as well ?

tyouritsugun commented 2 years ago

Here is my system information: OS: Ubuntu 20.04 IDE: VS code 1.61.1 CPU: X64 TPU: Coral USB Accelerator

Zhang

tyouritsugun commented 2 years ago

C

@tyouritsugun Did you try with any other image as well ? Yes, I've tried several ones including the BMP from MAC and Windows.

BTW, can you please give a image link to make sure it works in your side? Regards Zhang

manoj7410 commented 2 years ago

Can you try with https://github.com/google-coral/edgetpu/blob/master/test_data/parrot.jpg OR https://raw.githubusercontent.com/google-coral/edgetpu/master/test_data/cat.bmp ?

tyouritsugun commented 2 years ago

Can you try with https://github.com/google-coral/edgetpu/blob/master/test_data/parrot.jpg OR https://raw.githubusercontent.com/google-coral/edgetpu/master/test_data/cat.bmp ?

the former one, jpg guy: it returns from line 41: return {}; // Invalid file type.

the latter one, bmp guy: const uint32_t offset = ToInt32(&file_header[10]); says that the offset is 4294967178. int width = ToInt32(&info_header[4]); says that the width is 512 int height = ToInt32(&info_header[8]); says that the height is 341 then, it returns from line 67: return {}; // Read failed.

Hope those information are helpful.

Regards Zhang

hjonnala commented 2 years ago

@tyouritsugun can you please share the binary file for classify.cc.

Please try the classsify_image.cc also from libcoral repo.

hjonnala commented 2 years ago

Please try this command if you are using linux machine to resize image:

convert cat.bmp -resize 224x224! resize_cat.bmp

Feel free to reopen if you still having any issues. Thanks!

google-coral-bot[bot] commented 2 years ago

Are you satisfied with the resolution of your issue? Yes No

rfried-nrl commented 2 years ago

I'm experiencing the same. Ubuntu 21.04

Tried resizing using the command above. didn't work.