forked from SunOner/sunone_aimbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
71 lines (61 loc) · 1.96 KB
/
run.py
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from ultralytics import YOLO
import torch
from logic.config_watcher import cfg
from logic.capture import capture
from logic.visual import visuals
from logic.frame_parser import frameParser
from logic.hotkeys_watcher import hotkeys_watcher
@torch.no_grad()
def perform_detection(model, image, clss):
return model.predict(
source=image,
stream=True,
cfg='logic/game.yaml',
imgsz=480,
stream_buffer=False,
visualize=False,
augment=False,
agnostic_nms=False,
save=False,
conf=cfg.AI_conf,
iou=0.3,
device=cfg.AI_device,
half=False if 'cpu' in cfg.AI_device else True,
max_det=25,
vid_stride=False,
classes=clss,
verbose=False,
show_boxes=False,
show_labels=False,
show_conf=False,
show=False)
def print_startup_messages():
version = 0
try:
with open('./version', 'r') as f:
lines = f.read().split('\n')
version = lines[0].split('=')[1]
except:
print('(version file is not found)')
print(f'Yolov8 Aimbot is started! (Version {version})\n\n',
'Hotkeys:\n',
f'[{cfg.hotkey_targeting}] - Aiming at the target\n',
f'[{cfg.hotkey_exit}] - EXIT\n',
f'[{cfg.hotkey_pause}] - PAUSE AIM\n',
f'[{cfg.hotkey_reload_config}] - Reload config\n')
def init():
try:
model = YOLO(f'models/{cfg.AI_model_name}', task='detect')
print_startup_messages()
except Exception as e:
print('An error occurred when loading the AI model:\n', e)
quit(0)
while True:
image = capture.get_new_frame()
if cfg.show_window:
visuals.queue.put(image)
result = perform_detection(model, image, hotkeys_watcher.clss)
if hotkeys_watcher.app_pause == 0:
frameParser.parse(result)
if __name__ == "__main__":
init()