Steps to train CCTV defect classification models
These are instructions shared by Vannary on 05/2023 and are obsolete as of 01/26/2024.
Check CCTV Workflow document for up-to-date instructions.
Create Data
Create a shortcut folder of new uploaded videos folder and place the folder in
CCTV/<Utitlity>/Data/Uploaded_Dataof the gdrive.Run 0-zip-videos notebook to zip the videos into the group of 10 and store them in
CCTV/<Utitlity>/Data/Videosand create a video list of each group and save toCCTV/<Utility>/Data/Video_Lists/If you have an access to compute canada,
- Note: You cannot have more than 500,000 files in your project space. It is better to zip multiples into one zip file.
- Use rclone to copy those zip files and video lists csv files to the
CCTV/<Utitlity>/Data/Videos/andCCTV/<Utitlity>/Data/Video_Lists/directory in Compute Canada - Run sbatch shellrunner_extract_frames.sh -s vs_cctv_video_frame_extraction -c
<video_group_name>-u<Utility>to extract every 30th frames from videos and save them as zip file toCCTV/<Utitlity>/Data/Extracted_Frames/. The run will also output zip file containing list of frames csv files and save toCCTV/<Utitlity>/Data/Extracted_CSV/.- The processing time depends on the video size and video resolution. It can range from a few minutes to 5 hours per video group on Cedar cluster.
- Run sbatch shellrunner_Azure_OCR_6_stacked_full_image.sh -s colab_cctv_full_frame_stitch_and_azure_ocr -c
<video_group_name>-u<Utility>to get JSON file of texts detected in the image and save toCCTV/<Utitlity>/Data/Azure_JSON/.- The processing time depends on the image size and image resolution. The processing time can range from 1 to 10 hours per video group on Cedar cluster.
- You should not submit jobs for more than 30 video groups at once. You can get a disconnect error from Azure if you do too many multiple calls at once.
- Run sbatch shellrunner_blur.sh -s vs_cctv_images_save_blurred_frames -c
<video_group_name>-u<Utility>to create blurred images of the extracted frames and save the outputs toCCTV/<Utitlity>/Data/Blurred_Frames/.- The processing time depends on the image size and image resolution. It ranges from 10 min to 2 hours per video group on Cedar cluster.
- Extract middle frames and each video using sbatch shellrunner_mid_frames.sh -s mid_frame_extractor_from_videos -c
<video_group_name>-u<Utility>save them as zip file toCCTV/<Utitlity>/Data/.- Export the zip file to local compute and use streamlit app to classify video type.
- Upload the video type csv to gdrive
- Transfer outputs from steps 2 to 5 to gdrive using rclone.
If you run notebooks on colab,
- Note:
- We might need to modify these notebooks to read file from a zip file and to save the outputs as a zip file
- You can only run up to 5 notebooks at a time.
- Run CCTV_video_frame_extraction to extract every 30th frames from videos and save them as zip file to
CCTV/<Utitlity>/Data/Extracted_Frames/. The run will also output zip file containing list of frames csv files and save the outputs toCCTV/<Utitlity>/Data/Extracted_CSV/- The processing time depends on the video size and video resolution.
- Run colab-cctv-full-frame-stitch-and-Azure-OCR notebook to get JSON file of texts detected in the image and save the outputs to
CCTV/<Utitlity>/Data/Azure_JSON/.- This step has the largest processing time. The processing time depends on the image size and image resolution.
- Run CCTV_Images_Save_blurred_frames notebook to create blurred images from the extracted frames and save the outputs to
CCTV/<Utitlity>/Data/Blurred_Frames/ - Run mid_frame_extractor_from_videos notebook to extract middle frame of each video.
- Use streamlit app to classify video type.
- Note:
Run CCTV_Images_extract_labels notebook to create a zip file containing extracted labels csv file of each video.
- The processing time is < 1 hour per video group.
Create a metadata csv file from DBs provided by Utility. Refer to this page for more detail.
Add
cross_reference_idto list of video csv files using this notebook. You might need to modify the notebook to work for different utilities.Run create_image_labels notebook to annotate images.
- The processing time is < 1 hour per video group.
Run generate_data_for_k_fold_cross_val notebook to split data into train, validation, and test sets.
- Note: I will edit this notebook so it is easier for you to use.
- The processing time is < 1 hour per video group.