CCTV CV Cheat Sheet
This document contains the blueprint for running a new utility's data through the CCTV CV pipeline.
Starting point
The utility will provide gqc with inspection videos and inspection data (which contains metadata for the inspection videos). The inspection data will either be received as an MS Access Database, Database file (.dbf), Excel file (.xlsx), or a pdf file.
Directory structure:
For the new utility, create a folder in unionsine2/cctv/ with the utility name in lower case. For example, if we have a utility called Utility_Z, we would create a folder utility_z in unionsine2/cctv. Within the utility folder, create a subfolder called Data (eg: utility_z/Data).
Data from the utility will most likely be provided in batches which we call datasets. Within the Data folder, create a folder for each dataset. For example, if Utility_Z has two datasets, we would create two folders in the Data directory: utility_z/Data/Dataset_A and UTILITY_Z/data/Dataset_B. The dataset folders should be named sensibly possibly pertaining to the number of inspection videos that were in the dataset.
Within a dataset directory, create the following folders: received_data,azure_json, blurred_frames, extracted_frames , labels_csv, logs, metadata_csv, received_data, training_csv, video_db, and video_lists. These folders will be used when running through the cctv cv processing pipeline.
Depending on how the inspection videos are sent for the dataset, the videos may be grouped into subfolders already. If they are not grouped into subfolders, create a subfolders in the received_data folder and store the videos inside that subfolder. This step is important since the cctv cv notebooks require the videos to be grouped into subfolders for processing. The subfolder names are referred to as 'video_groups' in the processing notebooks. Please note that the received_data folder itself should not have any videos, but rather the subfolder(s) within received_data should contain the videos.
At this point your directory structure for your utility and dataset should look something like this:
Utility:
utility_z
└── Data
├── Dataset_A
├── Dataset_B
└── Dataset_C
Dataset:
Dataset_A
├── received_data
├── azure_json
├── blurred_frames
├── extracted_frames
├── labels_csv
├── logs
├── metadata_csv
├── Temp
├── training_csv
├── video_db
└── video_lists
We have our file structure set up. The next step is creating the .yml file that will drive the entire processing pipeline. Before creating the .yml file, it is advised to go through the CCTV CV workflow for SD1 as it has been well documented. Click here to take a look at the workflow for SD1.
To reference how to create and fill up the .yml file, take a look at the .yml file located at /home/gqc/git/gqc/gqc-utility-notebooks/yaml/cctv_settings_ds_SD1_B.yml.
Make sure to fill out the DISTANCE_BOUNDING_BOX_CSV, VIDEO_TYPES_CSV, and the CONDITION_STANDARD_CSV options in the .yml before running any of the cctv-cv notebooks. The CONDITION_STANDARD_CSV should be set to /home/gqc/CCTV/UTILITY_X/Data/Dataset_X/Metadata_CSV/PACP_Condition_Code.csv if the utility uses PACP inspection standards. The DISTANCE_BOUNDING_BOX_CSV and VIDEO_TYPES_CSV can be obtained from the Distance Region Extractor and Video Type Classifier streamlit apps. If you are re-running the CCTV CV pipeline on a utility, chances are that the DISTANCE_BOUNDING_BOX_CSV and VIDEO_TYPES_CSV files are present in the metadata_csv folder. While running the notebooks for a new utility, make sure to put those CSV files in the metdata_csv folder.
Running CCTV CV notebooks for a new utility
Open up a VS Code tab and navigate to ~/git/gqc/gqc-utility-notebooks. You will find the notebooks in the /nbs/02_cctv_cv directory.
Please refer to the mermaid diagrams here for an example of which notebooks to run and in which order.
Run through each of the notebooks in the order specified in the mermaid diagrams. Make sure to add the path for the .yml file that you created into the yaml_path= argument. As a heads up, for notebook 2 you will have to clone the gqc-utility-notebooks repository onto a Windows machine and copy over the output CSV if your inspection data is in the form of an MS Access Database.
After runnning through all the CV notebooks, the blurred_frames folder should be populated with zip files corresponding to the blurred images of each video_group. The training+validation and test csvs should also be present in the training_csv folder.
Training the CV model
To train the CV model, checkout this page.