Original

In the case of the Original voice, things are very easy since we don’t need sliders and values as in the case of Brightness and Contrast, and we don’t need to modify anything. We just need to get the image we opened with file_uploader and show it on the screen. The code is as follows:

Figure 9.12: The Original Image feature

If you want, you can try to set the use_column_width argument in st.image to False and check the result, or, if you prefer, you can specify a width size different from 600.

This is the effect in the browser:

Figure 9.13: The Original Image feature in action

With the Original image feature, we can consider the Image Enhancement voice of the menu completed. Thanks to the Pillow library, we could implement all features of this voice in a very smooth way. This is one of the best aspects of Python, and you can always find a nice package that already has all the features you need!

Let’s move on to the Disclaimer and Info section. The Diagnosis section is a little bit more complex, so we will leave that for the next chapter.

Adding the Disclaimer and Info section

Dealing with applications that provide predictions, especially health predictions, can be a little bit dangerous, so a good practice is to write down a disclaimer to avoid any kind of misunderstanding.

The disclaimer of this web application, named Disclaimer and Info, also serves the function of providing some information about the model used to predict COVID-19 from images and about the dataset that was used to train that model.

In short, the main purpose of the disclaimer is to clarify that the application is just a demo of Streamlit’s capabilities and doesn’t have any value from a medical point of view. Additionally, the disclaimer also contains some information about the AI model used to make the predictions.

In Chapter 10, we will see that every time we need to make predictions, a good strategy is to use a machine learning model.

In particular, the model used in our web application is a so-called convolutional neural network (CNN) developed using the library named tensorflow and using a dataset comprising 206 images of affected people and 206 images of healthy individuals.

Additional information

CNNs are particular neural network architectures that perform very well with problems related to images, such as image classification. What we want to do with this application is precisely the classification of images, specifically X-ray images of the chest, to discover whether or not they show cases of COVID-19. Discovering whether or not a given image represents a COVID-19 case is a classic problem of binary classification, which means understanding whether something is true or false. CNNs are very good classifiers for this type of task. However, for better performance, they need a large number of images, so a big dataset is required to train these models.

The CNN we used performs quite well, even if it was trained with a limited number of images. The model performs well when classifying images representing COVID-19 cases and healthy individuals, but its predictive performance is poor for images representing SARS cases (SARS is rather close to Covid-19).

The disclaimer has to be inserted in the else part of the if clause related to the menu, as shown in the following figure:

Figure 9.14: The insertion point of the disclaimer

We can decide to write this disclaimer in many ways, but a very easy one is just to use some st.write objects. In this way, we can have very clear, well-presented, formatted text, and we can add links to some websites that can be used as references. We are using the Markdown syntax, so it’s possible to use bold, italics, bullet points, lists, and so on.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *