File size: 1,380 Bytes
a9cdf20
 
 
 
 
 
 
 
 
 
 
e65a009
a9cdf20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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-detection")
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)

    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")