From 437fe9bc05eff339b644d23b34cd6f92f0de9314 Mon Sep 17 00:00:00 2001 From: Aydin <108932477+Aydinhamedi@users.noreply.github.com> Date: Thu, 14 Mar 2024 11:41:36 +0330 Subject: [PATCH 1/7] modified: .github/workflows/ruff_L&F.yml --- .github/workflows/ruff_L&F.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ruff_L&F.yml b/.github/workflows/ruff_L&F.yml index 81c7e44..ad10c06 100644 --- a/.github/workflows/ruff_L&F.yml +++ b/.github/workflows/ruff_L&F.yml @@ -26,7 +26,7 @@ jobs: pip install ruff - name: Lint with ruff run: | - ruff check . --fix --show-fixes --statistics + ruff check . --fix --show-fixes - name: Format with ruff run: | ruff format . --preview --line-length 140 From 5210e9f0063916a8eb591e319d01fa15d80da27e Mon Sep 17 00:00:00 2001 From: Aydin <108932477+Aydinhamedi@users.noreply.github.com> Date: Thu, 14 Mar 2024 11:52:16 +0330 Subject: [PATCH 2/7] modified: Interface/GUI/Data/GUI_main.py --- Interface/GUI/Data/GUI_main.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Interface/GUI/Data/GUI_main.py b/Interface/GUI/Data/GUI_main.py index 0b1a77b..09f0bb1 100644 --- a/Interface/GUI/Data/GUI_main.py +++ b/Interface/GUI/Data/GUI_main.py @@ -754,8 +754,8 @@ def main() -> None: if not event == "-TIMEOUT-": logger.debug(f"GUI_window:event: {event}") logger.debug(f"GUI_window:values: {values}") - print(f"GUI_window:event: {event}") - print(f"GUI_window:values: {values}") + print(f"GUI_window:event: ~e[{event}]e~\n") + print(f"GUI_window:values: ~v[{values}]v~\n") # Check if the window has been closed or the 'Close' button has been clicked if event == sg.WINDOW_CLOSED or event == "Close": @@ -835,7 +835,7 @@ def main() -> None: # Retrieve the result from the queue result_expanded = "" result = GUI_Queue["-Main_log-"].get() - print(f"Queue Data: {result}") + print(f"Queue Data: {result}\n") logger.debug(f"Queue[-Main_log-]:get: {result}") # Update the GUI with the result message for block in result: From bab3850a906370cdc177b56012ede5f8d6312a1a Mon Sep 17 00:00:00 2001 From: Aydin <108932477+Aydinhamedi@users.noreply.github.com> Date: Thu, 14 Mar 2024 11:52:41 +0330 Subject: [PATCH 3/7] modified: BETA_E_Model_T&T.ipynb modified: Interface/CLI/Data/CLI_main.py modified: Model_T&T.ipynb modified: history_vis.py modified: requirements.txt --- BETA_E_Model_T&T.ipynb | 48 ++++++++++++++++++---------------- Interface/CLI/Data/CLI_main.py | 4 +-- Model_T&T.ipynb | 48 ++++++++++++++++++---------------- history_vis.py | 4 +-- requirements.txt | 1 - 5 files changed, 56 insertions(+), 49 deletions(-) diff --git a/BETA_E_Model_T&T.ipynb b/BETA_E_Model_T&T.ipynb index ef81a87..1d22fdb 100644 --- a/BETA_E_Model_T&T.ipynb +++ b/BETA_E_Model_T&T.ipynb @@ -114,7 +114,7 @@ "from Utils.Grad_cam import make_gradcam_heatmap\n", "from Utils.print_color_V2_NEW import print_Color_V2\n", "from Utils.print_color_V1_OLD import print_Color\n", - "from Utils.Other import * # noqa: F403\n", + "from Utils.Other import * # noqa: F403\n", "\n", "# Other\n", "tf.get_logger().setLevel(\"ERROR\")\n", @@ -3214,10 +3214,12 @@ " layer.trainable = True\n", "\n", " # Combine the output of the two base models\n", - " combined = concatenate([\n", - " Dense(512, activation=\"relu\", kernel_regularizer=l2(0.01))(GlobalAveragePooling2D()(base_model1_out)),\n", - " Dense(512, activation=\"relu\", kernel_regularizer=l2(0.01))(GlobalAveragePooling2D()(base_model2_out)),\n", - " ])\n", + " combined = concatenate(\n", + " [\n", + " Dense(512, activation=\"relu\", kernel_regularizer=l2(0.01))(GlobalAveragePooling2D()(base_model1_out)),\n", + " Dense(512, activation=\"relu\", kernel_regularizer=l2(0.01))(GlobalAveragePooling2D()(base_model2_out)),\n", + " ]\n", + " )\n", "\n", " # adding CDL\n", " Dense_L1 = Dense(1024, activation=\"relu\", kernel_regularizer=l2(0.02))(combined)\n", @@ -9956,10 +9958,12 @@ "\n", " old_weights, old_biases = layer.get_weights()\n", "\n", - " layer.set_weights([\n", - " weight_initializer(shape=old_weights.shape),\n", - " bias_initializer(shape=len(old_biases)),\n", - " ])" + " layer.set_weights(\n", + " [\n", + " weight_initializer(shape=old_weights.shape),\n", + " bias_initializer(shape=len(old_biases)),\n", + " ]\n", + " )" ] }, { @@ -10356,14 +10360,14 @@ "\n", "\n", "# Funcs\n", - "def normalize_TO_RANGE(arr, min_val, max_val): # noqa: F811\n", + "def normalize_TO_RANGE(arr, min_val, max_val): # noqa: F811\n", " arr = arr.astype(\"float32\")\n", " arr = (arr - arr.min()) / (arr.max() - arr.min())\n", " arr = arr * (max_val - min_val) + min_val\n", " return arr\n", "\n", "\n", - "def Z_SCORE_normalize(arr): # noqa: F811\n", + "def Z_SCORE_normalize(arr): # noqa: F811\n", " arr = arr.astype(\"float32\")\n", " mean = np.mean(arr)\n", " std_dev = np.std(arr)\n", @@ -10613,8 +10617,8 @@ " advanced_mode=True,\n", ")\n", "# warnings\n", - "P_warning(\"[RES_Train -> True].\") if RES_Train else None # noqa: F405\n", - "P_warning(\"[TerminateOnHighTemp_M -> False] GPU temperature protection is OFF\") if not TerminateOnHighTemp_M else None # noqa: F405\n", + "P_warning(\"[RES_Train -> True].\") if RES_Train else None # noqa: F405\n", + "P_warning(\"[TerminateOnHighTemp_M -> False] GPU temperature protection is OFF\") if not TerminateOnHighTemp_M else None # noqa: F405\n", "print_Color(\"Setup Verbose END.\", [\"yellow\"])\n", "# MAIN LOOP\n", "try:\n", @@ -10636,7 +10640,7 @@ " advanced_mode=True,\n", " )\n", " # warnings\n", - " P_warning(\"[TerminateOnHighTemp_M -> False] GPU temperature protection is OFF\") if not TerminateOnHighTemp_M else None # noqa: F405\n", + " P_warning(\"[TerminateOnHighTemp_M -> False] GPU temperature protection is OFF\") if not TerminateOnHighTemp_M else None # noqa: F405\n", " # DP\n", " if not AdvSubsetC:\n", " print_Color(\"Shuffling data...\", [\"yellow\"])\n", @@ -10860,7 +10864,7 @@ " # Garbage Collection (memory)\n", " gc.collect()\n", " tf.keras.backend.clear_session()\n", - " GPU_memUsage() # noqa: F405\n", + " GPU_memUsage() # noqa: F405\n", " # Update TF summary text\n", " for Key in TF_Summary_text_Dict:\n", " TF_Summary_text_cache = f\"# @[{Key}].Data:\\n\"\n", @@ -11200,10 +11204,10 @@ "from numba import cuda\n", "\n", "device = cuda.get_current_device()\n", - "GPU_memUsage() # noqa: F405\n", + "GPU_memUsage() # noqa: F405\n", "print(\"Realising all memory...\")\n", "device.reset()\n", - "GPU_memUsage() # noqa: F405\n", + "GPU_memUsage() # noqa: F405\n", "print(\"done.\")" ] }, @@ -11221,7 +11225,7 @@ "outputs": [], "source": [ "# Save history\n", - "save_list(history, \"history\\\\model_history.pkl.gz\", compress=True) # noqa: F405" + "save_list(history, \"history\\\\model_history.pkl.gz\", compress=True) # noqa: F405" ] }, { @@ -11231,7 +11235,7 @@ "outputs": [], "source": [ "# load history\n", - "history = load_list(\"history\\\\model_history.pkl.gz\", compressed=True) # noqa: F405" + "history = load_list(\"history\\\\model_history.pkl.gz\", compressed=True) # noqa: F405" ] }, { @@ -11705,9 +11709,9 @@ "\n", "# Print acc\n", "print(\"Val data acc:\")\n", - "evaluate_model_full(y_val, val_predictions) # noqa: F405\n", + "evaluate_model_full(y_val, val_predictions) # noqa: F405\n", "print(\"Test data acc:\")\n", - "evaluate_model_full(y_test, test_predictions) # noqa: F405\n", + "evaluate_model_full(y_test, test_predictions) # noqa: F405\n", "\n", "# format data\n", "val_predictions = np.argmax(val_predictions, axis=1)\n", @@ -11824,7 +11828,7 @@ " plt.title(\"Number of Incorrect Predictions vs. Number of Data Points\")\n", " plt.show()\n", "except Exception:\n", - " P_warning(\"Failed to plot incorrect predictions vs. data points\") # noqa: F405" + " P_warning(\"Failed to plot incorrect predictions vs. data points\") # noqa: F405" ] } ], diff --git a/Interface/CLI/Data/CLI_main.py b/Interface/CLI/Data/CLI_main.py index 5e8ff25..2285f81 100644 --- a/Interface/CLI/Data/CLI_main.py +++ b/Interface/CLI/Data/CLI_main.py @@ -29,7 +29,7 @@ # Utils from Utils.Grad_cam import make_gradcam_heatmap from Utils.print_color_V1_OLD import print_Color -from Utils.Other import * # noqa: F403 +from Utils.Other import * # noqa: F403 # global vars>>> # CONST SYS @@ -463,7 +463,7 @@ def CI_tmwd(argv_Split: list = ["none"]): else: print("Training the model...\n") # training - model.fit(images, labels, epochs=train_epochs, batch_size=1, verbose="auto") + model.fit(images, labels, epochs=train_epochs, batch_size=1, verbose="auto") print("Training done.\n") else: print_Color( diff --git a/Model_T&T.ipynb b/Model_T&T.ipynb index ef81a87..1d22fdb 100644 --- a/Model_T&T.ipynb +++ b/Model_T&T.ipynb @@ -114,7 +114,7 @@ "from Utils.Grad_cam import make_gradcam_heatmap\n", "from Utils.print_color_V2_NEW import print_Color_V2\n", "from Utils.print_color_V1_OLD import print_Color\n", - "from Utils.Other import * # noqa: F403\n", + "from Utils.Other import * # noqa: F403\n", "\n", "# Other\n", "tf.get_logger().setLevel(\"ERROR\")\n", @@ -3214,10 +3214,12 @@ " layer.trainable = True\n", "\n", " # Combine the output of the two base models\n", - " combined = concatenate([\n", - " Dense(512, activation=\"relu\", kernel_regularizer=l2(0.01))(GlobalAveragePooling2D()(base_model1_out)),\n", - " Dense(512, activation=\"relu\", kernel_regularizer=l2(0.01))(GlobalAveragePooling2D()(base_model2_out)),\n", - " ])\n", + " combined = concatenate(\n", + " [\n", + " Dense(512, activation=\"relu\", kernel_regularizer=l2(0.01))(GlobalAveragePooling2D()(base_model1_out)),\n", + " Dense(512, activation=\"relu\", kernel_regularizer=l2(0.01))(GlobalAveragePooling2D()(base_model2_out)),\n", + " ]\n", + " )\n", "\n", " # adding CDL\n", " Dense_L1 = Dense(1024, activation=\"relu\", kernel_regularizer=l2(0.02))(combined)\n", @@ -9956,10 +9958,12 @@ "\n", " old_weights, old_biases = layer.get_weights()\n", "\n", - " layer.set_weights([\n", - " weight_initializer(shape=old_weights.shape),\n", - " bias_initializer(shape=len(old_biases)),\n", - " ])" + " layer.set_weights(\n", + " [\n", + " weight_initializer(shape=old_weights.shape),\n", + " bias_initializer(shape=len(old_biases)),\n", + " ]\n", + " )" ] }, { @@ -10356,14 +10360,14 @@ "\n", "\n", "# Funcs\n", - "def normalize_TO_RANGE(arr, min_val, max_val): # noqa: F811\n", + "def normalize_TO_RANGE(arr, min_val, max_val): # noqa: F811\n", " arr = arr.astype(\"float32\")\n", " arr = (arr - arr.min()) / (arr.max() - arr.min())\n", " arr = arr * (max_val - min_val) + min_val\n", " return arr\n", "\n", "\n", - "def Z_SCORE_normalize(arr): # noqa: F811\n", + "def Z_SCORE_normalize(arr): # noqa: F811\n", " arr = arr.astype(\"float32\")\n", " mean = np.mean(arr)\n", " std_dev = np.std(arr)\n", @@ -10613,8 +10617,8 @@ " advanced_mode=True,\n", ")\n", "# warnings\n", - "P_warning(\"[RES_Train -> True].\") if RES_Train else None # noqa: F405\n", - "P_warning(\"[TerminateOnHighTemp_M -> False] GPU temperature protection is OFF\") if not TerminateOnHighTemp_M else None # noqa: F405\n", + "P_warning(\"[RES_Train -> True].\") if RES_Train else None # noqa: F405\n", + "P_warning(\"[TerminateOnHighTemp_M -> False] GPU temperature protection is OFF\") if not TerminateOnHighTemp_M else None # noqa: F405\n", "print_Color(\"Setup Verbose END.\", [\"yellow\"])\n", "# MAIN LOOP\n", "try:\n", @@ -10636,7 +10640,7 @@ " advanced_mode=True,\n", " )\n", " # warnings\n", - " P_warning(\"[TerminateOnHighTemp_M -> False] GPU temperature protection is OFF\") if not TerminateOnHighTemp_M else None # noqa: F405\n", + " P_warning(\"[TerminateOnHighTemp_M -> False] GPU temperature protection is OFF\") if not TerminateOnHighTemp_M else None # noqa: F405\n", " # DP\n", " if not AdvSubsetC:\n", " print_Color(\"Shuffling data...\", [\"yellow\"])\n", @@ -10860,7 +10864,7 @@ " # Garbage Collection (memory)\n", " gc.collect()\n", " tf.keras.backend.clear_session()\n", - " GPU_memUsage() # noqa: F405\n", + " GPU_memUsage() # noqa: F405\n", " # Update TF summary text\n", " for Key in TF_Summary_text_Dict:\n", " TF_Summary_text_cache = f\"# @[{Key}].Data:\\n\"\n", @@ -11200,10 +11204,10 @@ "from numba import cuda\n", "\n", "device = cuda.get_current_device()\n", - "GPU_memUsage() # noqa: F405\n", + "GPU_memUsage() # noqa: F405\n", "print(\"Realising all memory...\")\n", "device.reset()\n", - "GPU_memUsage() # noqa: F405\n", + "GPU_memUsage() # noqa: F405\n", "print(\"done.\")" ] }, @@ -11221,7 +11225,7 @@ "outputs": [], "source": [ "# Save history\n", - "save_list(history, \"history\\\\model_history.pkl.gz\", compress=True) # noqa: F405" + "save_list(history, \"history\\\\model_history.pkl.gz\", compress=True) # noqa: F405" ] }, { @@ -11231,7 +11235,7 @@ "outputs": [], "source": [ "# load history\n", - "history = load_list(\"history\\\\model_history.pkl.gz\", compressed=True) # noqa: F405" + "history = load_list(\"history\\\\model_history.pkl.gz\", compressed=True) # noqa: F405" ] }, { @@ -11705,9 +11709,9 @@ "\n", "# Print acc\n", "print(\"Val data acc:\")\n", - "evaluate_model_full(y_val, val_predictions) # noqa: F405\n", + "evaluate_model_full(y_val, val_predictions) # noqa: F405\n", "print(\"Test data acc:\")\n", - "evaluate_model_full(y_test, test_predictions) # noqa: F405\n", + "evaluate_model_full(y_test, test_predictions) # noqa: F405\n", "\n", "# format data\n", "val_predictions = np.argmax(val_predictions, axis=1)\n", @@ -11824,7 +11828,7 @@ " plt.title(\"Number of Incorrect Predictions vs. Number of Data Points\")\n", " plt.show()\n", "except Exception:\n", - " P_warning(\"Failed to plot incorrect predictions vs. data points\") # noqa: F405" + " P_warning(\"Failed to plot incorrect predictions vs. data points\") # noqa: F405" ] } ], diff --git a/history_vis.py b/history_vis.py index 6eb6eee..9b96862 100644 --- a/history_vis.py +++ b/history_vis.py @@ -1,9 +1,9 @@ -from Utils.Other import * # noqa: F403 +from Utils.Other import * # noqa: F403 import matplotlib.pyplot as plt import numpy as np # load history -history = load_list("history\\model_history.pkl.gz", compressed=True) # noqa: F405 +history = load_list("history\\model_history.pkl.gz", compressed=True) # noqa: F405 # Chunk size for 3D plot chunk_size = 6 # Change this to your desired chunk size diff --git a/requirements.txt b/requirements.txt index 94902fa..dc3cf89 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,3 @@ -absl-py==1.4.0 adabelief-tf==0.2.1 efficientnet==1.1.1 gpu-control==1.0.0 From 0ced7352b4043cee047fcb19f2e329ef55395365 Mon Sep 17 00:00:00 2001 From: Aydin <108932477+Aydinhamedi@users.noreply.github.com> Date: Thu, 14 Mar 2024 12:00:54 +0330 Subject: [PATCH 4/7] modified: Interface/GUI/GUI.cmd modified: Interface/GUI/Silent_Run.vbs --- Interface/GUI/GUI.cmd | 6 ++++-- Interface/GUI/Silent_Run.vbs | 18 ++++++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Interface/GUI/GUI.cmd b/Interface/GUI/GUI.cmd index 7d8900c..cdd5de8 100644 --- a/Interface/GUI/GUI.cmd +++ b/Interface/GUI/GUI.cmd @@ -57,8 +57,10 @@ for /F "usebackq delims==" %%i in ("Data\requirements.txt") do ( REM Write the current Python version + Python install time to the file echo %current_python_version% > %PV_filepath% @REM Pause for user input -echo Press any key to load the GUI... -pause > nul +if not "%Full_Auto%"=="1" ( + echo Press any key to load the GUI... + pause > nul +) :FAST_START REM Print the appropriate loading message diff --git a/Interface/GUI/Silent_Run.vbs b/Interface/GUI/Silent_Run.vbs index e8f7ff0..dc2339d 100644 --- a/Interface/GUI/Silent_Run.vbs +++ b/Interface/GUI/Silent_Run.vbs @@ -1,3 +1,17 @@ Set WshShell = CreateObject("WScript.Shell") -WshShell.Run chr(34) & "GUI.cmd" & Chr(34), 0 -Set WshShell = Nothing \ No newline at end of file +Set FSO = CreateObject("Scripting.FileSystemObject") + +' Define the path to the file you want to check +filePath = "Data\Python Ver.tmp" + +' Check if the file exists +If FSO.FileExists(filePath) Then + ' If the file exists, run it without showing a window + WshShell.Run chr(34) & filePath & Chr(34), 0, False +Else + ' If the file does not exist, show a terminal window and display a popup message + WshShell.Run "cmd.exe /K echo This is the first time running the GUI. It may take a few minutes to start. && pause", 1, False +End If + +Set WshShell = Nothing +Set FSO = Nothing From 515a35c497599dd76a485fa829f7dc93fbdee237 Mon Sep 17 00:00:00 2001 From: Aydin <108932477+Aydinhamedi@users.noreply.github.com> Date: Thu, 14 Mar 2024 12:11:14 +0330 Subject: [PATCH 5/7] modified: Interface/GUI/Silent_Run.vbs --- Interface/GUI/Silent_Run.vbs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Interface/GUI/Silent_Run.vbs b/Interface/GUI/Silent_Run.vbs index dc2339d..6c9e455 100644 --- a/Interface/GUI/Silent_Run.vbs +++ b/Interface/GUI/Silent_Run.vbs @@ -7,10 +7,11 @@ filePath = "Data\Python Ver.tmp" ' Check if the file exists If FSO.FileExists(filePath) Then ' If the file exists, run it without showing a window - WshShell.Run chr(34) & filePath & Chr(34), 0, False + WshShell.Run chr(34) & "GUI.cmd" & Chr(34), 0, False Else - ' If the file does not exist, show a terminal window and display a popup message - WshShell.Run "cmd.exe /K echo This is the first time running the GUI. It may take a few minutes to start. && pause", 1, False + ' If the file does not exist, run GUI.cmd with a terminal window and show a popup message + WshShell.Run chr(34) & "GUI.cmd" & Chr(34), 1, False + WshShell.Popup "This is the first time running the GUI. It may take a few minutes to start.", 30, "First Time Running", 64 End If Set WshShell = Nothing From 587234624115b23696ae3b4c5b230daec9594f45 Mon Sep 17 00:00:00 2001 From: Aydin <108932477+Aydinhamedi@users.noreply.github.com> Date: Thu, 14 Mar 2024 12:13:46 +0330 Subject: [PATCH 6/7] modified: Interface/GUI/Data/GUI_main.py --- Interface/GUI/Data/GUI_main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Interface/GUI/Data/GUI_main.py b/Interface/GUI/Data/GUI_main.py index 09f0bb1..a6e2ab3 100644 --- a/Interface/GUI/Data/GUI_main.py +++ b/Interface/GUI/Data/GUI_main.py @@ -79,7 +79,7 @@ sys.exit() # global vars>>> # CONST SYS -GUI_Ver = "0.9.3 Pre1" +GUI_Ver = "0.9.4" Model_dir = "Data/PAI_model" # without file extention Database_dir = "Data/dataset.npy" IMG_AF = ("JPEG", "PNG", "BMP", "TIFF", "JPG", "DCM", "DICOM") From 12b754d1084af291853ab26457551523a2dfdd82 Mon Sep 17 00:00:00 2001 From: Aydin <108932477+Aydinhamedi@users.noreply.github.com> Date: Thu, 14 Mar 2024 12:14:03 +0330 Subject: [PATCH 7/7] deleted: Interface/GUI/README.txt --- Interface/GUI/README.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 Interface/GUI/README.txt diff --git a/Interface/GUI/README.txt b/Interface/GUI/README.txt deleted file mode 100644 index aa46809..0000000 --- a/Interface/GUI/README.txt +++ /dev/null @@ -1 +0,0 @@ -For the first time run it by GUI.cmd if loaded and didn't have any problem use Silent_Run.vbs to run it without a terminal. \ No newline at end of file