-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathupload.py
More file actions
36 lines (25 loc) · 966 Bytes
/
upload.py
File metadata and controls
36 lines (25 loc) · 966 Bytes
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
from classify import predict
import streamlit as st
from PIL import Image
import numpy as np
st.write("""
# Simple VGG16 Model Classifier
""")
import streamlit as st
import os
def file_selector(folder_path='./images'):
filenames = os.listdir(folder_path)
selected_filename = st.selectbox('Select your Image', filenames)
return os.path.join(folder_path, selected_filename)
filename = file_selector()
st.write('You selected `%s`' % filename)
# upload_img = st.file_uploader(label='Upload your Image', type=['png', 'jpg'])
if filename:
img = Image.open(filename)
st.image(img, caption="Your Image", use_column_width=True)
st.write("Classifying...")
label = predict(filename)
st.write('The image is %s with %.2f%% probabiity' % (label[1], label[2]*100))
# if upload_img is not None:
# file_bytes = np.asarray(bytearray(upload_img.read()), dtype=np.uint8)
# opencv_image = cv2.imdecode(file_bytes, 1)