Spaces:
Runtime error
Runtime error
import streamlit as st | |
import os | |
import subprocess | |
import geocoder | |
import pandas as pd | |
from csv import writer | |
# import keyboard | |
# st.title('Dawg Detection ๐ถ') | |
st.markdown("<h1 style='text-align: center; color: white;'>Dawg Detection ๐ถ</h1>", unsafe_allow_html=True) | |
pic=st.camera_input('Take A Picture') | |
bob='python /Users/eemanmajumder/code_shit/Project_Exibition/yolov7/detect.py --weights /Users/eemanmajumder/code_shit/Project_Exibition/app/yolov7.pt --classes 16 --conf 0.25 --img-size 640 --source /Users/eemanmajumder/code_shit/Project_Exibition/yolov7/inference/images/seesh.png --exist-ok --save-conf --save-txt' | |
if pic: | |
with open ('yolov7/inference/images/seesh.png','wb') as file: | |
file.write(pic.getbuffer()) | |
# keyboard.press_and_release('control+shift+`') | |
# !python3 yolov7/detect.py --weights yolov7.pt --conf 0.25 --img-size 640 --source inference/images/seesh.png --classes 16 --exist-ok --save-conf --save-txt | |
os.system('cd /Users/eemanmajumder/code_shit/Project_Exibition') | |
os.system(bob) | |
st.markdown("---") | |
st.text('Detected Dawgs') | |
img=st.image('/Users/eemanmajumder/code_shit/Project_Exibition/runs/detect/exp/seesh.png') | |
names= [ 'person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light', | |
'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', | |
'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee', | |
'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard', | |
'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple', | |
'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch', | |
'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone', | |
'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear', | |
'hair drier', 'toothbrush' ] | |
len(names) | |
d= {} | |
for i in range(0,len(names)): | |
d[names[i]]=i | |
f=open("/Users/eemanmajumder/code_shit/Project_Exibition/runs/detect/exp/labels/seesh.txt",'r') | |
a=f.readlines() | |
b=[] | |
for j in range(0,len(a)): | |
if a[j][0:2] == '16': | |
b.append('yass') | |
else: | |
continue | |
print(len(b)) | |
f=open("/Users/eemanmajumder/code_shit/Project_Exibition/runs/detect/exp/labels/seesh.txt",'w') | |
st.balloons() | |
st.success(f'Total Number Of Dogs Detected: {len(b)}') | |
st.markdown("---") | |
g = geocoder.ip('me') | |
print(g.latlng) | |
with open('database/cord.csv', 'a') as f_object: | |
writer_object = writer(f_object) | |
writer_object.writerow(g.latlng) | |
f_object.close() | |
df=pd.read_csv('database/cord.csv') | |
cum=len(df['lat']) | |
# df.to_csv('database/cord.csv',index=False) | |
st.text(f'Your Location Coordinates: {g.latlng}') | |
st.map(df,use_container_width=True,zoom = 4) | |
st.markdown(f"<h5 style='color: red;'>Total Number Of Reports Around The World: {cum}<h5>", unsafe_allow_html=True) | |
clicked= st.button('Click Me For Balloons',help='Click here to feel happy ๐') | |
if clicked==True: | |
st.balloons() |