initial commit
Browse files- app.py +34 -0
- best.pt +3 -0
- requirements.txt +0 -0
app.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from ultralytics import YOLO
|
3 |
+
|
4 |
+
format = { 0: 'Bengin case',
|
5 |
+
1: 'Bengin case Malignant case',
|
6 |
+
2: 'Malignant case',
|
7 |
+
3: 'Malignant case Normal case',
|
8 |
+
4: 'Normal case'}
|
9 |
+
|
10 |
+
def image_classifier(inp):
|
11 |
+
model = YOLO("best.pt")
|
12 |
+
|
13 |
+
result = model.predict(source=inp)
|
14 |
+
probs = result[0].probs
|
15 |
+
max_tensor = max(probs)
|
16 |
+
tensor_pos = ((probs == max_tensor).nonzero(as_tuple=True)[0])
|
17 |
+
|
18 |
+
return format.get(int(tensor_pos))
|
19 |
+
|
20 |
+
web = gr.Interface(fn=image_classifier, inputs="image", outputs="text")
|
21 |
+
|
22 |
+
|
23 |
+
|
24 |
+
with gr.Blocks() as site:
|
25 |
+
gr.Markdown("Lung cancer detection using Yolov8 model")
|
26 |
+
with gr.Row():
|
27 |
+
img_input = gr.Image()
|
28 |
+
txt_output = gr.Textbox()
|
29 |
+
submit_btn = gr.Button("Submit")
|
30 |
+
|
31 |
+
submit_btn.click(image_classifier, inputs=img_input, outputs=txt_output)
|
32 |
+
|
33 |
+
web.launch(share=True)
|
34 |
+
|
best.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d27ab3e4b292f0eddd4aa051a0a8554be486cc50c2478ac30c9188c4cfedc681
|
3 |
+
size 2962720
|
requirements.txt
ADDED
Binary file (2.54 kB). View file
|
|