{"id":22052822,"url":"https://github.com/srking501/ssp","last_synced_at":"2026-05-09T09:14:52.882Z","repository":{"id":156356514,"uuid":"499546512","full_name":"Srking501/SSP","owner":"Srking501","description":"Software Stack Program (SSP). The process to automate the assessment of Machine Learning (ML) Models.","archived":false,"fork":false,"pushed_at":"2022-06-18T15:41:02.000Z","size":90489,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-23T15:39:18.326Z","etag":null,"topics":["darknet-yolo","keras","keras-tensorflow","machine-learning","tensorflow","yolov3","yolov3-tiny"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Srking501.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-03T14:42:17.000Z","updated_at":"2023-02-27T20:39:23.000Z","dependencies_parsed_at":"2023-05-06T17:00:18.297Z","dependency_job_id":null,"html_url":"https://github.com/Srking501/SSP","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Srking501/SSP","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Srking501%2FSSP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Srking501%2FSSP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Srking501%2FSSP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Srking501%2FSSP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Srking501","download_url":"https://codeload.github.com/Srking501/SSP/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Srking501%2FSSP/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261330126,"owners_count":23142482,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["darknet-yolo","keras","keras-tensorflow","machine-learning","tensorflow","yolov3","yolov3-tiny"],"created_at":"2024-11-30T15:14:22.417Z","updated_at":"2026-05-09T09:14:47.855Z","avatar_url":"https://github.com/Srking501.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Newcastle Univeristy Logo](assets/images/newcastle-uni-logo.png \"Newcastle Univeristy Logo\")](https://www.ncl.ac.uk/)\n\n# **SSP**\n\nSoftware Stack Program (SSP). The process to automate the assessment of Machine Learning (ML) Models.\n\n**NOTE: This is a dissertation work for Newcastle University Computer Science course in the theme of Data Science and AI.**\n\n\n# Preview\n\n\n## Data Processing Stack\n\n![Data Processing Stack](assets/videos/Data_Preprocessing.gif \"Data Process in Progress\")\n\n\n## Data Manipulation and Training of ML Models Stack\n\n![Data Manipulation and Training of ML Models](assets/videos/Data_Man_and_Train_ML.gif \"Data Manipulated and Training of ML Model is Running\")\n\n\n## Analytics For ML Models Stack\n\n![Analytics For ML Models](assets/videos/Analytics_For_ML_Models.gif \"The Produced Analytics\")\n\n\n# Installation\n\nThis final notebook was solely designed and tested on [Google Colab](https://colab.research.google.com/).\n\nIt would not likely work in your machine unless if you could modify the Google libraries imports, like [Google Drive function](https://colab.research.google.com/notebooks/io.ipynb), and use a [POSIX](https://en.wikipedia.org/wiki/POSIX) complaint system.\n\n# Usage\n\nSee [Flowchart of the Software Stack Program](assets/images/flowchart-ssp.png) for the main logic flow of the SSP.\n\nThis software has a various number of constant variables, which each can be modified to manipulate parameters for the program, these are:\n\n## **Models to Run**\n```Python\n#################\n# MODELS TO RUN #\n#################\nYOLO_MODEL = True\nRES_NET_MODEL = True\nMOBILENET_MODEL = True\n```\nThese are conditions that decides what model you want to run in the notebook - `True` means run, `False` means **do not** run.\n\n| Variables Meanings |\n|--------------------|\n* `YOLO_MODEL` - to run the Tiny-YOLOv3 model.\n\n* `RES_NET_MODEL` - to run the ResNet50V2 model.\n\n* `MOBILENET_MODEL` - to run the MobileNetV2 model.\n\n\n## **Setup and Hyper-parameters for the program to work**\n\n\n```Python\n##########\n# SET-UP #\n##########\nSKIP_DATA_PROCESSING = False\nCLASSES = [\"Person\", \"No Person\"]\nPATH_DATA = DRIVE_PATH + \"quick_preview/\"\nTEST_DATA = PATH_DATA + \"test/\"\nFINAL_MODELS_PATH = PATH_DATA + \"models/\"\nBACKUP_TENSOR = PATH_DATA + \"backup/tensorflow/\"\nNUMPY_SAVE = PATH_DATA + \"numpy/\"\n```\nThe following is the setup for the essential directories for the rest of the notebook to work.\n\nFirst, it contain an option to skip the [Data Processing Stack](#data-processing-stack) if the data is already processed by switching `SKIP_DATA_PROCESSING` into `True` - the `SKIP_DATA_PROCESSING` is automatically switched into `True` when the data in `YOLO_FRAMES` (look below to the YOLO SET-UP code snippet) and `NUMPY_SAVE` has content, which is then an assumption is made that the data is already processed.\n\nSecond, `CLASSES` is a list/array  of the ML class names labels.\n\nLast, `PATH_DATA`, `TEST_DATA`, `FINAL_MODELS_PATH`, `BACKUP_TENSOR` and `NUMPY_SAVE` are paths for the directories that makes the notebook to setup the data files for training.\n\n| Variables Meanings |\n|--------------------|\n* `SKIP_DATA_PROCESSING` - look above for important details. Skips the [Data Processing Stack](#data-processing-stack) when boolean value is `True`.\n\n* `CLASSES` - a list/array of string class names labels.\n\n* `PATH_DATA` - the directory where the data is present. The rest of the directories are designed on top of the `PATH_DATA`, where they are all in inside of the `PATH_DATA` directory.\n\n* `TEST_DATA` - directory for any extra video or image data to test the ML model performance (has not been used in the notebook, thus manually input is needed to use it).\n\n* `FINAL_MODELS_PATH` - the final trained models on the inputted dataset.\n\n* `BACKUP_TENSOR` - the checkpoints weights of the training of [Tensorflow](https://www.tensorflow.org/) and [Keras](https://keras.io/api/applications/) supported models.\n\n* `NUMPY_SAVE` - the save numpy arrays of the processed data.\n\n```Python\nNUM_BUF = 30\nMIN_CONTOUR = 100\nMAX_CONTOUR = 10000\n# Use website to visualise how the HSV range colour selected looks  like:\n# https://wamingo.net/rgbbgr/ (WARNING: it uses (360Degree, 100%, 100%) data)\n# OpenCV uses (0-179, 0-255, 0-255)\n#\n# Trick to convert it:\n# (half the degree, 255 x 1.0, 255 x 1.0)\n# (Trick got from https://stackoverflow.com/a/10951189)\nCOLOUR_HSV_RANGE = [  # [lower bound, upper bound]\n    [np.array([156, 148, 150]), np.array([179, 255, 255])],  # Red Range\n    [np.array([110, 125, 125]), np.array([150, 255, 255])]  # Blue Range\n]\n```\nThese constant variables are the essential tweaks parameters to adjust the [Data Processing Stack](#data-processing-stack).\n\n| Variables Meanings |\n|--------------------|\n* `NUM_BUF` - integer value for the the size of the buffer. This buffer saves the loaded frames of a video dataset where it prevents the data from being processed until it reaches the buffer size total value, for example `30` in this code snippet (this is used to reduce the amount of computation needed in [Data Processing Stack](#data-processing-stack) and minimise duplication of dataset).\n\n* `MIN_CONTOUR` and `MAX_CONTOUR` - [contours](https://docs.opencv.org/4.x/d4/d73/tutorial_py_contours_begin.html) are a curve joining all the continuous points (along the boundary), that has the same colour or intensity. Basically, when you decrease the `MIN_CONTOUR` value, you will in turn allow more smaller objects to be detected by the [Data Processing Stack](#data-processing-stack). On the other hand, when you increase the `MAX_CONTOUR` value, you will allow more bigger objects to be detected.\n\n* `COLOUR_HSV_RANGE` - 2D array containing all the lower and upper bounds of a colour range to be detect in the [Data Processing Stack](#data-processing-stack). As stated in the variable comment, you could use the help of [wamingo website](https://wamingo.net/rgbbgr/) with the addition of [stackoverflow trick](https://stackoverflow.com/a/10951189) to figure out the [HSV](https://docs.opencv.org/4.x/df/d9d/tutorial_py_colorspaces.html) ranges needed. There is another great options is to copy the code in this [stackoverflow comment](https://stackoverflow.com/a/59906154) to have GUI window to help visualise and find the right [HSV](https://docs.opencv.org/4.x/df/d9d/tutorial_py_colorspaces.html) values for [masking](https://docs.opencv.org/4.x/df/d9d/tutorial_py_colorspaces.html).\n\n\n```Python\n####################\n# Hyper-parameters #\n####################\nIMG_SIZE = 416\nINPUT_SHAPE = (IMG_SIZE, IMG_SIZE, 3)\nBATCH_SIZE = 20\nSHUFFLE_BUFFER_SIZE = 100\nEPOCHS = 10\nMAX_SEQ_LENGTH = 20\nNUM_FEATURES = 2048\n```\nThese are hyper-parameters that are used to tweak the training process of [Tensorflow](https://www.tensorflow.org/) and [Keras](https://keras.io/api/applications/) supported ML models (see [Data Manipulation and Training of ML Models Stack](#data-manipulation-and-training-of-ml-models-stack)).\n\n| Variables Meanings |\n|--------------------|\n* `IMG_SIZE` - the set horizontal and vertical pixels value for the dataset image.\n\n* `INPUT_SHAPE` - the input shape of the dataset image for the ML models to understand and interpret in [Tensorflow](https://www.tensorflow.org/) and [Keras](https://keras.io/api/applications/).\n\n* `BATCH_SIZE` - the collection of subset of dataset images to be inputted in a train run. So, in this a batch of `20` images are pushed in the model to be trained until it reaches the total of the dataset in one train run.\n\n* `SHUFFLE_BUFFER_SIZE` **(DEPRECATED)** - was used for the [TensorArray](https://www.tensorflow.org/api_docs/python/tf/TensorArray) to randomly shuffle batches of dataset.\n\n* `EPOCHS` - the value of total re-occurrence of the training on a dataset while updating the previous weights of the model, to refine it to reach optimum accuracy.\n\n* `MAX_SEQ_LENGTH` **(DEPRECATED)** - was used to limit the sequence of inputted data into the ML model.\n\n* `NUM_FEATURES` **(DEPRECATED)** - was used to calculate the size number of features (the points of interest to detect an image in a [CNN](https://en.wikipedia.org/wiki/Convolutional_neural_network)).\n\n\n```Python\n###############\n# YOLO SET-UP #\n###############\n# Directories\nYOLO_BACKUP = PATH_DATA + \"backup/yolo/\"\nYOLO_FRAMES = PATH_DATA + \"frames/\"\nYOLO_METADATA = PATH_DATA + \"metadata/yolo/\"\n\n# Files\nYOLO_MAIN_DATA = YOLO_METADATA + \"main.txt\"\nYOLO_VALID_DATA = YOLO_METADATA + \"valid.txt\"\nYOLO_TEST_DATA = YOLO_METADATA + \"test.txt\"\nYOLO_DATA_FILE = YOLO_METADATA + \"obj.data\"\nYOLO_NAMES_FILE = YOLO_METADATA + \"obj.names\"\n```\nThe reason the variables of the YOLO model is separate is because it uses a completely different framework from [Tensorflow](https://www.tensorflow.org/), where it instead uses the [Darknet framework](https://github.com/AlexeyAB/darknet), which the officially supported way to train the YOLO models.\n\n| Variables Meanings |\n|--------------------|\n* `YOLO_BACKUP` - this is where the checkpoints for the YOLO models trained weights will be stored.\n\n* `YOLO_FRAMES` - this is the place where the extracted dataset video frames are stored with text files that includes the pixel coordinates of the location of the missing person for object detection.\n\n* `YOLO_METADATA` - this is the metadata that allows the run of the YOLO model under the [Darknet framework](https://github.com/AlexeyAB/darknet).\n\n* `YOLO_MAIN_DATA` - text file that links to a subset data of the frames in `YOLO_FRAMES` to be used for training the model.\n\n* `YOLO_VALID_DATA` - text file that links to a subset data of the frames in `YOLO_FRAMES` to be used for validating the model\n\n* `YOLO_TEST_DATA` - text file that links to a subset data of the frames in `YOLO_FRAMES` to be used for testing the model\n\n* `YOLO_DATA_FILE` - text files that includes all the important information of the number of name classes and the paths to the `YOLO_MAIN_DATA`, `YOLO_MAIN_DATA`, `YOLO_NAMES_FILE` (the text file that contain the classes names) and `YOLO_BACKUP`\n\n* `YOLO_NAMES_FILE` - text file that contains the classes names from the array `CLASSES` in the second code snippet above. Each class name is split into new lines, where label 0 corresponds to the first line and label 1 corresponds to the second line.\n\n\n```Python\n#########################\n# YOLO Hyper-parameters #\n#########################\nYOLO_BATCH = 64\nYOLO_SUBDIVISION = 32\nYOLO_MAX_BATCHES = 4000\nYOLO_LOWER_STEPS = 400\nYOLO_UPPER_STEPS = 450\n```\nThese are the special constant variables parameters that tweak how the training of YOLO model should run in [Data Manipulation and Training of ML Models Stack](#data-manipulation-and-training-of-ml-models-stack).\n\n| Variables Meanings |\n|--------------------|\n* `YOLO_BATCH` - the number of batches of dataset images to be run at once with process of training.\n\n* `YOLO_SUBDIVISION` - the division of the batches to be loaded in GPU cores, so when `YOLO_BATCH` is `64` and the `YOLO_SUBDIVISION` is `32`, the GPU will split the batches into 2 halves in parallel to ease the memory on the GPU.\n\n* `YOLO_MAX_BATCHES` - this is how the number of re-occurrence of training per 1 of the sum total of `YOLO_BATCH` (so from the code snippet above, [`64` batch is equal to `1` max batch](https://github.com/AlexeyAB/darknet/wiki/CFG-Parameters-in-the-%5Bnet%5D-section)).\n\n* `YOLO_LOWER_STEPS` and `YOLO_UPPER_STEPS` - the steps that once the `YOLO_MAX_BATCHES` total value reach in the steps boundary, [then the policy will change the current learning rate](https://github.com/AlexeyAB/darknet/wiki/CFG-Parameters-in-the-%5Bnet%5D-section).\n\n\n# Limitations \n\nFirst, the [Data Processing Stack](#data-processing-stack) is solely designed to detect `\"Person\"` or `\"No Person\"` in terms of Image Classification models (for, example [ResNet50V2](https://keras.io/api/applications/resnet/#resnet50v2-function)) or only `\"Person\"` class name will be used in the case of Object Detection models (for example, [Tiny-YOLOv3](https://github.com/AlexeyAB/darknet)).\n\n```Python\nif len(contours) != 0:\n    frames_with_missing_person.append(temp_frame)\n    for label in CLASSES:\n        label_name = \"Person\"\n        if label == label_name:\n            labels_for_missing_person.append(CLASSES.index(label_name))\n            print(\"Found:\", label_name, \", Label Num:\", CLASSES.index(label_name))\n    proces_images(path, contours, frame, temp_frame, progress)\nelse:\n    frames_without_missing_person.append(temp_frame)\n    for label in CLASSES:\n        label_name = \"No Person\"\n        if label == label_name:\n            labels_for_without_missing_person.append(CLASSES.index(label_name))\n            print(\"Found:\", label_name, \", Label Num:\", CLASSES.index(label_name))\n```\nAs you can see the above code snippet, the conditions are hardcoded to label the dataset as `\"Person\"` or `\"No Person\"`.\n\n```Python\nif YOLO_MODEL is True:\n    file_without_extension = os.path.splitext(os.path.basename(path))[0]\n    frame_file_name = \"{0}{1}-{2}\".format(YOLO_FRAMES, file_without_extension, progress)\n\n    if os.path.isfile(frame_file_name + \".jpg\") is False:\n        cv2.imwrite(frame_file_name + \".jpg\", clean_frame)\n\n    # Coordinates data\n    if os.path.isfile(frame_file_name + \".txt\"):\n        coord_file = open(frame_file_name + \".txt\", \"a\")\n        coord_file.write(\"0 {0} {1} {2} {3}\\n\".format((x + 10) / IMG_SIZE, (y + 10) / IMG_SIZE,\n                                                        w / IMG_SIZE, h / IMG_SIZE))\n        coord_file.close()\n    else:\n        coord_file = open(frame_file_name + \".txt\", \"w\")\n        coord_file.write(\"0 {0} {1} {2} {3}\\n\".format((x + 10) / IMG_SIZE, (y + 10) / IMG_SIZE,\n                                                        w / IMG_SIZE, h / IMG_SIZE))\n        coord_file.close()\n```\nIn here, the above code snippet has hardcoded the number `\"0\"` which corresponds to the class name `\"Person\"` in the `YOLO_NAMES_FILE` (see above to the code snippet for the [YOLO SET-UP](#setup-and-hyper-parameters-for-the-program-to-work) in the [Usage section](#usage)\n\nSecond, there is no constant variable to change the input size of the YOLO model. The model uses the default pixel input size of `416x416` when being read by the [Darknet framework](https://github.com/AlexeyAB/darknet) in the [Data Manipulation and Training of ML Models Stack](#data-manipulation-and-training-of-ml-models-stack).\n\nThird, due to the YOLO model running through the [Darknet framework](https://github.com/AlexeyAB/darknet), which is a framework made in C/C++ and mainly configured through changing values in files, it is hard to produce analytics other than the provided ones from the framework (for example, [mAP](https://towardsdatascience.com/map-mean-average-precision-might-confuse-you-5956f1bfa9e2) with the loss over iteration is provided by the framework). \n\nHowever, there is the option to convert the trained YOLO model into [Tensorflow compatible saved model](https://github.com/AlexeyAB/darknet/wiki/Converting-Yolo-v3-models-to-TensorFlow-and-OpenVINO(IR)-models#converting-a-yolo-v3-model-darknet---tensorflow); but due to time constraints, I have not tested the suggested code to convert the model, thus, I do not know if it could work.\n\n\nLastly, the [Data Manipulation and Training of ML Models Stack](#data-manipulation-and-training-of-ml-models-stack), and [Analytics for ML Models Stack)](#analytics-for-ml-models-stack) are basically hardcoded like the [Data Processing Stack](#data-processing-stack). Although the parameters in the [Setup and Hyper-parameters for the program to work](#setup-and-hyper-parameters-for-the-program-to-work) can configure the process of the training of ML models, these 2 other stacks cannot automatically load a different ML models by just adding extra variables in the [\"Model to Run\" boolean code snippet](#models-to-run) - you will need to add the new ML models manually in a similar manner of the other ML models. \n\nIt is designed that way because of time constraints and the original focus was solely to test the Tiny-YOLOv3, ResNet50V2 and MobileNetV2 models, which was the best candidates for TCSR use of finding missing persons using drone's imaging data, according to the research done in the given time period of the dissertation.\n\n\n# Author and Acknowledgment\n\nAuthor: [Abdullah Alshadadi](https://github.com/Srking501)\n\nSpecial Thanks to: [The Centre for Search Research (TCSR)](https://tcsr.org.uk/)\n\n\n# License\n\nThis program is licensed by the [GNU GPLv3](LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsrking501%2Fssp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsrking501%2Fssp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsrking501%2Fssp/lists"}