Commit
•
58ad867
1
Parent(s):
6ed6ec7
Update app.py
Browse files
app.py
CHANGED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from tensorflow.keras.preprocessing import image
|
3 |
+
from tensorflow.keras.models import load_model
|
4 |
+
import numpy as np
|
5 |
+
|
6 |
+
def predict(image_file):
|
7 |
+
width, height = 224, 224
|
8 |
+
img = image.img_to_array(image_file)
|
9 |
+
img = np.expand_dims(img, axis=0)
|
10 |
+
img = img / 255
|
11 |
+
|
12 |
+
model = load_model("/content/vgg16_model.h5")
|
13 |
+
result = model.predict(img)
|
14 |
+
|
15 |
+
if result[0][0] >= 0.5:
|
16 |
+
prediction = "Malignant"
|
17 |
+
else:
|
18 |
+
prediction = "Benign"
|
19 |
+
|
20 |
+
return prediction
|
21 |
+
|
22 |
+
iface = gr.Interface(
|
23 |
+
fn=predict,
|
24 |
+
inputs=gr.Image(label="Upload Image"),
|
25 |
+
outputs=gr.Textbox(label="Predicted Results"),
|
26 |
+
title="Skin Cancer Prediction",
|
27 |
+
description="Upload an image containing skin lesion to predict if it is malignant or benign.",
|
28 |
+
theme="huggingface",
|
29 |
+
allow_flagging=False,
|
30 |
+
examples=[
|
31 |
+
["example.jpg"], # Replace "example.jpg" with actual example image file path
|
32 |
+
]
|
33 |
+
)
|
34 |
+
|
35 |
+
iface.launch(share=True)
|