Welcome.
My first post, Lets hope it ages like fine wine.
Today I present you an Auto Processor for AI detectors (I've used this script to train cheats for games like valorant / cs2.
import os
import cv2
import shutil
import random
from ultralytics import YOLO
# Config
BASE_DIR = os.path.dirname(__file__)
model_path = os.path.join(BASE_DIR, 'my_yolo_dataset', 'runs', 'detect', 'train', 'weights', 'best.pt')
image_dir = os.path.join(BASE_DIR, 'my_yolo_dataset', 'images', 'all')
confidence_threshold = 0.25
val_split = 0.2
class_id = 0 # Update if multiple classes
# Output folders
train_img_dir = os.path.join(BASE_DIR, 'my_yolo_dataset', 'images', 'train')
val_img_dir = os.path.join(BASE_DIR, 'my_yolo_dataset', 'images', 'val')
train_lbl_dir = os.path.join(BASE_DIR, 'my_yolo_dataset', 'labels', 'train')
val_lbl_dir = os.path.join(BASE_DIR, 'my_yolo_dataset', 'labels', 'val')
for d in [train_img_dir, val_img_dir, train_lbl_dir, val_lbl_dir]:
os.makedirs(d, exist_ok=True)
# Load model
if not os.path.exists(model_path):
raise FileNotFoundError(f"Model not found: {model_path}")
model = YOLO(model_path)
# Process Image
image_files = [f for f in os.listdir(image_dir) if f.lower().endswith(('.png', '.jpg', '.jpeg'))]
image_files.sort()
for fname in image_files:
img_path = os.path.join(image_dir, fname)
img = cv2.imread(img_path)
if img is None:
print(f"Could not load {fname}")
continue
# Run YOLO detection - Enable verboses for more information ik you will need it.
results = model(img, conf=confidence_threshold, verbose=False)[0]
# Draw boxes over detected.
for box in results.boxes:
x1, y1, x2, y2 = map(int, box.xyxy[0])
conf = float(box.conf[0])
cv2.rectangle(img, (x1, y1), (x2, y2), (0, 255, 0), 2)
cv2.putText(img, f"{conf:.2f}", (x1, y1 - 5), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 1)
cv2.imshow('Detection Viewer', img)
print(f"▶ {fname}: {len(results.boxes)} detections")
print("Press 'n' = skip, 'd' = delete, 'a' = accept/save, ESC = quit")
key = cv2.waitKey(0) & 0xFF
if key == 27:
break
elif key == ord('d'):
os.remove(img_path)
print(f"Deleted {fname}")
continue
elif key == ord('n'):
continue
elif key == ord('a'):
# Determine destination
is_val = random.random() < val_split
img_dst = os.path.join(val_img_dir if is_val else train_img_dir, fname)
lbl_dst = os.path.join(val_lbl_dir if is_val else train_lbl_dir, fname.rsplit('.', 1)[0] + '.txt')
# Write label file in YOLO format
h, w = img.shape[:2]
with open(lbl_dst, 'w') as f:
for box in results.boxes:
x1, y1, x2, y2 = map(float, box.xyxy[0])
xc = (x1 + x2) / 2 / w
yc = (y1 + y2) / 2 / h
bw = (x2 - x1) / w
bh = (y2 - y1) / h
f.write(f"{class_id} {xc:.6f} {yc:.6f} {bw:.6f} {bh:.6f}\n")
# Move image
shutil.move(img_path, img_dst)
print(f"Saved to {'val' if is_val else 'train'}: {fname}")
cv2.destroyAllWindows()
FAQ:
Why am I doing this? After the downfall of a forum I used to frequent I took a break and wanted to come back to a community.
Are you going to drop anyother tools of AI manner? Yes many more.
Who's these scripts mainly targetted towards? Anyone that has a brain to realize you need alot more then an auto processor to make a cheat.
THANK YOU AND HAVE A MONEYFULL DAY.
My first post, Lets hope it ages like fine wine.
Today I present you an Auto Processor for AI detectors (I've used this script to train cheats for games like valorant / cs2.
[ Hidden Content! ]
import os
import cv2
import shutil
import random
from ultralytics import YOLO
# Config
BASE_DIR = os.path.dirname(__file__)
model_path = os.path.join(BASE_DIR, 'my_yolo_dataset', 'runs', 'detect', 'train', 'weights', 'best.pt')
image_dir = os.path.join(BASE_DIR, 'my_yolo_dataset', 'images', 'all')
confidence_threshold = 0.25
val_split = 0.2
class_id = 0 # Update if multiple classes
# Output folders
train_img_dir = os.path.join(BASE_DIR, 'my_yolo_dataset', 'images', 'train')
val_img_dir = os.path.join(BASE_DIR, 'my_yolo_dataset', 'images', 'val')
train_lbl_dir = os.path.join(BASE_DIR, 'my_yolo_dataset', 'labels', 'train')
val_lbl_dir = os.path.join(BASE_DIR, 'my_yolo_dataset', 'labels', 'val')
for d in [train_img_dir, val_img_dir, train_lbl_dir, val_lbl_dir]:
os.makedirs(d, exist_ok=True)
# Load model
if not os.path.exists(model_path):
raise FileNotFoundError(f"Model not found: {model_path}")
model = YOLO(model_path)
# Process Image
image_files = [f for f in os.listdir(image_dir) if f.lower().endswith(('.png', '.jpg', '.jpeg'))]
image_files.sort()
for fname in image_files:
img_path = os.path.join(image_dir, fname)
img = cv2.imread(img_path)
if img is None:
print(f"Could not load {fname}")
continue
# Run YOLO detection - Enable verboses for more information ik you will need it.
results = model(img, conf=confidence_threshold, verbose=False)[0]
# Draw boxes over detected.
for box in results.boxes:
x1, y1, x2, y2 = map(int, box.xyxy[0])
conf = float(box.conf[0])
cv2.rectangle(img, (x1, y1), (x2, y2), (0, 255, 0), 2)
cv2.putText(img, f"{conf:.2f}", (x1, y1 - 5), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 1)
cv2.imshow('Detection Viewer', img)
print(f"▶ {fname}: {len(results.boxes)} detections")
print("Press 'n' = skip, 'd' = delete, 'a' = accept/save, ESC = quit")
key = cv2.waitKey(0) & 0xFF
if key == 27:
break
elif key == ord('d'):
os.remove(img_path)
print(f"Deleted {fname}")
continue
elif key == ord('n'):
continue
elif key == ord('a'):
# Determine destination
is_val = random.random() < val_split
img_dst = os.path.join(val_img_dir if is_val else train_img_dir, fname)
lbl_dst = os.path.join(val_lbl_dir if is_val else train_lbl_dir, fname.rsplit('.', 1)[0] + '.txt')
# Write label file in YOLO format
h, w = img.shape[:2]
with open(lbl_dst, 'w') as f:
for box in results.boxes:
x1, y1, x2, y2 = map(float, box.xyxy[0])
xc = (x1 + x2) / 2 / w
yc = (y1 + y2) / 2 / h
bw = (x2 - x1) / w
bh = (y2 - y1) / h
f.write(f"{class_id} {xc:.6f} {yc:.6f} {bw:.6f} {bh:.6f}\n")
# Move image
shutil.move(img_path, img_dst)
print(f"Saved to {'val' if is_val else 'train'}: {fname}")
cv2.destroyAllWindows()
FAQ:
Why am I doing this? After the downfall of a forum I used to frequent I took a break and wanted to come back to a community.
Are you going to drop anyother tools of AI manner? Yes many more.
Who's these scripts mainly targetted towards? Anyone that has a brain to realize you need alot more then an auto processor to make a cheat.
THANK YOU AND HAVE A MONEYFULL DAY.