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'
Loading...
Searching...
No Matches
Functions | Variables
demo Namespace Reference

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..."
 

Detailed Description

@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

Function Documentation

◆ draw_partition()

demo.draw_partition (   img,
  split,
  cu_pos,
  cu_size 
)

Draw partition in image based in the split outputed by the model.

Parameters
[in]imgUser's input image
[in]cu_posCU position
[in]cu_sizeCU size
[in]splitInteger number representing the split that the model chose
[out]str_splitName of the corresponding split

◆ int2label()

demo.int2label (   split)

Obtain the string that corresponds to an integer value of the split.

Parameters
[in]splitInteger number representing the split tht the model chose
[out]str_splitName of the corresponding split

◆ main()

demo.main ( )

◆ partition_img()

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

Parameters
[in]imgImage in BGR
[in]img_yuvImage in YUV
[in]stgCurrent stage being partitioned
[in]cu_posCurrent stage being partitioned
[in]cu_sizeCurrent stage being partitioned
[out]imgImage in with partitions drawn to it

◆ pipeline()

demo.pipeline (   img,
  text 
)

Pipeline to implement the functionalities to demonstrate the potential of the MSE-CNN.

Parameters
[in]imgImage in RGB
[out]mod_imgModified image with drawings into it in RGB
[out]best_splitBest split (BTV, BTH, TTV, TTH, Non-split, QT)

◆ setup_model()

demo.setup_model ( )

Initializes and load the parameters of the MSE-CNN.

◆ split_fm()

demo.split_fm (   cu,
  cu_pos,
  split 
)

Splits feature maps in specific way.

Parameters
[in]cuInput to the model
[in]cu_posCoordinate of the CU
[in]splitWay to split CU
[out]cu_outNew Feature maps
[out]cu_pos_outPosition of the new CUs

Variable Documentation

◆ COLOR

tuple demo.COLOR = (0, 247, 255)

◆ CTU_SIZE

tuple demo.CTU_SIZE = (128, 128)

◆ DEFAULT_TEXT_FOR_COORDS

str demo.DEFAULT_TEXT_FOR_COORDS = "Insert CTU position in the image..."

◆ DEV

str demo.DEV = "cuda" if torch.cuda.is_available() else "cpu"

◆ EXAMPLE_IMGS

list demo.EXAMPLE_IMGS = ["example_img_1.jpeg", "example_img_2.jpeg"]

◆ FIRST_CU_POS

demo.FIRST_CU_POS = torch.tensor([0, 0]).reshape(shape=(-1, 2))

◆ FIRST_CU_SIZE

demo.FIRST_CU_SIZE = torch.tensor([64, 64]).reshape(shape=(-1, 2))

◆ LINE_THICKNESS

int demo.LINE_THICKNESS = 1

◆ LOAD_IMAGE_ERROR

str demo.LOAD_IMAGE_ERROR = "load_image_error.png"

◆ model

demo.model = None

◆ PATH_TO_COEFFS

str demo.PATH_TO_COEFFS = "../../../model_coefficients/best_coefficients"

◆ QP

int demo.QP = 32