forked from adityakakarla/focus-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstreamlit_app.py
More file actions
39 lines (27 loc) · 1.05 KB
/
streamlit_app.py
File metadata and controls
39 lines (27 loc) · 1.05 KB
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
import streamlit as st
from camera_input_live import camera_input_live
from roboflow import Roboflow
from PIL import Image
import io
from playsound import playsound
import time
rf = Roboflow(api_key="NBUvQ56DQdrvX3vNmz90")
project = rf.workspace().project("photo-detector-v3")
model = project.version(3).model
image = st.file_uploader(label='Upload a PNG or JPG file', type=['png','jpg'])
if image:
st.image(image)
with open('input_image.jpg', 'wb') as f:
f.write(image.getvalue())
result = model.predict('input_image.jpg', confidence=40, overlap=30).json()
if len(result['predictions']) >= 1:
st.write('You are off task')
playsound('phone.mp3')
else:
st.write('You are on task')
# infer on a local image
#st.write(model.predict('input_image.jpg', confidence=40, overlap=30).json())
# visualize your prediction
#model.predict(image, confidence=40, overlap=30).save("prediction.jpg")
# infer on an image hosted elsewhere
# print(model.predict("URL_OF_YOUR_IMAGE", hosted=True, confidence=40, overlap=30).json())