Eeman Majumder commited on
Commit
ee303e2
·
1 Parent(s): 6a5ff90

Add application file

Browse files
Files changed (1) hide show
  1. app.py +66 -0
app.py ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import os
3
+ import subprocess
4
+ import geocoder
5
+ import pandas as pd
6
+ from csv import writer
7
+ # import keyboard
8
+ # st.title('Dawg Detection 🐶')
9
+ st.markdown("<h1 style='text-align: center; color: white;'>Dawg Detection 🐶</h1>", unsafe_allow_html=True)
10
+
11
+ pic=st.camera_input('Take A Picture')
12
+ 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'
13
+ if pic:
14
+ with open ('yolov7/inference/images/seesh.png','wb') as file:
15
+ file.write(pic.getbuffer())
16
+ # keyboard.press_and_release('control+shift+`')
17
+ # !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
18
+ os.system('cd /Users/eemanmajumder/code_shit/Project_Exibition')
19
+ os.system(bob)
20
+ st.markdown("---")
21
+ st.text('Detected Dawgs')
22
+ img=st.image('/Users/eemanmajumder/code_shit/Project_Exibition/runs/detect/exp/seesh.png')
23
+ names= [ 'person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light',
24
+ 'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow',
25
+ 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee',
26
+ 'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard',
27
+ 'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple',
28
+ 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch',
29
+ 'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone',
30
+ 'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear',
31
+ 'hair drier', 'toothbrush' ]
32
+ len(names)
33
+ d= {}
34
+
35
+ for i in range(0,len(names)):
36
+ d[names[i]]=i
37
+ f=open("/Users/eemanmajumder/code_shit/Project_Exibition/runs/detect/exp/labels/seesh.txt",'r')
38
+ a=f.readlines()
39
+ b=[]
40
+ for j in range(0,len(a)):
41
+ if a[j][0:2] == '16':
42
+ b.append('yass')
43
+ else:
44
+ continue
45
+ print(len(b))
46
+ f=open("/Users/eemanmajumder/code_shit/Project_Exibition/runs/detect/exp/labels/seesh.txt",'w')
47
+ st.balloons()
48
+ st.success(f'Total Number Of Dogs Detected: {len(b)}')
49
+ st.markdown("---")
50
+ g = geocoder.ip('me')
51
+ print(g.latlng)
52
+
53
+ with open('database/cord.csv', 'a') as f_object:
54
+ writer_object = writer(f_object)
55
+ writer_object.writerow(g.latlng)
56
+ f_object.close()
57
+ df=pd.read_csv('database/cord.csv')
58
+ cum=len(df['lat'])
59
+ # df.to_csv('database/cord.csv',index=False)
60
+ st.text(f'Your Location Coordinates: {g.latlng}')
61
+ st.map(df,use_container_width=True,zoom = 4)
62
+ st.markdown(f"<h5 style='color: red;'>Total Number Of Reports Around The World: {cum}<h5>", unsafe_allow_html=True)
63
+
64
+ clicked= st.button('Click Me For Balloons',help='Click here to feel happy 😁')
65
+ if clicked==True:
66
+ st.balloons()