File size: 2,758 Bytes
37d8430
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2deb80a
 
db16572
 
7ca3eb0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
efaf5e3
 
98f9207
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
##importing the libraries
import numpy as np
import pandas as pd
from PIL import Image
import tensorflow as tf
import os 
from tensorflow.keras.models import load_model
import gradio as gr


# Load your trained model
model = load_model('tb_pretrained.h5')

### Preprocess the new image

def predict_image(test_image):
    # img = cv2.imread(test_image)
    img = np.array(test_image)
    
    image_1 = tf.image.resize(img, (256,256))

    image_processed = np.expand_dims(image_1/256, 0)
    
    ##prediction
    
    yhat = model.predict(image_processed)
    
    ## setting a threshold 
    if yhat[0][1] > 0.70:
        return (f'There is {round((yhat[0][1])*100,2)}% chance of the image being normal')
    elif yhat[0][0] > 0.9:
        return (f'There is {round((yhat[0][0])*100,2)}% chance of an abnormality either than TB being present')
    else:
        return (f'There is a chance of TB being present')


platform = gr.Interface( fn = predict_image, 
                        title ="TB CADx",
                        inputs = "image", 
                        outputs = "label",
                        description="""
                        Introducing a revolutionary computer-aided detection tool designed to enhance the efficiency of clinicians in the classification of chest X-ray images. 
                        This innovative system facilitates the swift classification of images into three key categories: normal, indicating no abnormalities; 
                        unhealthy but not indicative of Tuberculosis (TB); and those with a high likelihood of TB presence. 
                        By streamlining the classification process, this tool aims to expedite diagnostic assessments and aid clinicians in making informed decisions regarding patient care. 
                        """,
                        article = """ 
                        It is crucial to emphasize that while this tool serves as a valuable research aid, 
                        it is not intended to replace clinical guidelines, 
                        nor should it substitute for the wealth of clinical knowledge 
                        and experience possessed by healthcare professionals. 
                        The algorithm is meant to complement and support the diagnostic process, 
                        providing an additional layer of analysis for consideration in conjunction with the clinician's expertise. 
                        Users are encouraged to interpret the algorithm's output in conjunction with their clinical judgment, 
                        and the tool should be viewed as a supplementary resource rather than a standalone diagnostic solution.
                        """ )


platform.launch(inline=True, share=True)