This repository was archived by the owner on May 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsettings.py
More file actions
47 lines (38 loc) · 1.38 KB
/
settings.py
File metadata and controls
47 lines (38 loc) · 1.38 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
40
41
42
43
44
45
46
47
from ultralytics import YOLO
class Settings:
#Default settings
def __init__(self):
self.width = None
self.height = None
self.frame_rate = None
self.conf = 0.4
#Settings handling for custom settings
def update(self, width, height, frame_rate, conf):
self.width = int(width) if width not in (None, '') else None
self.height = int(height) if height not in (None, '') else None
self.frame_rate = int(frame_rate) if frame_rate not in (None, '') else None
self.conf = float(conf) if conf not in (None, '') else 0.4
#Reset back to default settings
def reset(self):
self.width = None
self.height = None
self.frame_rate = None
self.conf = 0.4
#Switch model
class ModelSwitch:
#Default model is v8n
def __init__(self):
self.model_path = 'model/bestv8n.engine'
self.load_model()
#Loading models
def load_model(self):
self.model = YOLO(self.model_path, task='detect')
#Model switch & load model
def switch_model(self, name):
if name == 'v8n':
self.model_path = 'model/bestv8n.engine'
elif name == 'v8x':
self.model_path = 'model/bestv8x.engine'
self.load_model()
settings = Settings()
model_switch = ModelSwitch()