From 5a6334369d9ecfe535bd3bc4fcd682f664bb478e Mon Sep 17 00:00:00 2001 From: Glas42 <145870870+Glas42@users.noreply.github.com> Date: Wed, 14 Feb 2024 02:37:52 +0100 Subject: [PATCH 1/3] removed useless dev setting from the trucksimapi --- plugins/TruckSimAPI/main.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/plugins/TruckSimAPI/main.py b/plugins/TruckSimAPI/main.py index e058b7c21..705484d00 100644 --- a/plugins/TruckSimAPI/main.py +++ b/plugins/TruckSimAPI/main.py @@ -114,11 +114,6 @@ def onEnable(): data = API.update() print("Plugin version: " + str(data["scsValues"]["telemetryPluginRevision"])) - - devmode = settings.GetSettings("Dev", "disable_warnings", False) - if devmode == False: - if data["scsValues"]["telemetryPluginRevision"] < 2: - print("Plugin not installed") def onDisable(): global stop From 39175a2d4b149634f81ff8447ad7e0d80a92db3a Mon Sep 17 00:00:00 2001 From: Glas42 <145870870+Glas42@users.noreply.github.com> Date: Wed, 14 Feb 2024 02:39:05 +0100 Subject: [PATCH 2/3] removed useless dev setting from the trucksimapi --- plugins/TruckSimAPI/main.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/TruckSimAPI/main.py b/plugins/TruckSimAPI/main.py index 705484d00..f2d24dd99 100644 --- a/plugins/TruckSimAPI/main.py +++ b/plugins/TruckSimAPI/main.py @@ -114,6 +114,9 @@ def onEnable(): data = API.update() print("Plugin version: " + str(data["scsValues"]["telemetryPluginRevision"])) + + if data["scsValues"]["telemetryPluginRevision"] < 2: + print("Plugin not installed") def onDisable(): global stop From d10433ac848b1dc8670471ca053614adbba0fe6c Mon Sep 17 00:00:00 2001 From: Glas42 <145870870+Glas42@users.noreply.github.com> Date: Wed, 14 Feb 2024 23:22:22 +0100 Subject: [PATCH 3/3] TrafficLightDetection UI Update. --- .../NavigationDetection/automatic_setup.py | 4 +-- .../TrafficLightDetection/YOLOModels/index.md | 3 ++ plugins/TrafficLightDetection/main.py | 36 ++++++++++++++++--- 3 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 plugins/TrafficLightDetection/YOLOModels/index.md diff --git a/plugins/NavigationDetection/automatic_setup.py b/plugins/NavigationDetection/automatic_setup.py index 08c3ec85b..f23630b42 100644 --- a/plugins/NavigationDetection/automatic_setup.py +++ b/plugins/NavigationDetection/automatic_setup.py @@ -127,10 +127,10 @@ def CreateSettings(category:str, name:str, data:any): folder_path = os.path.dirname(__file__) model_path = os.path.join(folder_path, 'YOLOv5_MapDetectionModel.pt') try: - torch.hub.set_dir(f"{folder_path}\\YoloFiles") + torch.hub.set_dir(f"{folder_path}\\YOLOFiles") model = torch.hub.load('ultralytics/yolov5', 'custom', path=model_path) except: - torch.hub.set_dir(f"{folder_path}\\YoloFiles") + torch.hub.set_dir(f"{folder_path}\\YOLOFiles") model = torch.hub.load('ultralytics/yolov5', 'custom', path=model_path, force_reload=True) print("\033[92m" + f"Successfully loaded the YOLOv5_MapDetectionModel.pt model!" + "\033[0m") startscreen("Setup model successfully loaded!", (0,255,0)) diff --git a/plugins/TrafficLightDetection/YOLOModels/index.md b/plugins/TrafficLightDetection/YOLOModels/index.md new file mode 100644 index 000000000..205f59b4b --- /dev/null +++ b/plugins/TrafficLightDetection/YOLOModels/index.md @@ -0,0 +1,3 @@ +--- +visibility: hidden +--- \ No newline at end of file diff --git a/plugins/TrafficLightDetection/main.py b/plugins/TrafficLightDetection/main.py index d9626ef83..b2056d7ae 100644 --- a/plugins/TrafficLightDetection/main.py +++ b/plugins/TrafficLightDetection/main.py @@ -280,8 +280,8 @@ def yolo_load_model_thread(): try: print("\033[92m" + f"Loading the {yolo_model_str} model..." + "\033[0m") import torch - torch.hub.set_dir(f"{variables.PATH}plugins\\TrafficLightDetection\\YoloFiles") - yolo_model = torch.hub.load("ultralytics/yolov5", yolo_model_str) + torch.hub.set_dir(f"{variables.PATH}plugins\\TrafficLightDetection\\YOLOFiles") + yolo_model = torch.hub.load("ultralytics/yolov5:master", 'custom', f"{variables.PATH}plugins\\TrafficLightDetection\\YOLOModels\\{yolo_model_str}") print("\033[92m" + f"Successfully loaded the {yolo_model_str} model!" + "\033[0m") yolo_model_loaded = True except Exception as e: @@ -1324,8 +1324,7 @@ def exampleFunction(self): helpers.MakeCheckButton(trackeraiFrame, "Do Yolo Detection confirmation\n---------------------------------------------\nIf enabled, the app tracks the detected traffic lights and confirms them with the YOLO object detection.\nWhat this means: higher accuracy, but a small lag every time the detection detects a new traffic light.", "TrafficLightDetection", "yolo_detection", 1, 0, width=100, callback=lambda:UpdateSettings()) helpers.MakeCheckButton(trackeraiFrame, "Show unconfirmed traffic lights\n--------------------------------------------\nIf enabled, the app will show unconfirmed or wrongly detected traffic lights in gray in the output window.", "TrafficLightDetection", "yolo_showunconfirmed", 2, 0, width=100, callback=lambda:UpdateSettings()) - helpers.MakeEmptyLine(trackeraiFrame,3,0) - helpers.MakeLabel(trackeraiFrame, "YOLOv5 Model:", 4, 0, sticky="nw") + helpers.MakeLabel(trackeraiFrame, "YOLOv5 Model:", 4, 0, sticky="nw", font=("Segoe UI", 12)) model_ui = tk.StringVar() previous_model_ui = settings.GetSettings("TrafficLightDetection", "yolo_model") if previous_model_ui == "yolov5n": @@ -1351,7 +1350,8 @@ def model_selection(): yolov5x = ttk.Radiobutton(trackeraiFrame, text="YOLOv5x (slowest, highest accuracy)", variable=model_ui, value="yolov5x", command=model_selection) yolov5x.grid(row=9, column=0, sticky="nw") model_selection() - helpers.MakeButton(trackeraiFrame, "Save and Load Model\n-------------------------------\nLoading the model could take some time.", self.save_and_load_model, 10, 0, width=50, sticky="nw") + helpers.MakeButton(trackeraiFrame, "Save and Load Model", self.save_and_load_model, 10, 0, width=100, sticky="nw") + helpers.MakeButton(trackeraiFrame, "Delete all downloaded models and redownload the model you are currently using.\nThis could fix faulty model files and other issues.", self.delete_and_redownload_model, 11, 0, width=100, sticky="nw") helpers.MakeCheckButton(screencaptureFrame, "Use Full Frame\n----------------------\nIf enabled, the screen capture for the traffic light detection uses the top ⅔ of the screen for\nthe traffic light detection. (not recommended, could have a bad impact on performance)\n\nTo set own screen capture coordinates disable Use Full Frame and use sliders below.", "TrafficLightDetection", "usefullframe", 1, 0, width=80, callback=lambda:UpdateSettings()) @@ -1728,6 +1728,32 @@ def save_and_load_model(self): else: messagebox.showwarning("TrafficLightDetection", f"The code is still loading a different model. Please try again when the other model has finished loading.") + def delete_and_redownload_model(self): + global last_model_load_press + global yolo_model_loaded + if time.time() > last_model_load_press + 1: + last_model_load_press = time.time() + if yolo_model_loaded != "loading...": + try: + import os + yolomodels_path = f"{variables.PATH}plugins\\TrafficLightDetection\\YOLOModels" + for filename in os.listdir(yolomodels_path): + file_path = os.path.join(yolomodels_path, filename) + if os.path.isfile(file_path) and filename.lower() != 'index.md': + os.remove(file_path) + except Exception as e: + messagebox.showwarning("TrafficLightDetection", f"The code encountered an error while deleting the model files. Please try again.") + exc = traceback.format_exc() + SendCrashReport("TrafficLightDetection - Model Delete Error.", str(exc)) + print("TrafficLightDetection - Model Delete Error: " + str(e)) + yolo_model_loaded = False + yolo_load_model() + UpdateSettings() + else: + messagebox.showwarning("TrafficLightDetection", f"The code is still loading a model. Please try again when the model has finished loading.") + else: + messagebox.showwarning("TrafficLightDetection", f"The code is still loading a model. Please try again when the model has finished loading.") + def update(self, data): self.root.update()