AI Based Object Redaction/Examples/Library Examples: Difference between revisions

From RidgeRun Developer Wiki
(Created page with "=== Backend === First, we create the backend object. The backend provides factories to create the redaction algorithm and buffers. It provides the user the ability to select the desired backend for the execution of the algorithm for object redaction. The backend could be CPU or GPU. <source lang=C++> std::shared_ptr<rd::IBackend> backend = std::make_shared<rd::gpu::Backend>(); </source> In case the input buffer is not already in GPU memory, we also need to create a CP...")
 
No edit summary
Line 1: Line 1:
In this section will be explained an example for face redaction running on GPU.
=== Backend ===
=== Backend ===
First, we create the backend object. The backend provides factories to create the redaction algorithm and buffers. It provides the user the ability to select the desired backend for the execution of the algorithm for object redaction. The backend could be CPU or GPU.  
First, we create the backend object. The backend provides factories to create the redaction algorithm and buffers. It provides the user the ability to select the desired backend for the execution of the algorithm for object redaction. The backend could be CPU or GPU.  
Line 11: Line 12:
</source>
</source>


=== Get algorithm ===
==== Get algorithm ====
The GetAlgorithm method is used to obtain the redaction algorithm to process the input buffer.  
The GetAlgorithm method is used to obtain the redaction algorithm to process the input buffer.  


<source lang=C++>
<source lang=C++>
std::shared_ptr<rd::IRedaction> algorithm = backend->GetAlgorithm();
</source>
==== Get Model ====
The getModel method is used to obtain the AI model that will be used for the detection of the desired object. In this case: faces.


<source lang=C++>
std::shared_ptr<rd::IModel> model = backend->getModel(rd::Model::FACE_DETECTION);
</source>
</source>
=== Buffers ===

Revision as of 20:25, 20 December 2023

In this section will be explained an example for face redaction running on GPU.

Backend

First, we create the backend object. The backend provides factories to create the redaction algorithm and buffers. It provides the user the ability to select the desired backend for the execution of the algorithm for object redaction. The backend could be CPU or GPU.

std::shared_ptr<rd::IBackend> backend = std::make_shared<rd::gpu::Backend>();

In case the input buffer is not already in GPU memory, we also need to create a CPU backend to allocate the buffer in CPU memory.

std::shared_ptr<rd::IBackend> cpu_backend = std::make_shared<rd::cpu::Backend>();

Get algorithm

The GetAlgorithm method is used to obtain the redaction algorithm to process the input buffer.

std::shared_ptr<rd::IRedaction> algorithm = backend->GetAlgorithm();

Get Model

The getModel method is used to obtain the AI model that will be used for the detection of the desired object. In this case: faces.

std::shared_ptr<rd::IModel> model = backend->getModel(rd::Model::FACE_DETECTION);

Buffers