|
import gradio as gr |
|
import tensorflow as tf |
|
import numpy as np |
|
from PIL import Image |
|
|
|
model_path = "xception.keras" |
|
model = tf.keras.models.load_model(model_path) |
|
|
|
|
|
def predict_tumor(image): |
|
|
|
print(type(image)) |
|
image = Image.fromarray(image.astype('uint8')) |
|
image = image.resize((150, 150)) |
|
image = np.array(image) |
|
image = np.expand_dims(image, axis=0) |
|
|
|
|
|
prediction = model.predict(image) |
|
|
|
|
|
|
|
prediction = np.round(prediction, 2) |
|
|
|
|
|
p_non_tumor = prediction[0][0] |
|
tumor = prediction[0][1] |
|
|
|
return {'kein tumor': p_non_tumor, 'tumor': tumor} |
|
|
|
|
|
|
|
input_image = gr.Image() |
|
iface = gr.Interface( |
|
fn=predict_tumor, |
|
inputs=input_image, |
|
outputs=gr.Label(), |
|
examples=["images/1 no.jpeg", "images/3 no.jpg", "images/2 no.jpeg", "images/5 no.jpg", "images/4 no.jpg", "images/Y1.jpg", "images/Y2.jpg", "images/Y7.jpg", "images/Y4.jpg", "images/Y8.jpg"], |
|
description="TEST.") |
|
|
|
iface.launch() |