Intel® Distribution of OpenVINO™ Toolkit
Community assistance about the Intel® Distribution of OpenVINO™ toolkit, OpenCV, and all aspects of computer vision-related on Intel® platforms.

Building a Pneumonia Classification Application

JNoh01
Beginner
1,400 Views

I am doing a project for Building a Pneumonia Classification Application.
I've downloaded the notebook files from the following link:

https://github.com/intel-iot-devkit/pneumonia-classification

When I run the code in pneumonia_classification_jupyter.ipynb, I got the following error:

Exception: Path to the model ../resources/FP32/model.xml doesn't exist or it's a directory

In the resources directory, there's no FP32 folder. How can I get model.xml file?

0 Kudos
1 Solution
JesusE_Intel
Moderator
1,400 Views

Hi Jung Soon,

Looking at the repository, there is a TensorFlow format (model.pb) model in the resources/model directory. The setup.sh contains the model optimizer command to convert the model.pb to IR format that is being referenced by the Jupyter Notebook. You will need to run that script to generate the IR files.

#Optimize the model
cd /opt/intel/openvino/deployment_tools/model_optimizer/
python3 mo_tf.py -m $BASE_DIR/resources/model/model.pb --input_shape=[1,224,224,3] --data_type FP32 -o $BASE_DIR/resources/FP32 --mean_values [123.75,116.28,103.58] --scale_values [58.395,57.12,57.375]
python3 mo_tf.py -m $BASE_DIR/resources/model/model.pb --input_shape=[1,224,224,3] --data_type FP16 -o $BASE_DIR/resources/FP16 --mean_values [123.75,116.28,103.58] --scale_values [58.395,57.12,57.375]

Hope this answers your question.

Regards,

Jesus

View solution in original post

0 Kudos
6 Replies
JNoh01
Beginner
1,400 Views

I raised the issue in the GitHub repo and waiting for a pull-request.  In the resources folder, there's no FP32 folder, but there's model.pb file

in the model folder.

0 Kudos
JesusE_Intel
Moderator
1,401 Views

Hi Jung Soon,

Looking at the repository, there is a TensorFlow format (model.pb) model in the resources/model directory. The setup.sh contains the model optimizer command to convert the model.pb to IR format that is being referenced by the Jupyter Notebook. You will need to run that script to generate the IR files.

#Optimize the model
cd /opt/intel/openvino/deployment_tools/model_optimizer/
python3 mo_tf.py -m $BASE_DIR/resources/model/model.pb --input_shape=[1,224,224,3] --data_type FP32 -o $BASE_DIR/resources/FP32 --mean_values [123.75,116.28,103.58] --scale_values [58.395,57.12,57.375]
python3 mo_tf.py -m $BASE_DIR/resources/model/model.pb --input_shape=[1,224,224,3] --data_type FP16 -o $BASE_DIR/resources/FP16 --mean_values [123.75,116.28,103.58] --scale_values [58.395,57.12,57.375]

Hope this answers your question.

Regards,

Jesus

0 Kudos
JNoh01
Beginner
1,400 Views

I am working on Windows 10 environment.  So, I cannot run setup.sh as it is. Instead, I ran the following code:

!python C:/OpenVino/openvino/deployment_tools/model_optimizer/mo_tf.py -m $BASE_DIR/resources/model/model.pb --input_shape=[1,224,224,3] --data_type FP32 -o $BASE_DIR/resources/FP32 --mean_values [123.75,116.28,103.58] --scale_values [58.395,57.12,57.375]

After running the above code, I got the following result:

[ SUCCESS ] Generated IR model.
[ SUCCESS ] XML file: C:\Users\USER\Documents\pneumonia-classification-master/resources/FP32\model.xml
[ SUCCESS ] BIN file: C:\Users\USER\Documents\pneumonia-classification-master/resources/FP32\model.bin
[ SUCCESS ] Total execution time: 774.89 seconds. 

However, after running pneumonia_classification_jupyer.py, I got the following error message:
----------------------------------------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-10-74cd54106bc1> in <module>
    381 
    382 if __name__ == '__main__':
--> 383     main()

<ipython-input-10-74cd54106bc1> in main()
    372                 file_name = file.split('/')[-1]
    373                 output_file = "{}/{}".format(output_dir, file_name)
--> 374                 save_img(output_file, img1, file_format='jpeg')
    375 
    376     log.info("Success")

<ipython-input-10-74cd54106bc1> in save_img(path, x, data_format, file_format, scale, **kwargs)
    120                       'RGBA images, converting to RGB.')
    121         img = img.convert('RGB')
--> 122     img.save(path, format=file_format, **kwargs)
    123 
    124 

~\Anaconda3\lib\site-packages\PIL\Image.py in save(self, fp, format, **params)
   2079                 fp = builtins.open(filename, "r+b")
   2080             else:
-> 2081                 fp = builtins.open(filename, "w+b")
   2082 
   2083         try:

FileNotFoundError: [Errno 2] No such file or directory: '../output/PNEUMONIA\\person1946_bacteria_4874.jpeg'
----------------------------------------------------------------------------------------------------------------------------
In the output folder, empty files of result.txt and stats.txt exist (No image files saved). 

0 Kudos
JNoh01
Beginner
1,400 Views

BTW, I cannot upload (attach) files here.  Could you please show me another way of uploading files?

The CPU of my PC is Intel(R) Core(TM) i7-8700CPU@3.20 GHz 3.19 GHz.

The graphic card of my PC is Nvidia GeForce GTX 1660.  Is there any possibility of affecting image processing/displaying due to the Nividia graphics card?

0 Kudos
JesusE_Intel
Moderator
1,400 Views

Hi Jung Soon,

The GitHub repository lists Ubuntu 16.04 as a requirement, the issue may be related to the windows path. However, I have not used this repository before, I recommend posting you issue on the GitHub Issue section.

Regards,

Jesus

0 Kudos
JNoh01
Beginner
1,400 Views

Instead of running pneumonia_classification_jupyter.py on the notebook cell, I executed the following command:

!python pneumonia_classification_jupyter.py -m ../resources/FP32/model.xml -o ../output

After running the above command, got result.txt and stats.txt file, which are not empty.  Also, after copying
PNEUMONIA folder to the output directory, I also got image files, where class_activation heatmap is overlaid
over the X-ray image in case of pneumonia.  The wider the yellow color area, the higher the probability of pneumonia is. 
The file not found error is caused as there are no base X-ray image files to be overlaid. Looks like in the
pneumonia_classification_jupyter.py file, there is no code copying PNEUMONIA folder to the output directory
(I manually copied the folder).

0 Kudos
Reply