shivakumar4147 commited on
Commit
4110e83
·
verified ·
1 Parent(s): 7209293

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +28 -0
  2. final_model.h5 +3 -0
  3. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import tensorflow as tf
3
+ import numpy as np
4
+ import cv2
5
+
6
+ # Load model
7
+ model = tf.keras.models.load_model("model_244.h5")
8
+
9
+ def predict_image(image):
10
+ # Resize to 244x244
11
+ img = cv2.resize(image, (244, 244))
12
+ img = img.astype(np.float32) / 255.0
13
+ img = np.expand_dims(img, axis=0)
14
+ p = model.predict(img)[0][0]
15
+ risk = "High" if p > 0.7 else "Medium" if p > 0.4 else "Low"
16
+ return f"Risk: {risk} (Probability: {p:.3f})"
17
+
18
+ # Gradio interface
19
+ iface = gr.Interface(
20
+ fn=predict_image,
21
+ inputs=gr.Image(type="numpy"),
22
+ outputs="text",
23
+ title="Cancer Risk Detector (244×244)",
24
+ description="Upload an image to get a cancer risk prediction."
25
+ )
26
+
27
+ if __name__ == "__main__":
28
+ iface.launch()
final_model.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8ff8ac00211462b4b533154bae22362e5501838219a1dfb9eecf3bd8121ca533
3
+ size 24526712
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ tensorflow
2
+ opencv-python
3
+ numpy
4
+ gradio