-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcancer-detect.py
52 lines (43 loc) · 1.44 KB
/
cancer-detect.py
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
44
45
46
47
48
49
50
51
52
import streamlit as st
from ultralytics import YOLO
import pandas as pd
import numpy as np
from io import StringIO
import PIL
from PIL import Image
import requests
from io import BytesIO
st.title("cancer-dect")
st.text("Upload image here:")
uploaded_file = st.file_uploader("Choose a file", type=['png', 'jpg'])
if uploaded_file is not None:
st.write("filename:", uploaded_file.name)
uploaded_image = PIL.Image.open(uploaded_file)
st.image(uploaded_image, caption='Input', width=200)
st.divider()
type_=st.selectbox("Choose any one type of detection", (('Brain'), ('Skin')))
conf = st.slider('Set confidence level percentage', 0, 100, 25)
if type_=='Brain':
model= YOLO("cd_detect.pt")
confi=conf/100
res=model(uploaded_image, conf=confi)
img=res[0].plot()
a=res[0]
if a.masks is not None:
st.image(img, caption='Output', width=600)
else:
st.write("No detections found")
if type_=='Skin':
# Load a model
model = YOLO('yolov8n.pt') # load an official model
model= YOLO("skin_detect.pt")
confi=conf/100
res=model(uploaded_image, conf=confi)
img=res[0].plot()
a=res[0]
if a.masks is not None:
st.image(img, caption='Output', width=600)
else:
st.write("No detections found")
url="https://github.com/Amala02"
st.write("Made by: [@Amala02](%s)" % url)