Spaces:
Sleeping
Sleeping
File size: 909 Bytes
db11337 |
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 |
import cv2
import numpy as np
import time
import os
from PIL import Image
import gradio as gr
ch_detection_model1 = cv2.dnn.readNet('tumor_classifier_mixed_datasets.onnx')
def main_func(im):
im=cv2.resize(im,(224,224))
im=cv2.cvtColor(im, cv2.COLOR_RGB2BGR)
im = (im.astype(np.float32)) / 255.0
im=im[np.newaxis, ...]
#print(im.shape)
ch_detection_model1.setInput(im)
outputs=ch_detection_model1.forward(ch_detection_model1.getUnconnectedOutLayersNames())
outputs=np.array(outputs)
outputs=outputs.reshape(-1)
if outputs[0]>0.49:
results=("predicted as Tumor with probability :"+str(outputs[0]))
return results
if outputs[0]<0.50:
results=("There is No-Tumor with probability :"+str(1-outputs[0]))
return results
def final_func():
gr.Interface(fn=main_func,
inputs=gr.Image(),
outputs='text').launch()
if __name__ == "__main__":
final_func()
|