File size: 712 Bytes
556fd3a
 
 
 
6ac284f
 
 
 
556fd3a
 
6ac284f
556fd3a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6ac284f
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
import gradio as gr
import numpy as np



# load the trained CNN model
cnn_model = keras.models.load_model("fine_tuning.keras")

def Normal_or_Pneumonia(img):
   img = img.reshape( -1, 180, 180,3 )
   prediction = cnn_model .predict(img).tolist()[0]
   CLASS_NAMES = ["PNEUMONIA DETECTOR"]
   return {CLASS_NAMES[i]: prediction[i] for i in range(1)}

#set the user uploaded image as the input array
#match same shape as the input shape in the model

image_input = gr.inputs.Image( shape=(180, 180) ,invert_colors=False  ,   type="numpy"    )


#setup the interface
iface = gr.Interface(
  fn = Normal_or_Pneumonia,
  inputs = image_input,
  outputs = gr.outputs.Label(),
)
iface.launch(share=True , debug = True)