Skip to content
TheChatArchiveThe Chat Archive
gpt-4o-2024-05-13· OpenAIAi2 WildChat-4.8M (AI2)

import numpy as np from termcolor import colored import timeit import threading # thread…

  1. User

    import numpy as np from termcolor import colored import timeit import threading # thread -> threading import imutils import time import mss import cv2 import os import signal import sys import pynput import ctypes import pyautogui from lib.grab import grab_screen

    import win32gui import win32api import win32con import mouse import keyboard

    sct = mss.mss() Wd, Hd = sct.monitors[1]["width"], sct.monitors[1]["height"] SendInput = ctypes.windll.user32.SendInput PUL = ctypes.POINTER(ctypes.c_ulong)

    class KeyBdInput(ctypes.Structure): fields = [("wVk", ctypes.c_ushort), ("wScan", ctypes.c_ushort), ("dwFlags", ctypes.c_ulong), ("time", ctypes.c_ulong), ("dwExtraInfo", PUL)] class HardwareInput(ctypes.Structure): fields = [("uMsg", ctypes.c_ulong), ("wParamL", ctypes.c_short), ("wParamH", ctypes.c_ushort)] class MouseInput(ctypes.Structure): fields = [("dx", ctypes.c_long), ("dy", ctypes.c_long), ("mouseData", ctypes.c_ulong), ("dwFlags", ctypes.c_ulong), ("time", ctypes.c_ulong), ("dwExtraInfo", PUL)] class Input_I(ctypes.Union): fields = [("ki", KeyBdInput), ("mi", MouseInput), ("hi", HardwareInput)] class Input(ctypes.Structure): fields = [("type", ctypes.c_ulong), ("ii", Input_I)]

    def set_pos(x, y): if mouse.is_pressed(button='left') or keyboard.is_pressed('alt'): x = int(x - (Wd / 2)) y = int(y - (Hd / 2))

        extra = ctypes.c_ulong(0)
        ii = pynput._util.win32.INPUT_union()
        ii.mi = pynput._util.win32.MOUSEINPUT(x, y, 0, (0x0001 | 0x8000), 0, ctypes.cast(ctypes.pointer(extra), ctypes.c_void_p))
        command = pynput._util.win32.INPUT(ctypes.c_ulong(0), ii)
        SendInput(1, ctypes.pointer(command), ctypes.sizeof(command))
    

    if name == "main": print("Do not run this file directly.")

    def start(ENABLE_AIMBOT):

    # Config
    #YOLO_DIRECTORY = "models"
    #CONFIDENCE = 0.20 #Reduzir CONFIDENCE permitirá que o modelo detecte mais objetos, mas pode aumentar os falsos positivos:
    #THRESHOLD = 0.01
    #THRESHOLD = 0.22 Estava usando esete antes de 0.01
    
    
    # Config
    YOLO_DIRECTORY = "models"
    CONFIDENCE = 0.25 #Reduzir CONFIDENCE permitirá que o modelo detecte mais objetos, mas pode aumentar os falsos positivos:
    THRESHOLD = 0.05
    #THRESHOLD = 0.22 Estava usando esete antes de 0.01
    
    
    
    
    #
    #   Size (in pixels) of the screen capture box to feed the neural net.
    #   This box is in the center of your screen. Lower value makes the network faster.
    #
    #   Example: "ACTIVATION_RANGE = 400" means a 400x400 pixel box.
    #
    ACTIVATION_RANGE = 200
    
    # load the COCO class labels our YOLO model was trained on
    labelsPath = os.path.sep.join([YOLO_DIRECTORY, "obj.names"])
    LABELS = open(labelsPath).read().strip().split("\n")
    
    # initialize a list of colors to represent each possible class label
    np.random.seed(42)
    COLORS = np.random.randint(0, 255, size=(len(LABELS), 3),
                               dtype="uint8")
    
    # derive the paths to the YOLO weights and model configuration
    weightsPath = os.path.sep.join([YOLO_DIRECTORY, "PESOCNN/yolov4.weights"])
    configPath = os.path.sep.join([YOLO_DIRECTORY, "PESOCNN/yolov4.cfg"])
    
    # Wait for buffering
    time.sleep(0.4)
    
    # load our YOLO object detector trained on COCO dataset (80 classes)
    # and determine only the output layer names that we need from YOLO
    print("[INFO] loading neural-network from disk…")
    net = cv2.dnn.readNetFromDarknet(configPath, weightsPath)
    
    # Check if GPU is available and use it
    if cv2.cuda.getCudaEnabledDeviceCount() > 0:
        print(colored("[OKAY] CUDA GPU Detected!", "green"))
        net.setPreferableBackend(cv2.dnn.DNN_BACKEND_CUDA)
        net.setPreferableTarget(cv2.dnn.DNN_TARGET_CUDA)
    elif cv2.ocl.haveOpenCL():
        print(colored("[OKAY] OpenCL GPU Detected!", "green"))
        net.setPreferableBackend(cv2.dnn.DNN_BACKEND_DEFAULT)
        net.setPreferableTarget(cv2.dnn.DNN_TARGET_OPENCL)
    else:
        print(colored("[WARNING] No GPU detected, using CPU.", "yellow"))
        net.setPreferableBackend(cv2.dnn.DNN_BACKEND_DEFAULT)
        net.setPreferableTarget(cv2.dnn.DNN_TARGET_CPU)
    
    ln = net.getLayerNames()
    ln = [ln[i - 1] for i in net.getUnconnectedOutLayers()]
    
    # Define screen capture area
    print("[INFO] loading screencapture device…")
    W, H = None, None
    origbox = (int(Wd/2 - ACTIVATION_RANGE/2),
               int(Hd/2 - ACTIVATION_RANGE/2),
               int(Wd/2 + ACTIVATION_RANGE/2),
               int(Hd/2 + ACTIVATION_RANGE/2))
    
    # Log whether aimbot is enabled
    if not ENABLE_AIMBOT:
        print("[INFO] aimbot disabled, using visualizer only…")
    else:
        print(colored("[OKAY] Aimbot enabled!", "green"))
    
    # Handle Ctrl+C in terminal, release pointers
    def signal_handler(sig, frame):
        # release the file pointers
        print("\n[INFO] cleaning up…")
        sct.close()  # .exit() does not exist for mss.mss()
        cv2.destroyAllWindows()
        sys.exit(0)
    signal.signal(signal.SIGINT, signal_handler)
    
    print()
    
    # loop over frames from the video file stream
    while True:
        start_time = timeit.default_timer()
        frame = np.array(grab_screen(region=origbox))
        frame = cv2.cvtColor(frame, cv2.COLOR_RGBA2BGR)
    
        # if the frame dimensions are empty, grab them
        if W is None or H is None:
            (H, W) = frame.shape[: 2]
    
        frame = cv2.UMat(frame)
    
        # construct a blob from the input frame and then perform a forward
        # pass of the YOLO object detector, giving us our bounding boxes
        # and associated probabilities
        blob = cv2.dnn.blobFromImage(frame, 1/260, (150, 150), 
                                     swapRB=True, crop=True)
        net.setInput(blob)
        layerOutputs = net.forward(ln)
    
        # initialize our lists of detected bounding boxes, confidences,
        # and class IDs, respectively
        boxes = []
        confidences = []
        classIDs = []
    
        # loop over each of the layer outputs
        for output in layerOutputs:
            # loop over each of the detections
            for detection in output:
                # extract the class ID and confidence (i.e., probability)
                # of the current object detection
                scores = detection[5:]
                classID = 0  # person = 0
                confidence = scores[classID]
    
                # filter out weak predictions by ensuring the detected
                # probability is greater than the minimum probability
                if confidence > CONFIDENCE:
                    box = detection[0: 4] * np.array([W, H, W, H])
                    (centerX, centerY, width, height) = box.astype("int")
    
                    # use the center (x, y)-coordinates to derive the top
                    # and and left corner of the bounding box
                    x = int(centerX - (width / 2))
                    y = int(centerY - (height / 2))
    
                    # update our list of bounding box coordinates,
                    # confidences, and class IDs
                    boxes.append([x, y, int(width), int(height)])
                    confidences.append(float(confidence))
                    classIDs.append(classID)
    
        # apply non-maxima suppression to suppress weak, overlapping
        # bounding boxes
        idxs = cv2.dnn.NMSBoxes(boxes, confidences, CONFIDENCE, THRESHOLD)
    
        # ensure at least one detection exists
        if len(idxs) > 0:
            # Find best player match
            bestMatch = confidences[np.argmax(confidences)]
    
            # loop over the indexes we are keeping
            for i in idxs.flatten():
                # extract the bounding box coordinates
                (x, y) = (boxes[i][0], boxes[i][1])
                (w, h) = (boxes[i][2], boxes[i][3])
    
                # draw target dot on the frame
                cv2.circle(frame, (int(x + w / 2), int(y + h / 3)), 2, (0, 0, 255), -1)
    
                # draw a bounding box rectangle and label on the frame
                cv2.rectangle(frame, (x, y),
                                (x + w, y + h), (0, 255, 0), 1)
    
                text = "enemy {}%".format(int(confidences[i] * 100))
                cv2.putText(frame, text, (x, y - 5),
                            cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2)
    
                if ENABLE_AIMBOT and bestMatch == confidences[i]:
                    mouseX = origbox[0] + (x + w/1.55)
                    mouseY = origbox[1] + (y + h/2.50)
                    set_pos(mouseX, mouseY)
    
        cv2.imshow("Neural Net Vision (Pine)", frame)
        elapsed = timeit.default_timer() - start_time
        sys.stdout.write(
            "\r{1} FPS with {0} MS interpolation delay \t".format(int(elapsed*1000), int(1/elapsed)))
        sys.stdout.flush()
        if cv2.waitKey(1) & 0xFF == ord('0'):
            break
    
    # Clean up on exit
    signal_handler(0, 0)
    

    meu codigo acima erro aaixo:

    ============================================================== Pine: Neural-Network Aimbot (v2.0 by Wendel for Apex Legends)

    [INFO] press '0' to quit or ctrl+C in console... [INFO] loading neural-network from disk… [OKAY] OpenCL GPU Detected! [INFO] loading screencapture device… [OKAY] Aimbot enabled!

    [ERROR:0@1.735] global net_impl.cpp:1165 cv::dnn::dnn4_v20240521::Net::Impl::getLayerShapesRecursively OPENCV/DNN: [Concat]:(concat_131): getMemoryShapes() throws exception. inputs=2 outputs=1/1 blobs=0 [ERROR:0@1.741] global net_impl.cpp:1168 cv::dnn::dnn4_v20240521::Net::Impl::getLayerShapesRecursively input[0] = [ 1 128 19 19 ] [ERROR:0@1.747] global net_impl.cpp:1168 cv::dnn::dnn4_v20240521::Net::Impl::getLayerShapesRecursively input[1] = [ 1 128 20 20 ] [ERROR:0@1.752] global net_impl.cpp:1172 cv::dnn::dnn4_v20240521::Net::Impl::getLayerShapesRecursively output[0] = [ 1 128 19 19 ] [ERROR:0@1.756] global net_impl.cpp:1178 cv::dnn::dnn4_v20240521::Net::Impl::getLayerShapesRecursively Exception message: OpenCV(4.10.0) D:\a\opencv-python\opencv-python\opencv\modules\dnn\src\layers\concat_layer.cpp:108: error: (-201:Incorrect size of input array) Inconsistent shape for ConcatLayer in function 'cv::dnn::ConcatLayerImpl::getMemoryShapes'

    Traceback (most recent call last): File "C:\Users\Wendel\Desktop\Apex_Aimbot_PY\para_vender_HWID_Local\pine.py", line 14, in pine.start(ENABLE_AIMBOT=True) File "C:\Users\Wendel\Desktop\Apex_Aimbot_PY\para_vender_HWID_Local\lib\pine.py", line 174, in start layerOutputs = net.forward(ln) ^^^^^^^^^^^^^^^ cv2.error: OpenCV(4.10.0) D:\a\opencv-python\opencv-python\opencv\modules\dnn\src\layers\concat_layer.cpp:108: error: (-201:Incorrect size of input array) Inconsistent shape for ConcatLayer in function 'cv::dnn::ConcatLayerImpl::getMemoryShapes'

    PS C:\Users\Wendel\Desktop\Apex_Aimbot_PY\para_vender_HWID_Local>

  2. Assistant

    The error message you're encountering is related to a problem in the cv2.dnn module when it tries to concatenate inputs of different shapes. This typically happens because the inputs to a ConcatLayer are expected to have the same height and width but, in this case, they do not.

    Here are some possible steps to resolve this issue:

    1. Check the Configuration and Model Files

    Ensure that the configuration file (yolov4.cfg) and weights file (yolov4.weights) are compatible with each other. If there is any mismatch, it might throw such errors.

    2. Update OpenCV

    Make sure you are using the latest versions of OpenCV and its dependencies. Sometimes, updating to the latest version can resolve unexpected issues.

    You can update OpenCV using pip:

    pip install --upgrade opencv-python opencv-python-headless
    

    3. Validate Custom Configurations

    If you are using a custom YOLO model, ensure that the custom configuration files (.cfg and corresponding .weights) are correctly specified and compatible.

    4. Check Input Sizes

    Ensure the input size of the blob matches what the neural network expects. You might need to adjust your input dimensions.

    blob = cv2.dnn.blobFromImage(frame, 1/260, (416, 416), swapRB=True, crop=False)
    

    Make sure the dimensions (416, 416) match what is specified in your model configuration file.

    5. Debug Specific Layer

    The error message indicates an issue specifically with the ConcatLayer. Debug each layer of the network to ensure it is working correctly.

    Example of How to Debug Layers

    for layer in ln:
        try:
            layerOutput = net.forward(layer)
            print(f"Layer {layer} executed successfully.")
        except cv2.error as e:
            print(f"Error in layer {layer}: {e}")
            break
    

    Revised Example Code

    Here is an updated version of your existing code which includes some checks:

    # Other imports and initializations remain unchanged
    
    if __name__ == "__main__":
        print("Do not run this file directly.")
    
    def start(ENABLE_AIMBOT):
        YOLO_DIRECTORY = "models"
        CONFIDENCE = 0.25  # Assuming it's 25%
        THRESHOLD = 0.05
        ACTIVATION_RANGE = 200
    
        labelsPath = os.path.sep.join([YOLO_DIRECTORY, "obj.names"])
        LABELS = open(labelsPath).read().strip().split("\n")
    
        np.random.seed(42)
        COLORS = np.random.randint(0, 255, size=(len(LABELS), 3), dtype="uint8")
    
        weightsPath = os.path.sep.join([YOLO_DIRECTORY, "PESOCNN/yolov4.weights"])
        configPath = os.path.sep.join([YOLO_DIRECTORY, "PESOCNN/yolov4.cfg"])
    
        time.sleep(0.4)
    
        print("[INFO] loading neural-network from disk…")
        net = cv2.dnn.readNetFromDarknet(configPath, weightsPath)
    
        if cv2.cuda.getCudaEnabledDeviceCount() > 0:
            print(colored("[OKAY] CUDA GPU Detected!", "green"))
            net.setPreferableBackend(cv2.dnn.DNN_BACKEND_CUDA)
            net.setPreferableTarget(cv2.dnn.DNN_TARGET_CUDA)
        elif cv2.ocl.haveOpenCL():
            print(colored("[OKAY] OpenCL GPU Detected!", "green"))
            net.setPreferableBackend(cv2.dnn.DNN_BACKEND_DEFAULT)
            net.setPreferableTarget(cv2.dnn.DNN_TARGET_OPENCL)
        else:
            print(colored("[WARNING] No GPU detected, using CPU.", "yellow"))
            net.setPreferableBackend(cv2.dnn.DNN_BACKEND_DEFAULT)
            net.setPreferableTarget(cv2.dnn.DNN_TARGET_CPU)
    
        ln = net.getLayerNames()
        ln = [ln[i - 1] for i in net.getUnconnectedOutLayers()]
    
        print("[INFO] loading screencapture device…")
        W, H = None, None
        origbox = (int(Wd/2 - ACTIVATION_RANGE/2), int(Hd/2 - ACTIVATION_RANGE/2), int(Wd/2 + ACTIVATION_RANGE/2), int(Hd/2 + ACTIVATION_RANGE/2))
    
        if not ENABLE_AIMBOT:
            print("[INFO] aimbot disabled, using visualizer only…")
        else:
            print(colored("[OKAY] Aimbot enabled!", "green"))
    
        def signal_handler(sig, frame):
            print("\n[INFO] cleaning up…")
            sct.close()
            cv2.destroyAllWindows()
            sys.exit(0)
        signal.signal(signal.SIGINT, signal_handler)
    
        print()
    
        while True:
            start_time = timeit.default_timer()
            frame = np.array(grab_screen(region=origbox))
            frame = cv2.cvtColor(frame, cv2.COLOR_RGBA2BGR)
            if W is None or H is None:
                (H, W) = frame.shape[:2]
    
            frame = cv2.UMat(frame)
            blob = cv2.dnn.blobFromImage(frame, 1/260, (416, 416), swapRB=True, crop=False)
            net.setInput(blob)
    
            try:
                layerOutputs = net.forward(ln)
            except cv2.error as e:
                print(f"Error in forward pass: {e}")
                break
    
            boxes = []
            confidences = []
            classIDs = []
    
            for output in layerOutputs:
                for detection in output:
                    scores = detection[5:]
                    classID = 0
                    confidence = scores[classID]
    
                    if confidence > CONFIDENCE:
                        box = detection[0:4] * np.array([W, H, W, H])
                        (centerX, centerY, width, height) = box.astype("int")
                        x = int(centerX - (width / 2))
                        y = int(centerY - (height / 2))
    
                        boxes.append([x, y, int(width), int(height)])
                        confidences.append(float(confidence))
                        classIDs.append(classID)
    
            idxs = cv2.dnn.NMSBoxes(boxes, confidences, CONFIDENCE, THRESHOLD)
    
            if len(idxs) > 0:
                bestMatch = confidences[np.argmax(confidences)]
                for i in idxs.flatten():
                    (x, y) = (boxes[i][0], boxes[i][1])
                    (w, h) = (boxes[i][2], boxes[i][3])
                    cv2.circle(frame, (int(x + w / 2), int(y + h / 3)), 2, (0, 0, 255), -1)
                    cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 1)
                    text = "enemy {}%".format(int(confidences[i] * 100))
                    cv2.putText(frame, text, (x, y - 5), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2)
                    if ENABLE_AIMBOT and bestMatch == confidences[i]:
                        mouseX = origbox[0] + (x + w/1.55)
                        mouseY = origbox[1] + (y + h/2.50)
                        set_pos(mouseX, mouseY)
    
            cv2.imshow("Neural Net Vision (Pine)", frame)
            elapsed = timeit.default_timer() - start_time
            sys.stdout.write(f"\r{int(1/elapsed)} FPS with {int(elapsed*1000)} MS interpolation delay \t")
            sys.stdout.flush()
            if cv2.waitKey(1) & 0xFF == ord('0'):
                break
    
        signal_handler(0, 0)
    

    Try updating the input dimension in blobFromImage and handle potential errors to debug the specific layer causing issues. If problems persist, check your custom configurations and ensure all dependencies are up-to-date.

  3. User

    responda em posrtugues:

    erro:

    ============================================================== Pine: Neural-Network Aimbot (v2.0 by Wendel for Apex Legends)

    [INFO] press '0' to quit or ctrl+C in console... [INFO] loading neural-network from disk… [OKAY] OpenCL GPU Detected! [INFO] loading screencapture device… [OKAY] Aimbot enabled!

    [ERROR:0@2.207] global net_impl.cpp:1165 cv::dnn::dnn4_v20240521::Net::Impl::getLayerShapesRecursively OPENCV/DNN: [Concat]:(concat_131): getMemoryShapes() throws exception. inputs=2 outputs=1/1 blobs=0 [ERROR:0@2.215] global net_impl.cpp:1168 cv::dnn::dnn4_v20240521::Net::Impl::getLayerShapesRecursively input[0] = [ 1 128 19 19 ] [ERROR:0@2.220] global net_impl.cpp:1168 cv::dnn::dnn4_v20240521::Net::Impl::getLayerShapesRecursively input[1] = [ 1 128 20 20 ] [ERROR:0@2.225] global net_impl.cpp:1172 cv::dnn::dnn4_v20240521::Net::Impl::getLayerShapesRecursively output[0] = [ 1 128 19 19 ] [ERROR:0@2.230] global net_impl.cpp:1178 cv::dnn::dnn4_v20240521::Net::Impl::getLayerShapesRecursively Exception message: OpenCV(4.10.0) D:\a\opencv-python\opencv-python\opencv\modules\dnn\src\layers\concat_layer.cpp:108: error: (-201:Incorrect size of input array) Inconsistent shape for ConcatLayer in function 'cv::dnn::ConcatLayerImpl::getMemoryShapes'

    Traceback (most recent call last): File "C:\Users\Wendel\Desktop\Apex_Aimbot_PY\para_vender_HWID_Local\pine.py", line 14, in pine.start(ENABLE_AIMBOT=True) File "C:\Users\Wendel\Desktop\Apex_Aimbot_PY\para_vender_HWID_Local\lib\pine.py", line 174, in start layerOutputs = net.forward(ln) ^^^^^^^^^^^^^^^ cv2.error: OpenCV(4.10.0) D:\a\opencv-python\opencv-python\opencv\modules\dnn\src\layers\concat_layer.cpp:108: error: (-201:Incorrect size of input array) Inconsistent shape for ConcatLayer in function 'cv::dnn::ConcatLayerImpl::getMemoryShapes'

    meu codigo abaixo:

    import numpy as np from termcolor import colored import timeit import threading # thread -> threading import imutils import time import mss import cv2 import os import signal import sys import pynput import ctypes import pyautogui from lib.grab import grab_screen

    import win32gui import win32api import win32con import mouse import keyboard

    sct = mss.mss() Wd, Hd = sct.monitors[1]["width"], sct.monitors[1]["height"] SendInput = ctypes.windll.user32.SendInput PUL = ctypes.POINTER(ctypes.c_ulong)

    class KeyBdInput(ctypes.Structure): fields = [("wVk", ctypes.c_ushort), ("wScan", ctypes.c_ushort), ("dwFlags", ctypes.c_ulong), ("time", ctypes.c_ulong), ("dwExtraInfo", PUL)] class HardwareInput(ctypes.Structure): fields = [("uMsg", ctypes.c_ulong), ("wParamL", ctypes.c_short), ("wParamH", ctypes.c_ushort)] class MouseInput(ctypes.Structure): fields = [("dx", ctypes.c_long), ("dy", ctypes.c_long), ("mouseData", ctypes.c_ulong), ("dwFlags", ctypes.c_ulong), ("time", ctypes.c_ulong), ("dwExtraInfo", PUL)] class Input_I(ctypes.Union): fields = [("ki", KeyBdInput), ("mi", MouseInput), ("hi", HardwareInput)] class Input(ctypes.Structure): fields = [("type", ctypes.c_ulong), ("ii", Input_I)]

    def set_pos(x, y): if mouse.is_pressed(button='left') or keyboard.is_pressed('alt'): x = int(x - (Wd / 2)) y = int(y - (Hd / 2))

        extra = ctypes.c_ulong(0)
        ii = pynput._util.win32.INPUT_union()
        ii.mi = pynput._util.win32.MOUSEINPUT(x, y, 0, (0x0001 | 0x8000), 0, ctypes.cast(ctypes.pointer(extra), ctypes.c_void_p))
        command = pynput._util.win32.INPUT(ctypes.c_ulong(0), ii)
        SendInput(1, ctypes.pointer(command), ctypes.sizeof(command))
    

    if name == "main": print("Do not run this file directly.")

    def start(ENABLE_AIMBOT):

    # Config
    #YOLO_DIRECTORY = "models"
    #CONFIDENCE = 0.20 #Reduzir CONFIDENCE permitirá que o modelo detecte mais objetos, mas pode aumentar os falsos positivos:
    #THRESHOLD = 0.01
    #THRESHOLD = 0.22 Estava usando esete antes de 0.01
    
    
    # Config
    YOLO_DIRECTORY = "models"
    CONFIDENCE = 0.25 #Reduzir CONFIDENCE permitirá que o modelo detecte mais objetos, mas pode aumentar os falsos positivos:
    THRESHOLD = 0.05
    #THRESHOLD = 0.22 Estava usando esete antes de 0.01
    
    
    
    
    #
    #   Size (in pixels) of the screen capture box to feed the neural net.
    #   This box is in the center of your screen. Lower value makes the network faster.
    #
    #   Example: "ACTIVATION_RANGE = 400" means a 400x400 pixel box.
    #
    ACTIVATION_RANGE = 200
    
    # load the COCO class labels our YOLO model was trained on
    labelsPath = os.path.sep.join([YOLO_DIRECTORY, "obj.names"])
    LABELS = open(labelsPath).read().strip().split("\n")
    
    # initialize a list of colors to represent each possible class label
    np.random.seed(42)
    COLORS = np.random.randint(0, 255, size=(len(LABELS), 3),
                               dtype="uint8")
    
    # derive the paths to the YOLO weights and model configuration
    weightsPath = os.path.sep.join([YOLO_DIRECTORY, "PESOCNN/yolov4.weights"])
    configPath = os.path.sep.join([YOLO_DIRECTORY, "PESOCNN/yolov4.cfg"])
    
    # Wait for buffering
    time.sleep(0.4)
    
    # load our YOLO object detector trained on COCO dataset (80 classes)
    # and determine only the output layer names that we need from YOLO
    print("[INFO] loading neural-network from disk…")
    net = cv2.dnn.readNetFromDarknet(configPath, weightsPath)
    
    # Check if GPU is available and use it
    if cv2.cuda.getCudaEnabledDeviceCount() > 0:
        print(colored("[OKAY] CUDA GPU Detected!", "green"))
        net.setPreferableBackend(cv2.dnn.DNN_BACKEND_CUDA)
        net.setPreferableTarget(cv2.dnn.DNN_TARGET_CUDA)
    elif cv2.ocl.haveOpenCL():
        print(colored("[OKAY] OpenCL GPU Detected!", "green"))
        net.setPreferableBackend(cv2.dnn.DNN_BACKEND_DEFAULT)
        net.setPreferableTarget(cv2.dnn.DNN_TARGET_OPENCL)
    else:
        print(colored("[WARNING] No GPU detected, using CPU.", "yellow"))
        net.setPreferableBackend(cv2.dnn.DNN_BACKEND_DEFAULT)
        net.setPreferableTarget(cv2.dnn.DNN_TARGET_CPU)
    
    ln = net.getLayerNames()
    ln = [ln[i - 1] for i in net.getUnconnectedOutLayers()]
    
    # Define screen capture area
    print("[INFO] loading screencapture device…")
    W, H = None, None
    origbox = (int(Wd/2 - ACTIVATION_RANGE/2),
               int(Hd/2 - ACTIVATION_RANGE/2),
               int(Wd/2 + ACTIVATION_RANGE/2),
               int(Hd/2 + ACTIVATION_RANGE/2))
    
    # Log whether aimbot is enabled
    if not ENABLE_AIMBOT:
        print("[INFO] aimbot disabled, using visualizer only…")
    else:
        print(colored("[OKAY] Aimbot enabled!", "green"))
    
    # Handle Ctrl+C in terminal, release pointers
    def signal_handler(sig, frame):
        # release the file pointers
        print("\n[INFO] cleaning up…")
        sct.close()  # .exit() does not exist for mss.mss()
        cv2.destroyAllWindows()
        sys.exit(0)
    signal.signal(signal.SIGINT, signal_handler)
    
    print()
    
    # loop over frames from the video file stream
    while True:
        start_time = timeit.default_timer()
        frame = np.array(grab_screen(region=origbox))
        frame = cv2.cvtColor(frame, cv2.COLOR_RGBA2BGR)
    
        # if the frame dimensions are empty, grab them
        if W is None or H is None:
            (H, W) = frame.shape[: 2]
    
        frame = cv2.UMat(frame)
    
        # construct a blob from the input frame and then perform a forward
        # pass of the YOLO object detector, giving us our bounding boxes
        # and associated probabilities
        blob = cv2.dnn.blobFromImage(frame, 1/260, (150, 150), 
                                     swapRB=True, crop=True)
        net.setInput(blob)
        layerOutputs = net.forward(ln)
    
        # initialize our lists of detected bounding boxes, confidences,
        # and class IDs, respectively
        boxes = []
        confidences = []
        classIDs = []
    
        # loop over each of the layer outputs
        for output in layerOutputs:
            # loop over each of the detections
            for detection in output:
                # extract the class ID and confidence (i.e., probability)
                # of the current object detection
                scores = detection[5:]
                classID = 0  # person = 0
                confidence = scores[classID]
    
                # filter out weak predictions by ensuring the detected
                # probability is greater than the minimum probability
                if confidence > CONFIDENCE:
                    box = detection[0: 4] * np.array([W, H, W, H])
                    (centerX, centerY, width, height) = box.astype("int")
    
                    # use the center (x, y)-coordinates to derive the top
                    # and and left corner of the bounding box
                    x = int(centerX - (width / 2))
                    y = int(centerY - (height / 2))
    
                    # update our list of bounding box coordinates,
                    # confidences, and class IDs
                    boxes.append([x, y, int(width), int(height)])
                    confidences.append(float(confidence))
                    classIDs.append(classID)
    
        # apply non-maxima suppression to suppress weak, overlapping
        # bounding boxes
        idxs = cv2.dnn.NMSBoxes(boxes, confidences, CONFIDENCE, THRESHOLD)
    
        # ensure at least one detection exists
        if len(idxs) > 0:
            # Find best player match
            bestMatch = confidences[np.argmax(confidences)]
    
            # loop over the indexes we are keeping
            for i in idxs.flatten():
                # extract the bounding box coordinates
                (x, y) = (boxes[i][0], boxes[i][1])
                (w, h) = (boxes[i][2], boxes[i][3])
    
                # draw target dot on the frame
                cv2.circle(frame, (int(x + w / 2), int(y + h / 3)), 2, (0, 0, 255), -1)
    
                # draw a bounding box rectangle and label on the frame
                cv2.rectangle(frame, (x, y),
                                (x + w, y + h), (0, 255, 0), 1)
    
                text = "enemy {}%".format(int(confidences[i] * 100))
                cv2.putText(frame, text, (x, y - 5),
                            cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2)
    
                if ENABLE_AIMBOT and bestMatch == confidences[i]:
                    mouseX = origbox[0] + (x + w/1.55)
                    mouseY = origbox[1] + (y + h/2.50)
                    set_pos(mouseX, mouseY)
    
        cv2.imshow("Neural Net Vision (Pine)", frame)
        elapsed = timeit.default_timer() - start_time
        sys.stdout.write(
            "\r{1} FPS with {0} MS interpolation delay \t".format(int(elapsed*1000), int(1/elapsed)))
        sys.stdout.flush()
        if cv2.waitKey(1) & 0xFF == ord('0'):
            break
    
    # Clean up on exit
    signal_handler(0, 0)
    
  4. Assistant

    O erro que você está encontrando está relacionado ao uso do módulo cv2.dnn do OpenCV. Esse erro ocorre ao tentar concatenar entradas de diferentes formas em um ConcatLayer. Aqui estão algumas abordagens para resolver esse problema:

    1. Verifique os Arquivos de Configuração e Pesos

    Certifique-se de que os arquivos de configuração (yolov4.cfg) e pesos (yolov4.weights) são compatíveis entre si. Qualquer incompatibilidade pode causar esse tipo de erro.

    2. Atualize o OpenCV

    Certifique-se de que você está usando a versão mais recente do OpenCV e suas dependências. Às vezes, a atualização para a versão mais recente pode resolver problemas inesperados.

    Você pode atualizar o OpenCV usando pip:

    pip install --upgrade opencv-python opencv-python-headless
    

    3. Valide Configurações Customizadas

    Se você estiver usando um modelo YOLO customizado, verifique se os arquivos de configuração (.cfg e correspondentes .weights) estão corretamente especificados e são compatíveis.

    4. Verifique os Tamanhos de Entrada

    Verifique se o tamanho da entrada do blob corresponde ao que a rede neural espera. Você pode precisar ajustar as dimensões da entrada.

    blob = cv2.dnn.blobFromImage(frame, 1/255, (416, 416), swapRB=True, crop=False)
    

    Certifique-se de que as dimensões (416, 416) correspondem ao que está especificado no seu arquivo de configuração do modelo.

    5. Depure Camadas Específicas

    A mensagem de erro indica um problema especificamente com o ConcatLayer. Depure cada camada da rede para garantir que está funcionando corretamente.

    Exemplo de Como Depurar Camadas

    for layer in ln:
        try:
            layerOutput = net.forward(layer)
            print(f"Camada {layer} executada com sucesso.")
        except cv2.error as e:
            print(f"Erro na camada {layer}: {e}")
            break
    

    Código Revisado

    Aqui está uma versão atualizada do seu código com algumas verificações adicionais:

    # Outras importações e inicializações permanecem inalteradas
    
    if __name__ == "__main__":
        print("Do not run this file directly.")
    
    def start(ENABLE_AIMBOT):
        YOLO_DIRECTORY = "models"
        CONFIDENCE = 0.25  # Pressupondo que seja 25%
        THRESHOLD = 0.05
        ACTIVATION_RANGE = 200
    
        labelsPath = os.path.sep.join([YOLO_DIRECTORY, "obj.names"])
        LABELS = open(labelsPath).read().strip().split("\n")
    
        np.random.seed(42)
        COLORS = np.random.randint(0, 255, size=(len(LABELS), 3), dtype="uint8")
    
        weightsPath = os.path.sep.join([YOLO_DIRECTORY, "PESOCNN/yolov4.weights"])
        configPath = os.path.sep.join([YOLO_DIRECTORY, "PESOCNN/yolov4.cfg"])
    
        time.sleep(0.4)
    
        print("[INFO] loading neural-network from disk…")
        net = cv2.dnn.readNetFromDarknet(configPath, weightsPath)
    
        if cv2.cuda.getCudaEnabledDeviceCount() > 0:
            print(colored("[OKAY] CUDA GPU Detected!", "green"))
            net.setPreferableBackend(cv2.dnn.DNN_BACKEND_CUDA)
            net.setPreferableTarget(cv2.dnn.DNN_TARGET_CUDA)
        elif cv2.ocl.haveOpenCL():
            print(colored("[OKAY] OpenCL GPU Detected!", "green"))
            net.setPreferableBackend(cv2.dnn.DNN_BACKEND_DEFAULT)
            net.setPreferableTarget(cv2.dnn.DNN_TARGET_OPENCL)
        else:
            print(colored("[WARNING] No GPU detected, using CPU.", "yellow"))
            net.setPreferableBackend(cv2.dnn.DNN_BACKEND_DEFAULT)
            net.setPreferableTarget(cv2.dnn.DNN_TARGET_CPU)
    
        ln = net.getLayerNames()
        ln = [ln[i - 1] for i in net.getUnconnectedOutLayers()]
    
        print("[INFO] loading screencapture device…")
        W, H = None, None
        origbox = (int(Wd/2 - ACTIVATION_RANGE/2), int(Hd/2 - ACTIVATION_RANGE/2), int(Wd/2 + ACTIVATION_RANGE/2), int(Hd/2 + ACTIVATION_RANGE/2))
    
        if not ENABLE_AIMBOT:
            print("[INFO] aimbot disabled, using visualizer only…")
        else:
            print(colored("[OKAY] Aimbot enabled!", "green"))
    
        def signal_handler(sig, frame):
            print("\n[INFO] cleaning up…")
            sct.close()
            cv2.destroyAllWindows()
            sys.exit(0)
        signal.signal(signal.SIGINT, signal_handler)
    
        print()
    
        while True:
            start_time = timeit.default_timer()
            frame = np.array(grab_screen(region=origbox))
            frame = cv2.cvtColor(frame, cv2.COLOR_RGBA2BGR)
            if W is None ou H é None:
                (H, W) = frame.shape[:2]
    
            frame = cv2.UMat(frame)
            blob = cv2.dnn.blobFromImage(frame, 1/255, (416, 416), swapRB=True, crop=False)
            net.setInput(blob)
    
            try:
                layerOutputs = net.forward(ln)
            except cv2.error as e:
                print(f"Erro na passagem forward: {e}")
                break
    
            boxes = []
            confidences = []
            classIDs = []
    
            for output in layerOutputs:
                for detection in output:
                    scores = detection[5:]
                    classID = 0
                    confidence = scores[classID]
    
                    if confidence > CONFIDENCE:
                        box = detection[0:4] * np.array([W, H, W, H])
                        (centerX, centerY, width, height) = box.astype("int")
                        x = int(centerX - (width / 2))
                        y = int(centerY - (height / 2))
    
                        boxes.append([x, y, int(width), int(height)])
                        confidences.append(float(confidence))
                        classIDs.append(classID)
    
            idxs = cv2.dnn.NMSBoxes(boxes, confidences, CONFIDENCE, THRESHOLD)
    
            if len(idxs) > 0:
                bestMatch = confidences[np.argmax(confidences)]
                for i in idxs.flatten():
                    (x, y) = (boxes[i][0], boxes[i][1])
                    (w, h) = (boxes[i][2], boxes[i][3])
                    cv2.circle(frame, (int(x + w / 2), int(y + h / 3)), 2, (0, 0, 255), -1)
                    cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 1)
                    text = "enemy {}%".format(int(confidences[i] * 100))
                    cv2.putText(frame, text, (x, y - 5), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2)
                    if ENABLE_AIMBOT e bestMatch == confidences[i]:
                        mouseX = origbox[0] + (x + w/1.55)
                        mouseY = origbox[1] + (y + h/2.50)
                        set_pos(mouseX, mouseY)
    
            cv2.imshow("Neural Net Vision (Pine)", frame)
            elapsed = timeit.default_timer() - start_time
            sys.stdout.write(f"\r{int(1/elapsed)} FPS with {int(elapsed*1000)} MS interpolation delay \t")
            sys.stdout.flush()
            if cv2.waitKey(1) & 0xFF == ord('0'):
                break
    
        signal_handler(0, 0)
    

    Tente atualizar a dimensão de entrada em blobFromImage e tratar possíveis erros para depurar a camada específica que está causando problemas. Se os problemas persistirem, verifique suas configurações personalizadas e certifique-se de que todas as dependências estão atualizadas.

  5. User

    import numpy as np from termcolor import colored import timeit import threading # thread -> threading import imutils import time import mss import cv2 import os import signal import sys import pynput import ctypes import pyautogui from lib.grab import grab_screen

    import win32gui import win32api import win32con import mouse import keyboard

    sct = mss.mss() Wd, Hd = sct.monitors[1]["width"], sct.monitors[1]["height"] SendInput = ctypes.windll.user32.SendInput PUL = ctypes.POINTER(ctypes.c_ulong)

    class KeyBdInput(ctypes.Structure): fields = [("wVk", ctypes.c_ushort), ("wScan", ctypes.c_ushort), ("dwFlags", ctypes.c_ulong), ("time", ctypes.c_ulong), ("dwExtraInfo", PUL)] class HardwareInput(ctypes.Structure): fields = [("uMsg", ctypes.c_ulong), ("wParamL", ctypes.c_short), ("wParamH", ctypes.c_ushort)] class MouseInput(ctypes.Structure): fields = [("dx", ctypes.c_long), ("dy", ctypes.c_long), ("mouseData", ctypes.c_ulong), ("dwFlags", ctypes.c_ulong), ("time", ctypes.c_ulong), ("dwExtraInfo", PUL)] class Input_I(ctypes.Union): fields = [("ki", KeyBdInput), ("mi", MouseInput), ("hi", HardwareInput)] class Input(ctypes.Structure): fields = [("type", ctypes.c_ulong), ("ii", Input_I)]

    def set_pos(x, y): if mouse.is_pressed(button='left') or keyboard.is_pressed('alt'): x = int(x - (Wd / 2)) y = int(y - (Hd / 2))

        extra = ctypes.c_ulong(0)
        ii = pynput._util.win32.INPUT_union()
        ii.mi = pynput._util.win32.MOUSEINPUT(x, y, 0, (0x0001 | 0x8000), 0, ctypes.cast(ctypes.pointer(extra), ctypes.c_void_p))
        command = pynput._util.win32.INPUT(ctypes.c_ulong(0), ii)
        SendInput(1, ctypes.pointer(command), ctypes.sizeof(command))
    

    if name == "main": print("Do not run this file directly.")

    def start(ENABLE_AIMBOT):

    # Config
    #YOLO_DIRECTORY = "models"
    #CONFIDENCE = 0.20 #Reduzir CONFIDENCE permitirá que o modelo detecte mais objetos, mas pode aumentar os falsos positivos:
    #THRESHOLD = 0.01
    #THRESHOLD = 0.22 Estava usando esete antes de 0.01
    
    
    # Config
    YOLO_DIRECTORY = "models"
    CONFIDENCE = 0.25 #Reduzir CONFIDENCE permitirá que o modelo detecte mais objetos, mas pode aumentar os falsos positivos:
    THRESHOLD = 0.05
    #THRESHOLD = 0.22 Estava usando esete antes de 0.01
    
    
    
    
    #
    #   Size (in pixels) of the screen capture box to feed the neural net.
    #   This box is in the center of your screen. Lower value makes the network faster.
    #
    #   Example: "ACTIVATION_RANGE = 400" means a 400x400 pixel box.
    #
    ACTIVATION_RANGE = 200
    
    # load the COCO class labels our YOLO model was trained on
    labelsPath = os.path.sep.join([YOLO_DIRECTORY, "obj.names"])
    LABELS = open(labelsPath).read().strip().split("\n")
    
    # initialize a list of colors to represent each possible class label
    np.random.seed(42)
    COLORS = np.random.randint(0, 255, size=(len(LABELS), 3),
                               dtype="uint8")
    
    # derive the paths to the YOLO weights and model configuration
    weightsPath = os.path.sep.join([YOLO_DIRECTORY, "PESOCNN/yolov4.weights"])
    configPath = os.path.sep.join([YOLO_DIRECTORY, "PESOCNN/yolov4.cfg"])
    
    # Wait for buffering
    time.sleep(0.4)
    
    # load our YOLO object detector trained on COCO dataset (80 classes)
    # and determine only the output layer names that we need from YOLO
    print("[INFO] loading neural-network from disk…")
    net = cv2.dnn.readNetFromDarknet(configPath, weightsPath)
    
    # Check if GPU is available and use it
    if cv2.cuda.getCudaEnabledDeviceCount() > 0:
        print(colored("[OKAY] CUDA GPU Detected!", "green"))
        net.setPreferableBackend(cv2.dnn.DNN_BACKEND_CUDA)
        net.setPreferableTarget(cv2.dnn.DNN_TARGET_CUDA)
    elif cv2.ocl.haveOpenCL():
        print(colored("[OKAY] OpenCL GPU Detected!", "green"))
        net.setPreferableBackend(cv2.dnn.DNN_BACKEND_DEFAULT)
        net.setPreferableTarget(cv2.dnn.DNN_TARGET_OPENCL)
    else:
        print(colored("[WARNING] No GPU detected, using CPU.", "yellow"))
        net.setPreferableBackend(cv2.dnn.DNN_BACKEND_DEFAULT)
        net.setPreferableTarget(cv2.dnn.DNN_TARGET_CPU)
    
    ln = net.getLayerNames()
    ln = [ln[i - 1] for i in net.getUnconnectedOutLayers()]
    
    # Define screen capture area
    print("[INFO] loading screencapture device…")
    W, H = None, None
    origbox = (int(Wd/2 - ACTIVATION_RANGE/2),
               int(Hd/2 - ACTIVATION_RANGE/2),
               int(Wd/2 + ACTIVATION_RANGE/2),
               int(Hd/2 + ACTIVATION_RANGE/2))
    
    # Log whether aimbot is enabled
    def start(ENABLE_AIMBOT):
    YOLO_DIRECTORY = "models"
    CONFIDENCE = 0.25  # Pressupondo que seja 25%
    THRESHOLD = 0.05
    ACTIVATION_RANGE = 200
    
    labelsPath = os.path.sep.join([YOLO_DIRECTORY, "obj.names"])
    LABELS = open(labelsPath).read().strip().split("\n")
    
    np.random.seed(42)
    COLORS = np.random.randint(0, 255, size=(len(LABELS), 3), dtype="uint8")
    
    weightsPath = os.path.sep.join([YOLO_DIRECTORY, "PESOCNN/yolov4.weights"])
    configPath = os.path.sep.join([YOLO_DIRECTORY, "PESOCNN/yolov4.cfg"])
    
    time.sleep(0.4)
    
    print("[INFO] loading neural-network from disk…")
    net = cv2.dnn.readNetFromDarknet(configPath, weightsPath)
    
    if cv2.cuda.getCudaEnabledDeviceCount() > 0:
        print(colored("[OKAY] CUDA GPU Detected!", "green"))
        net.setPreferableBackend(cv2.dnn.DNN_BACKEND_CUDA)
        net.setPreferableTarget(cv2.dnn.DNN_TARGET_CUDA)
    elif cv2.ocl.haveOpenCL():
        print(colored("[OKAY] OpenCL GPU Detected!", "green"))
        net.setPreferableBackend(cv2.dnn.DNN_BACKEND_DEFAULT)
        net.setPreferableTarget(cv2.dnn.DNN_TARGET_OPENCL)
    else:
        print(colored("[WARNING] No GPU detected, using CPU.", "yellow"))
        net.setPreferableBackend(cv2.dnn.DNN_BACKEND_DEFAULT)
        net.setPreferableTarget(cv2.dnn.DNN_TARGET_CPU)
    
    ln = net.getLayerNames()
    ln = [ln[i - 1] for i in net.getUnconnectedOutLayers()]
    
    print("[INFO] loading screencapture device…")
    W, H = None, None
    origbox = (int(Wd/2 - ACTIVATION_RANGE/2), int(Hd/2 - ACTIVATION_RANGE/2), int(Wd/2 + ACTIVATION_RANGE/2), int(Hd/2 + ACTIVATION_RANGE/2))
    
    if not ENABLE_AIMBOT:
        print("[INFO] aimbot disabled, using visualizer only…")
    else:
        print(colored("[OKAY] Aimbot enabled!", "green"))
    
    def signal_handler(sig, frame):
        print("\n[INFO] cleaning up…")
        sct.close()
        cv2.destroyAllWindows()
        sys.exit(0)
    signal.signal(signal.SIGINT, signal_handler)
    
    print()
    
    while True:
        start_time = timeit.default_timer()
        frame = np.array(grab_screen(region=origbox))
        frame = cv2.cvtColor(frame, cv2.COLOR_RGBA2BGR)
        if W is None ou H é None:
            (H, W) = frame.shape[:2]
    
        frame = cv2.UMat(frame)
        blob = cv2.dnn.blobFromImage(frame, 1/255, (416, 416), swapRB=True, crop=False)
        net.setInput(blob)
    
        try:
            layerOutputs = net.forward(ln)
        except cv2.error as e:
            print(f"Erro na passagem forward: {e}")
            break
    
        boxes = []
        confidences = []
        classIDs = []
    
        for output in layerOutputs:
            for detection in output:
                scores = detection[5:]
                classID = 0
                confidence = scores[classID]
    
                if confidence > CONFIDENCE:
                    box = detection[0:4] * np.array([W, H, W, H])
                    (centerX, centerY, width, height) = box.astype("int")
                    x = int(centerX - (width / 2))
                    y = int(centerY - (height / 2))
    
                    boxes.append([x, y, int(width), int(height)])
                    confidences.append(float(confidence))
                    classIDs.append(classID)
    
        idxs = cv2.dnn.NMSBoxes(boxes, confidences, CONFIDENCE, THRESHOLD)
    
        if len(idxs) > 0:
            bestMatch = confidences[np.argmax(confidences)]
            for i in idxs.flatten():
                (x, y) = (boxes[i][0], boxes[i][1])
                (w, h) = (boxes[i][2], boxes[i][3])
                cv2.circle(frame, (int(x + w / 2), int(y + h / 3)), 2, (0, 0, 255), -1)
                cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 1)
                text = "enemy {}%".format(int(confidences[i] * 100))
                cv2.putText(frame, text, (x, y - 5), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2)
                if ENABLE_AIMBOT e bestMatch == confidences[i]:
                    mouseX = origbox[0] + (x + w/1.55)
                    mouseY = origbox[1] + (y + h/2.50)
                    set_pos(mouseX, mouseY)
    
        cv2.imshow("Neural Net Vision (Pine)", frame)
        elapsed = timeit.default_timer() - start_time
        sys.stdout.write(f"\r{int(1/elapsed)} FPS with {int(elapsed*1000)} MS interpolation delay \t")
        sys.stdout.flush()
        if cv2.waitKey(1) & 0xFF == ord('0'):
            break
    
    signal_handler(0, 0)
    

    erro abaixo:

    PS C:\Users\Wendel\Desktop\Apex_Aimbot_PY\para_vender_HWID_Local> python pine.py Traceback (most recent call last): File "C:\Users\Wendel\Desktop\Apex_Aimbot_PY\para_vender_HWID_Local\pine.py", line 1, in from lib import pine File "C:\Users\Wendel\Desktop\Apex_Aimbot_PY\para_vender_HWID_Local\lib\pine.py", line 141 YOLO_DIRECTORY = "models" ^ IndentationError: expected an indented block after function definition on line 140 PS C:\Users\Wendel\Desktop\Apex_Aimbot_PY\para_vender_HWID_Local>

  6. Assistant

    O erro "IndentationError: expected an indented block after function definition on line 140" indica que há um problema de indentação no código. Isso ocorre quando uma definição de função (def) é seguida por código que não está corretamente indentado.

    Aqui está a correção do bloco de código onde a indentação estava incorreta:

    def start(ENABLE_AIMBOT):
    
        # Config
        YOLO_DIRECTORY = "models"
        CONFIDENCE = 0.25 #Reduzir CONFIDENCE permitirá que o modelo detecte mais objetos, mas pode aumentar os falsos positivos:
        THRESHOLD = 0.05
        ACTIVATION_RANGE = 200
    
        # Carregar as etiquetas da classe COCO em que nosso modelo YOLO foi treinado
        labelsPath = os.path.sep.join([YOLO_DIRECTORY, "obj.names"])
        LABELS = open(labelsPath).read().strip().split("\n")
    
        # Inicializar uma lista de cores para representar cada etiqueta de classe possível
        np.random.seed(42)
        COLORS = np.random.randint(0, 255, size=(len(LABELS), 3), dtype="uint8")
    
        # Derivar os caminhos para os pesos do YOLO e configuração do modelo
        weightsPath = os.path.sep.join([YOLO_DIRECTORY, "PESOCNN/yolov4.weights"])
        configPath = os.path.sep.join([YOLO_DIRECTORY, "PESOCNN/yolov4.cfg"])
    
        # Esperar por buffering
        time.sleep(0.4)
    
        # Carregar nosso detector de objetos YOLO treinado no conjunto de dados COCO (80 classes)
        # e determinar apenas os nomes das camadas de saída que precisamos do YOLO
        print("[INFO] loading neural-network from disk…")
        net = cv2.dnn.readNetFromDarknet(configPath, weightsPath)
    
        # Verificar se a GPU está disponível e usá-la
        if cv2.cuda.getCudaEnabledDeviceCount() > 0:
            print(colored("[OKAY] CUDA GPU Detected!", "green"))
            net.setPreferableBackend(cv2.dnn.DNN_BACKEND_CUDA)
            net.setPreferableTarget(cv2.dnn.DNN_TARGET_CUDA)
        elif cv2.ocl.haveOpenCL():
            print(colored("[OKAY] OpenCL GPU Detected!", "green"))
            net.setPreferableBackend(cv2.dnn.DNN_BACKEND_DEFAULT)
            net.setPreferableTarget(cv2.dnn.DNN_TARGET_OPENCL)
        else:
            print(colored("[WARNING] No GPU detected, using CPU.", "yellow"))
            net.setPreferableBackend(cv2.dnn.DNN_BACKEND_DEFAULT)
            net.setPreferableTarget(cv2.dnn.DNN_TARGET_CPU)
    
        ln = net.getLayerNames()
        ln = [ln[i - 1] for i in net.getUnconnectedOutLayers()]
    
        # Definir a área de captura de tela
        print("[INFO] loading screencapture device…")
        W, H = None, None
        origbox = (int(Wd/2 - ACTIVATION_RANGE/2), int(Hd/2 - ACTIVATION_RANGE/2),
                   int(Wd/2 + ACTIVATION_RANGE/2), int(Hd/2 + ACTIVATION_RANGE/2))
    
        if not ENABLE_AIMBOT:
            print("[INFO] aimbot disabled, using visualizer only…")
        else:
            print(colored("[OKAY] Aimbot enabled!", "green"))
    
        def signal_handler(sig, frame):
            print("\n[INFO] cleaning up…")
            sct.close()
            cv2.destroyAllWindows()
            sys.exit(0)
    
        signal.signal(signal.SIGINT, signal_handler)
    
        print()
    
        while True:
            start_time = timeit.default_timer()
            frame = np.array(grab_screen(region=origbox))
            frame = cv2.cvtColor(frame, cv2.COLOR_RGBA2BGR)
            if W is None or H is None:
                (H, W) = frame.shape[:2]
    
            frame = cv2.UMat(frame)
            blob = cv2.dnn.blobFromImage(frame, 1/255, (416, 416), swapRB=True, crop=False)
            net.setInput(blob)
    
            try:
                layerOutputs = net.forward(ln)
            except cv2.error as e:
                print(f"Erro na passagem forward: {e}")
                break
    
            boxes = []
            confidences = []
            classIDs = []
    
            for output in layerOutputs:
                for detection in output:
                    scores = detection[5:]
                    classID = 0
                    confidence = scores[classID]
    
                    if confidence > CONFIDENCE:
                        box = detection[0:4] * np.array([W, H, W, H])
                        (centerX, centerY, width, height) = box.astype("int")
                        x = int(centerX - (width / 2))
                        y = int(centerY - (height / 2))
    
                        boxes.append([x, y, int(width), int(height)])
                        confidences.append(float(confidence))
                        classIDs.append(classID)
    
            idxs = cv2.dnn.NMSBoxes(boxes, confidences, CONFIDENCE, THRESHOLD)
    
            if len(idxs) > 0:
                bestMatch = confidences[np.argmax(confidences)]
                for i in idxs.flatten():
                    (x, y) = (boxes[i][0], boxes[i][1])
                    (w, h) = (boxes[i][2], boxes[i][3])
                    cv2.circle(frame, (int(x + w / 2), int(y + h / 3)), 2, (0, 0, 255), -1)
                    cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 1)
                    text = f"enemy {int(confidences[i] * 100)}%"
                    cv2.putText(frame, text, (x, y - 5), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2)
    
                    if ENABLE_AIMBOT and bestMatch == confidences[i]:
                        mouseX = origbox[0] + (x + w / 1.55)
                        mouseY = origbox[1] + (y + h / 2.50)
                        set_pos(mouseX, mouseY)
    
            cv2.imshow("Neural Net Vision (Pine)", frame)
            elapsed = timeit.default_timer() - start_time
            sys.stdout.write(f"\r{int(1/elapsed)} FPS with {int(elapsed*1000)} MS interpolation delay \t")
            sys.stdout.flush()
            if cv2.waitKey(1) & 0xFF == ord('0'):
                break
    
        signal_handler(0, 0)
    

    Notas:

    1. Certifique-se de que todas as linhas de código dentro da função start estejam corretamente indentadas com quatro espaços.
    2. A parte duplicada do código foi removida para evitar confusão.

    Você pode tentar rodar o script novamente após fazer essas correções. Qualquer outro erro ou problema, não hesite em comentar para que possamos ajudar.