MSE-CNN Implementation 1
Code database with the implementation of MSE-CNN, from the paper 'DeepQTMT: A Deep Learning Approach for Fast QTMT-based CU Partition of Intra-mode VVC'
|
Functions | |
setup_model () | |
Initializes and load the parameters of the MSE-CNN. | |
int2label (split) | |
Obtain the string that corresponds to an integer value of the split. | |
draw_partition (img, split, cu_pos, cu_size) | |
Draw partition in image based in the split outputed by the model. | |
split_fm (cu, cu_pos, split) | |
Splits feature maps in specific way. | |
partition_img (img, img_yuv) | |
Partitions a full 128x128 CTU and draws the partition in the original image. | |
pipeline (img, text) | |
Pipeline to implement the functionalities to demonstrate the potential of the MSE-CNN. | |
main () | |
Variables | |
str | PATH_TO_COEFFS = "../../../model_coefficients/best_coefficients" |
str | LOAD_IMAGE_ERROR = "load_image_error.png" |
list | EXAMPLE_IMGS = ["example_img_1.jpeg", "example_img_2.jpeg"] |
tuple | CTU_SIZE = (128, 128) |
FIRST_CU_POS = torch.tensor([0, 0]).reshape(shape=(-1, 2)) | |
FIRST_CU_SIZE = torch.tensor([64, 64]).reshape(shape=(-1, 2)) | |
str | DEV = "cuda" if torch.cuda.is_available() else "cpu" |
int | QP = 32 |
model = None | |
tuple | COLOR = (0, 247, 255) |
int | LINE_THICKNESS = 1 |
str | DEFAULT_TEXT_FOR_COORDS = "Insert CTU position in the image..." |
@package docstring @file demo.py @brief Demonstration of the application of the MSE-CNN Note: In order to run this script, you have to do it inside the folder @section libraries_demo Libraries - msecnn - train_model_utils - cv2 - dataset_utils - re - sys - numpy - gradio - torch - custom_dataset - PIL @section classes_demo Classes - None @section functions_demo Functions - setup_model() - int2label(split) - draw_partition(img, split, cu_pos, cu_size) - split_fm(cu, cu_pos, split) - partition_img(img, img_yuv) - pipeline(img, text) - main() @section global_vars_demo Global Variables - PATH_TO_COEFFS - LOAD_IMAGE_ERROR - EXAMPLE_IMGS - CTU_SIZE - FIRST_CU_POS - FIRST_CU_SIZE - DEV - QP - model - COLOR - LINE_THICKNESS - DEFAULT_TEXT_FOR_COORDS @section todo_demo TODO - Instead of obtaining the best split, do the thresholding and then split it until you find the right type of split @section license License MIT License Copyright (c) 2022 Raul Kevin do Espirito Santo Viana Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @section author_demo Author(s) - Created by Raul Kevin Viana - Last time modified is 2023-09-10 21:00:10.225508
demo.draw_partition | ( | img, | |
split, | |||
cu_pos, | |||
cu_size | |||
) |
Draw partition in image based in the split outputed by the model.
[in] | img | User's input image |
[in] | cu_pos | CU position |
[in] | cu_size | CU size |
[in] | split | Integer number representing the split that the model chose |
[out] | str_split | Name of the corresponding split |
demo.int2label | ( | split | ) |
Obtain the string that corresponds to an integer value of the split.
[in] | split | Integer number representing the split tht the model chose |
[out] | str_split | Name of the corresponding split |
demo.main | ( | ) |
demo.partition_img | ( | img, | |
img_yuv | |||
) |
Partitions a full 128x128 CTU and draws the partition in the original image.
TODO: Instead of obtaining the best split, do the thresholding and then split it until you find the right type of split
[in] | img | Image in BGR |
[in] | img_yuv | Image in YUV |
[in] | stg | Current stage being partitioned |
[in] | cu_pos | Current stage being partitioned |
[in] | cu_size | Current stage being partitioned |
[out] | img | Image in with partitions drawn to it |
demo.pipeline | ( | img, | |
text | |||
) |
Pipeline to implement the functionalities to demonstrate the potential of the MSE-CNN.
[in] | img | Image in RGB |
[out] | mod_img | Modified image with drawings into it in RGB |
[out] | best_split | Best split (BTV, BTH, TTV, TTH, Non-split, QT) |
demo.setup_model | ( | ) |
Initializes and load the parameters of the MSE-CNN.
demo.split_fm | ( | cu, | |
cu_pos, | |||
split | |||
) |
Splits feature maps in specific way.
[in] | cu | Input to the model |
[in] | cu_pos | Coordinate of the CU |
[in] | split | Way to split CU |
[out] | cu_out | New Feature maps |
[out] | cu_pos_out | Position of the new CUs |
tuple demo.COLOR = (0, 247, 255) |
tuple demo.CTU_SIZE = (128, 128) |
str demo.DEFAULT_TEXT_FOR_COORDS = "Insert CTU position in the image..." |
str demo.DEV = "cuda" if torch.cuda.is_available() else "cpu" |
list demo.EXAMPLE_IMGS = ["example_img_1.jpeg", "example_img_2.jpeg"] |
demo.FIRST_CU_POS = torch.tensor([0, 0]).reshape(shape=(-1, 2)) |
demo.FIRST_CU_SIZE = torch.tensor([64, 64]).reshape(shape=(-1, 2)) |
int demo.LINE_THICKNESS = 1 |
str demo.LOAD_IMAGE_ERROR = "load_image_error.png" |
demo.model = None |
str demo.PATH_TO_COEFFS = "../../../model_coefficients/best_coefficients" |
int demo.QP = 32 |