didnt appear any boxes and the screen isnt the same color as the game, it's like reverted color still

import time
import os
import cv2
import pygetwindow as gw
from PIL import ImageGrab
import numpy as np
import torch

# Change the current working directory to the script's directory
os.chdir(os.path.dirname(os.path.abspath(__file__)))

MAX_EPISODE_LENGTH = 1000
FRAMES_DIRECTORY = r'C:\Users\Ninja.000\Downloads\SFD_AI\gameplay\Tutorial'

def is_game_open():
    game_window = gw.getWindowsWithTitle('Superfighters Deluxe')
    return bool(game_window)

def draw_boxes(window, local_player_box, enemy_box):
    frame = np.array(ImageGrab.grab(bbox=(window.left, window.top, window.right, window.bottom)))

    # Display the annotated frame without bounding boxes
    cv2.imshow("Annotated Frame", frame)
    cv2.waitKey(1)

    color = (0, 255, 0)  # Green color for bounding boxes (you can adjust this)

    if local_player_box is not None:
        x_lp, y_lp, w_lp, h_lp = local_player_box
        x_lp, y_lp, w_lp, h_lp = int(x_lp), int(y_lp), int(w_lp), int(h_lp)  # Convert to integers
        cv2.rectangle(frame, (x_lp, y_lp), (x_lp + w_lp, y_lp + h_lp), color, 2)
        cv2.putText(frame, "localPlayer", (x_lp, y_lp - 5), cv2.FONT_HERSHEY_SIMPLEX, 0.5, color, 2)

    if enemy_box is not None:
        x_enemy, y_enemy, w_enemy, h_enemy = enemy_box
        x_enemy, y_enemy, w_enemy, h_enemy = int(x_enemy), int(y_enemy), int(w_enemy), int(h_enemy)  # Convert to integers
        cv2.rectangle(frame, (x_enemy, y_enemy), (x_enemy + w_enemy, y_enemy + h_enemy), color, 2)
        cv2.putText(frame, "enemy", (x_enemy, y_enemy - 5), cv2.FONT_HERSHEY_SIMPLEX, 0.5, color, 2)

    cv2.imshow("Annotated Frame", frame)
    cv2.waitKey(1)

def process_frame(frame, model):
    # Convert frame to format expected by YOLOv5
    frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
    results = model(frame)

    local_player_detected = False
    enemy_detected = False

    local_player_box = None  # Initialize the variables here
    enemy_box = None

    for box in results.xyxy[0].cpu().numpy():
        class_id = int(box[5])
        box = box[:4]

        if class_id == 0:  # Assuming class 0 is localPlayer
            local_player_detected = True
            local_player_box = box
        elif class_id == 1:  # Assuming class 1 is enemy
            enemy_detected = True
            enemy_box = box

    return local_player_box if local_player_detected else None, enemy_box if enemy_detected else None

def visualize_and_process_frames():
    try:
        game_window = gw.getWindowsWithTitle('Superfighters Deluxe')[0]

        local_player_box = None
        enemy_box = None

        # Load the YOLOv5 model outside the loop
        model = torch.hub.load('ultralytics/yolov5:v7.0', 'yolov5s', force_reload=True)

        # Print model summary
        print(model)

        for t in range(6, MAX_EPISODE_LENGTH, 6):
            start_time = time.time()

            frame_path = os.path.join(FRAMES_DIRECTORY, f'frame_{t}.jpg')

            if os.path.exists(frame_path):
                frame = cv2.imread(frame_path)
                local_player_box, enemy_box = process_frame(frame, model)
                draw_boxes(game_window, local_player_box, enemy_box)

                if local_player_box is not None:
                    print("Local player detected!")
                    print("Local player box:", local_player_box)

                if enemy_box is not None:
                    print("Enemy detected!")
                    print("Enemy box:", enemy_box)

                elapsed_time = time.time() - start_time
                # Introduce a delay to limit CPU usage
                time.sleep(max(0, 0.0333 - elapsed_time))
            else:
                print(f"Frame {t} not found. Skipping to the next frame.")

        print("Done watching all frames. Press Ctrl + C to exit.")

    except KeyboardInterrupt:
        print("Script interrupted by user. Exiting...")

if __name__ == "__main__":
    if is_game_open():
        visualize_and_process_frames()
    else:
        print("Superfighters Deluxe is not open. Please open the game and try again.")