File size: 975 Bytes
55fb928
e029c27
fae541d
 
 
73a347f
e029c27
55fb928
 
e029c27
 
 
 
 
 
 
 
55fb928
e029c27
 
 
 
 
 
55fb928
e029c27
 
 
55fb928
f1594b8
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
import os
import gradio as gr
import numpy as np
from tensorflow.keras.models import load_model
import cv2
###

def image_predict (image):
    model_path = 'resnet_ct.h5'  
    h5_model = load_model(model_path)
    image = np.array(image) / 255
    image = np.expand_dims(image, axis=0)
    h5_prediction = h5_model.predict(image)  
    print('Prediction from h5 model: {}'.format(h5_prediction))
    print(h5_prediction)
    probability = h5_prediction[0]
    print("H5 Predictions:")
    print (probability)
    if probability[0] > 0.5:
        covid_chest_pred = str('%.2f' % (probability[0] * 100) + '% COVID-Positive')
        probability = (probability[0] * 100)
    else:
        covid_chest_pred = str('%.2f' % ((1 - probability[0]) * 100) + '% COVID-Negative')
        probability = ((1 - probability[0]) * 100)
    return  covid_chest_pred



myApp = gr.Interface(fn=image_predict, inputs="image", outputs="text")
myApp.launch(auth=("admin", "pass1234"))#share=True