Deep Learning with Images using Tensorflow

DOI : 10.17577/IJERTV8IS090264

Download Full-Text PDF Cite this Publication

Text Only Version

Deep Learning with Images using Tensorflow

G. Janane1, Dr. K. Meena Alias Jeyanthi 2

PG Scholar, Department of ECE, PSNACET, Dindigul, India1 Professor, Department of ECE, PSNA CET, Dindigul, India2

AbstractThis paper focuses the image detection and classification of the disease stages based on the newly emerging deep learning technology. The deep learning technology is from the basic Artificial intelligence and machine learning. The images that are to be analyzed is taken from the X-ray data. There different algorithm that are used to differentiate the normal with the affected area of the organ. In this, we look about the strength of deep learning approaches for pathology detection in chest radiographs. Convolutional neural networks (CNN) deep architecture classification approaches have gained popularity due to their ability to learn mid and high-level image representations. We explore the ability of CNN learned from a non-medical dataset to identify different types of causes and effect of disease in chest x-rays. The best implementation was achieved using CNN. The outcomes establish the feasibility of encountering the pathology in chest x-rays using deep learning approaches based on non-medical learning.

Index terms Chest Radiography, Deep Learning, Deep Networks, CNN.


    Pneumonia is the leading cause of death among children in developing countries, including India. WHO estimates that one in three new born infant deaths is due to pneumonia. About half of these deaths can be prevented as they are caused by the bacteria for which an effective vaccine is available. Chest X-ray (CXR), is an important tool for diagnosing pneumonia and many clinical decisions rely heavily on its radiological findings. Also, it is relatively cheap compared to other imaging diagnostics and can be afforded by masses. Some work has been done on automated pneumonia detection through natural language processing and artificial neural network. When interpreting chest X-rays for Pneumonia, the radiologist will look for white spots in the lungs called infiltrates that identify an infection. However, such cloudy patterns would also be observed in TB Pneumonia and severe cases of bronchitis too. For conclusive diagnosis, further investigations such as complete blood count (CBC), Sputum test, and Chest computed tomography (CT) scan etc. may be needed. Therefore, we are only attempting to detect possibility of pneumonia from Chest X-rays, by looking for cloudy region in the same. Conclusive detection will depend on pathological tests.

    The deep learning is a broader area of machine learning technique based on artificial neural network. The learning technology has several architectures such as deep belief network, deep neural network, recurrent neural network and convolutional neural network used for the purpose of computer vision, speech recognition, bioinformatics and medical image analysis etc. In this the

    ANN is inspired by the biological neural network (BNN). Basically, Deep learning is a class of machine learning algorithm that uses multiple layers to progressively extract higher level features from the raw input. Fig 1 shows basic CNN Working. Here the CNN performs both generative and descriptive task. It is used for image recognition and video processing. It includes the Input layer, Hidden Layer, Output Layer with convolution layer, pooling layer and fully connected layer. The Convolutional layer is used to extract the features from the source input image. The pooling layer reduces the dimension of the image without any loss of feature extraction. The Fully connected Layer is also the dense layer where the result of the convolutional layer is given as a input to many neural layer to generate the prediction of image.

    The convolution layer is used for both 2-dimensional and 3-dimensional structures of an image.CNN are well used for image recognition purposes.In this work, the prediction method is implemented via convolutional neural network (CNN) using python programming language.After pre- processing of data, different deep learning algorithms are trained to measure the performance of CNN with classifiers.

    The CNN takes the input image as raw pixel and transforms it using the convolution layer, Rectified Linear Unit (RELU) and pooling layers. These outputs are given as input to the fully connected layer which assigns the high values to classify the classes.

    Fig 1 CNN working


    In [1] Xue-Wen Chen And Xiao tong Lin (2014) proposed that with the more amount of data available today, it is used in various sectors. It also presents unprecedented challenges to harnessing data and information. This paper provides the knowledge about the deep learning and challenges to big data as well as the future trends.

    In [2] Pranav Rajpurkar, Jeremy Irvin, Kaylie Zhu, Brandon Yang, Hershel Mehta, Tony Duan, Daisy Ding, Aarti Bagul, Robyn L. Ball, Curtis Langlotz, Katie Shpanskaya, Matthew

    P. Lungren, Andrew Y. Ng, (2017) proposed that in this they used CheXNet which consist of 121-layer of Convolutional Neural Network trained on ChestX-ray14, currently the best available chest X-ray dataset, containing over 100,000 frontal view X-ray images with 14 diseases. Four practicing academic radiologists annotate a test set, on which they compared the performance of CheXNet to that of radiologists.

    In [3] Adam Rao, Jorge Ruiz, Chen Bao, Shuvo Roy (2017) proposed using the rapid technique they have developed a non-invasive acoustic proof to characterize the deposit of fluids in the lungs caused by pneumonia. The acoustic mismatch is marked as difference in sound transmission of 500Hz.The pneumonia patient data are represented between the normal and consolidated lung as a difference of 10dB.

    In [4] Pedro Cisneros-Velarde, Malena Correa, Holger Mayta, Cynthia Anticona, Monica Pajuelo, Richard Oberhelman, William Checkley, Robert H Gilman, Dante Figueroa, Mirko Zimic, Roberto Lavarello, Benjamín Castañeda (2016) proposed that the algorithm utilizes different geometrical properties of typical anatomical and pathological features that commonly appear in lung sonography and which are already clinically typified in the literature. This technique has been tested on different transverse thoracic scanning protocols and probes maneuvers, thus, under a variety of clinical and usage protocols. Then, it can be targeted towards screening applications.

    In [5] Gilberto de Melo, Sanderson O. Macedo, Silvio L. Vieira, and Leandro L. G. Oliveira(2018) proposed that this paper presents a CUDA-based parallel algorithm especially designed to provide speed gains for a wavelet feature extraction applied to high resolution DICOM images. The wavelet features are used for pneumonia detection and the proposed parallel technique improves the computing speed more than 12.75 times.Here the pattern recognition helps to automate the presence and absence of pneumonia with high reliability with high cost.

    In [6] Mohammed Nizam Saad, Zurina Muda, Noraidah Sahari@ Ashaari, Hamzaini Abdul Hamid (2014) This paper has proposed the method for segmenting lung region in CXR images using canny edge filter and morphology. Although the filter can detect the lung edge, the final edge line is unsatisfied. To solve this problem, Euler number method is applied to extract the lung region before executing the edge detection using the filter. The implementation produced convincing result as most of the segmented image is almost similar to the ground truth image.

    In [7] Marios Anthimopoulos, Stergios Christodoulidis, Lukas Ebner, Andreas Christe, and Stavroula Mugiakakou (2016) In this paper they proposed and evaluate a convolutional neural network (CNN), designed for the classication of ILD patterns. The proposed network consists of 5 convolutional layers with 2 2 kernels and Leaky ReLU activations, followed by average pooling with size equal to the size of the nal feature maps and three dense layers. The last dense layer has 7 outputs, equivalent to the classes considered: healthy, ground glass opacity (GGO), micronodules, consolidation, reticulation, honeycombing and a combination of GGO/reticulation. To train and evaluate the CNN, we used a dataset of 14696 image patches, derived by

    120 CT scans from different scanners and hospitals.Theclassication performance (85.5%) demonstrated the potential of CNNs in analysing lung patterns.In [8] Adrien Depeursinge, Pedram Pad, Anne S. Chin, Ann N. Leung, Daniel L. Rubin, Henning Muller and Michael Unser (2015) This proposal is to act on the bandwidth of steerable wavelets while maintaining their tight frame property. To that end, they designed a family of maximally localized wavelet pyramids in 3D for a continuously adjustable radial bandwidth [, ], [/4, /2]. The proposed wavelets are coupled with a rotation covariant directional operator based on the Riesz transform, which provides characterizations of the organization image directions independently from their local orientations.

    In [9] Azian Azamimi Abdullah and Norafifah Md Posdzi, Yoshifumi Nishio (2011) In this paper, a pneumonia symptoms detection method based on cellular neural networks (CNNs) is proposed. The CNN design is characterized by a virtual template expansion obtained through a multistep operation. It is based on linear space invariant 3 x 3 templates. The proposed design is capable of performing pneumonia symptoms detection within a short time. The main idea in CNN is that connection is allowed between adjacent units only. Candy software is used as a CNN simulator to detect the pneumonia symptoms area. The simulation results show good performance based on the different grayscale colour and segmentation between the normal area and lung region area.

    In [10] Yaniv Bar, Idit Diamant, Lior Wolf, Sivan Lieberman, Eli Konen, Hayit Greenspan (2015) proposed the feasibility of detecting pathology in chest x-rays using deep learning approaches based on non-medical learning. This shows that Deep learning with ImageNet, a large scale non- medical image database may be a good substitute to domain specific representations, which are yet to be available, for general medical image recognition tasks. We obtained an area under curve (AUC) of 0.87-0.94 for the different pathologies.

    In [11] Karan Jakhar, Nishtha Hooda(2018) proposed that Big Data predictive analytics using machine learning techniques is currently a much active area of research in medical science. With increasing size and complexity of medical data like X-rays, deep learning gained huge success in prediction of many fatal diseases like

    pneumonia. In this work, DCNN (deep convolutional neural networks) an efficient predicting model for big data, having deep layers is a proposed, which can classify whether a person is having a pneumonia or not.


    The main purpose of establishing the field of deep learning is to get trained model for prediction and classification of the patients using the X-ray data. The result of the CNN helps to predict whether there is presence of pneumonia or not.


    The result of the CNN helps to predict whether the person is affected by pneumonia or not using the X-ray images of the chest. Normally in these recent days, the detection of image has less control over the quality of the images. Hence some of them are being pre-processed for the removal of corrupted image, cleaning etc.

    Images Prediction model

    Feature Extraction by Convolutional layer:

    When the input data is too large to be processed

      1. Repetitiveness of images represented as pixels can be transformed into reduced set of features. The selected feature should contain the relevant information from the input, so that the task can be performed by using this reduced representation than the complete data.

        Fully Connected Layer:

        The final layer in a Convolutional Neural Network is the fully connected layer. In this every neuron in the forgoing layer is connected to every neuron in the Fully connected layer. This layer takes the output from the previous layer of convolution, pooling layer or RELU as input and computes a score for classification of classes. This layer looks at the combination of strongly activated function features.

        Output Layer:

        The output layer is the output of the continuous connection of the fully connected layer. This layer gets flattened and made into single row of layer. Finally, the respected area or the pixel or high value is obtained for the respective classes.




        Fig 2 CNN Prediction framework

        Fig 2 shows the basic prediction framework of pneumonia using the CNN. Fig 3 shows the flow diagram of the proposed work. The output of the proposed Convolutional neural network gives the information about whether the person is affected by pneumonia or not. If the output is 1it gives the positive result(pneumonia) and if 0 it gives negative result(normal). Fig 3 shows the Process flow diagram of the work.

        Convolutional Layer:

        A convolution operation is defined as two functions. In image prediction, one function consists of input values at a position of the images, and second function is a kernel filter. They can be represented in the form of arrays. The dot product between the two functions gives an output.

        CNN in Keras library:

        To use Deep learning to classify the image we should build the CNN network hence the Keras in Python is used to build the Convolutional Neural Network. Basically, Convolution is used to identify the images where the computer visualizes as pixel, the group of pixel forms the edge of the image. This edge of an image can be identified by the Convolutional network. In Keras Library we can load set of data. Suppose we have 60,000 images, 50,000 images are taken as trained data and remaining 10,000 images is taken for testing.

        Loading images



        Implementation CNN Using Kera's library in TensorFlow

        Implementation CNN Using Kera's library in TensorFlow

        Output layer

        Output layer

        Feature Extraction by convolutional layer Fully Connected Layer

        Accuracy, Loss function

        Accuracy, Loss function



        Fig 3Process Flow Diagram


    In this section, the Chest X-ray images used for classification were taken from a public chest database Kaggle which consist of medical databases. The dataset has

    more than 5,000 X-ray images with two parts i.e. normal and pneumonia. All the images available are in (.jpeg) format.


Based on various deep learning algorithms the image detection and classification were studied in this survey. In the above paper they describe the methods used to detect the disease and its stages have been predicted. The accuracy of the pathology with non-medical training. Some papers said about the algorithms in a wavelet for the analysis of the tissues.

Fig 4 Accuracy Graph

Fig 4 shows about the accuracy of the images that have been loaded to predict the pneumonia affected part. The accuracy has been compared to the trained dataset and the resulting graph is shown.

Fig 5 shows the Loss function of the given image. The input given image is compared to the trained images and being tested. Finally, the loss function is given less that of the trained dataset.

Fig 6 gives output that has been executed using the TensorFlow software with Python language. Here the image Accuracy, Loss function for every Epochs is shown.

Fig 5 Loss Graph

Fig 6 Output


Pneumonia is becoming a serious issue if it is not being treated properly in patients. Based on the World Health Organization report 75% of the global population are lagging from radiology diagnostics. In this work, Deep learning-based prediction of pneumonia model is proposed. Here, we develop an algorithm using a software tool TensorFlow to detect pneumonia in the frontal view of Chest X-ray images.It compares the normal image with the affected image and displays the area in color and its stage

of it. The accuracy is given with best result.


      1. Xue-Wen Chen, (Senior Member, Ieee), And Xiaotong Lin, Big Data Deep Learning: Challenges and Perspectives. IEEE Access Vol.2 May 13,2014.

      2. Pranav Rajpurkar, Jeremy Irvin, Kaylie Zhu, Brandon Yang, Hershel Mehta, Tony Duan, Daisy Ding, Aarti Bagul, Robyn L. Ball, Curtis Langlotz, Katie Shpanskaya, Matthew P. Lungren, Andrew Y. Ng, CheXnet: Radiologist-Level Pneumonia Detection on Chest X-Rays with Deep Learning.

      3. Adam Rao, Student Member, IEEE, Jorge Ruiz, Chen Bao, Shuvo Roy, Member, IEEE., Tabla: An Acoustic Device Designed for Low Cost Pneumonia Detection.978-1-5386-1392-4/17/$31.00

        ©2017 IEEE.

      4. Pedro Cisneros-Velarde, Malena Correa, Holger Mayta, Cynthia Anticona, Monica Pajuelo, Richard Oberhelman, William Checkley, Robert H Gilman, Dante Figueroa, Mirko Zimic, Roberto Lavarello, Benjamín Castañeda., Automatic

        Pneumonia Detection Based on Ultrasound Video Analysis.978-1-4577-0220-4/16/$31.00 ©2016 IEEE.

      5. Gilberto de Melo, Sanderson O. Macedo, Silvio L. Vieira, and Leandro L. G. Oliveira., Classification of Images and Enhancement of Performance Using Parallel Algorithm to Detection of Pneumonia, ICA-ACCA 2018, October 17-19, 2018, Greater Concepci´on, Chile.,978-1-5386-5586-3/18/$31.00 c2018 IEEE.

      6. Mohd Nizam Saad, Zurina Muda, Noraidah Sahari@ Ashaari, Hamzaini Abdul Hamid., Image Segmentation for Lung Region in Chest X-Ray Images Using Edge Detection and Morphology,2014 IEEE International Conference on Control System, Computing and Engineering, 28 – 30 November 2014, Penang, Malaysia.

      7. Marios Anthimopoulos, Member, IEEE, Stergios Christodoulidis, Member, IEEE, Lukas Ebner, Andreas Christe, and Stavroula Mougiakakou*, Member, IEEE., Lung Pattern Classification for Interstitial Lung Diseases Using A Deep Convolutional Neural Network, IEEE Transactions on Medical Imaging, Vol.35, No.5, May2016.

      8. Adrien Depeursinge, Pedram Pad, Anne S. Chin, Ann N. Leung, Daniel L. Rubin, Henning Muller and Michael Unser., Optimized Steerable Wavelets for Texture Analysis of Lung Tissue In 3Dct: Classification of Usual Interstitial Pneumonia,978-1-4799-2374-8/15/$31.00 ©2015 IEEE.

      9. Azian Azamimi Abdullah and Norafifah Md Posdzi, Yoshifumi Nishio., Premilinary Study of Pneumonia Symptoms Detection Method Using Cellular Neural Network, International Conference on Electrical, Control and Computer Engineering Pahang, Malaysia, June 21-22, 2011.,978-1-61284- 230-1/11/$26.00 ©2011 IEEE

      10. Yaniv Bar, Idit Diamant, Lior Wolf, Sivan Lieberman, Eli Konen, Hayit Greenspan., Chest Pathology Detection Using Deep Learning with Non-Medical Training,978-1-4799-2374- 8/15/$31.00 ©2015 IEEE

      11. Karan Jakhar, Nishtha Hooda Big Data Deep Learning Framework Using Keras: A Case Study Of Pneumonia Prediction,2018 4th International Conference on Computing Communication and Automation (ICCCA).,978-1-5386-6947- 1/18/$31.00 ©2018 IEEE.

Leave a Reply