File tree 7 files changed +28
-31
lines changed
7 files changed +28
-31
lines changed Original file line number Diff line number Diff line change 1
1
.cache
2
- __pycache__
2
+ __pycache__
3
+ idle_models
Original file line number Diff line number Diff line change 2
2
"classes" : [
3
3
67
4
4
],
5
- "iou_thres" : 0.5 ,
6
- "conf_thres" : 0.3 ,
7
- "model_path" : " idle_models/idle_v0.3.11.pt" ,
8
5
"wait_time" : 10 ,
9
6
"threshold" : 100
10
7
}
Original file line number Diff line number Diff line change 1
1
username = ' admin'
2
2
password = ' just4Taqtile'
3
3
camera_url = ' http://192.168.1.162/onvif-http/snapshot?Profile_1'
4
- server_url = ' http://192.168.1.999 '
4
+ server_url = ' http://127.0.0.1 '
5
5
folder = ' images/192.168.1.163'
Original file line number Diff line number Diff line change 9
9
import requests
10
10
import httplib2
11
11
import numpy as np
12
- from idle_models .IdleObjectDetectionModel import IdleObjectDetectionModel
13
12
import time
14
- from dotenv import load_dotenv
15
13
16
14
17
15
def create_logger ():
@@ -34,9 +32,6 @@ def create_logger():
34
32
35
33
def init_connection ():
36
34
password = os .environ .get ("password" )
37
- if password is None :
38
- load_dotenv ("confs/settings.env" )
39
- password = os .environ .get ("password" )
40
35
username = os .environ .get ("username" )
41
36
try :
42
37
h = httplib2 .Http (".cache" )
@@ -47,16 +42,6 @@ def init_connection():
47
42
return None
48
43
49
44
50
- def init_model ():
51
- model = IdleObjectDetectionModel (
52
- MODEL_PATH ,
53
- CONF_THRES ,
54
- IOU_THRES ,
55
- CLASSES
56
- )
57
- return model
58
-
59
-
60
45
def get_frame (h ):
61
46
try :
62
47
time_ = datetime .datetime .now ()
Original file line number Diff line number Diff line change 1
1
import time
2
2
from functional import *
3
+ from send_request import predict
4
+ from dotenv import load_dotenv
3
5
4
6
7
+ password = os .environ .get ("password" )
8
+ if password is None :
9
+ load_dotenv ("confs/settings.env" )
5
10
logger = create_logger ()
6
11
7
12
8
13
def run ():
14
+ server_url = os .environ .get ("server_url" )
9
15
while (h := init_connection ()) is None :
10
16
logger .warning ("Cannot create connection" )
11
17
time .sleep (1 )
12
- model = init_model ()
13
- logger .info ("Model is initialized" )
14
18
prev_preds = None
15
19
iter_idx = 0
16
20
while True :
@@ -24,8 +28,8 @@ def run():
24
28
time .sleep (1 )
25
29
continue
26
30
time .sleep (2 )
27
- preds , scores = model (img )
28
- img = put_rectangle (img , preds . numpy () , scores . numpy () )
31
+ preds , scores = predict (img , server_url )
32
+ img = put_rectangle (img , preds , scores )
29
33
if len (scores ) > 0 :
30
34
logger .info ("Telephone is detected" )
31
35
if check_coordinates_diffs (prev_preds , preds ):
Original file line number Diff line number Diff line change 1
1
colorlog == 4.8.0
2
2
httplib2 == 0.22.0
3
- matplotlib == 3.6.3
4
3
numpy == 1.22.3
5
- onnx == 1.13.1
6
4
opencv_python == 4.7.0.72
7
5
pafy == 0.5.5
8
- pandas == 1.5.3
9
6
Pillow == 9.5.0
10
7
pydantic == 1.10.2
11
8
python-dotenv == 1.0.0
12
9
PyYAML == 6.0
13
10
requests == 2.27.1
14
- scipy == 1.10.1
15
- seaborn == 0.12.2
16
- tqdm == 4.64.1
17
- ultralytics == 8.0.112
Original file line number Diff line number Diff line change
1
+ import requests
2
+ import numpy as np
3
+
4
+
5
+ PORT = 5000
6
+
7
+
8
+ def predict (img : np .array , server_url : str ):
9
+ response = requests .post (
10
+ f"{ server_url } :{ PORT } /predict" ,
11
+ json = {
12
+ "image" : img .tolist ()
13
+ }
14
+ )
15
+ coordinates = np .array (response .json ().get ("coordinates" ))
16
+ confidences = np .array (response .json ().get ("confidences" ))
17
+ return [coordinates , confidences ]
You can’t perform that action at this time.
0 commit comments