-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathapp.py
31 lines (25 loc) · 862 Bytes
/
app.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
import cv2
import numpy as np
import streamlit as st
from PIL import Image
@st.cache(allow_output_mutation=True)
def get_predictor_model():
from model import Model
model = Model()
return model
header = st.container()
model = get_predictor_model()
with header:
st.title('Hello!')
st.text(
'Using this app you can classify whether there is fight on a street? or fire? or car crash? or everything is okay?')
uploaded_file = st.file_uploader("Or choose an image...")
if uploaded_file is not None:
image = Image.open(uploaded_file).convert('RGB')
image = np.array(image)
label_text = model.predict(image=image)['label'].title()
st.write(f'Predicted label is: **{label_text}**')
st.write('Original Image')
if len(image.shape) == 3:
cv_image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
st.image(image)