shikharyashmaurya commited on
Commit
a9cdf20
1 Parent(s): a5578bb

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -0
app.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from ultralytics import YOLO
3
+ import pandas as pd
4
+ import numpy as np
5
+ from io import StringIO
6
+ import PIL
7
+ from PIL import Image
8
+ import requests
9
+ from io import BytesIO
10
+
11
+
12
+ st.title("cancer-dect")
13
+ st.text("Upload image here:")
14
+ uploaded_file = st.file_uploader("Choose a file", type=['png', 'jpg'])
15
+ if uploaded_file is not None:
16
+
17
+
18
+ st.write("filename:", uploaded_file.name)
19
+ uploaded_image = PIL.Image.open(uploaded_file)
20
+ st.image(uploaded_image, caption='Input', width=200)
21
+
22
+ # st.divider()
23
+
24
+ type_=st.selectbox("Choose any one type of detection", (('Brain'), ('Skin')))
25
+ conf = st.slider('Set confidence level percentage', 0, 100, 25)
26
+
27
+ if type_=='Brain':
28
+ model= YOLO("cd_detect.pt")
29
+ confi=conf/100
30
+ res=model(uploaded_image, conf=confi)
31
+ img=res[0].plot()
32
+ a=res[0]
33
+ if a.masks is not None:
34
+ st.image(img, caption='Output', width=600)
35
+ else:
36
+ st.write("No detections found")
37
+
38
+ if type_=='Skin':
39
+ # Load a model
40
+ # model = YOLO('yolov8n.pt') # load an official model
41
+ model= YOLO("skin_detect.pt")
42
+ confi=conf/100
43
+ res=model(uploaded_image, conf=confi)
44
+ img=res[0].plot()
45
+ a=res[0]
46
+ if a.masks is not None:
47
+ st.image(img, caption='Output', width=600)
48
+ else:
49
+ st.write("No detections found")