Retinexformer (default)
C++ (Windows, Linux, MacOS / CUDA and Metal accelerated) port of https://github.com/caiyuanhao1998/Retinexformer.git.
Example Input & Outputs
Inputs | Outputs |
![]() |
![]() |
Demo Code
1#include <opencv2/opencv.hpp>
2
3#include "blace_ai.h"
4
5// include the models you want to use
6#include "retinexformer_v1_default_v1_ALL_export_version_v17.h"
7
8int main() {
9 ::blace::workload_management::BlaceWorld blace;
10 // register model at server
11 blace::util::registerModel(retinexformer_v1_default_v1_ALL_export_version_v17,
12 blace::util::getPathToExe());
13
14 // load image into op
15 auto exe_path = blace::util::getPathToExe();
16 std::filesystem::path photo_path = exe_path / "dark_kitchen.png";
17 auto input_img =
18 CONSTRUCT_OP(blace::ops::FromImageFileOp(photo_path.string()));
19
20 // construct model inference arguments
21 blace::ml_core::InferenceArgsCollection infer_args;
22 infer_args.inference_args.device = blace::util::get_accelerator().value();
23
24 // construct inference operation
25 auto infer_op = CONSTRUCT_OP(blace::ops::InferenceOp(
26 retinexformer_v1_default_v1_ALL_export_version_v17_IDENT, {input_img},
27 infer_args, 0));
28
29 // construct evaluator and evaluate to cv::Mat
30 blace::computation_graph::GraphEvaluator evaluator(infer_op);
31 auto cv_result = evaluator.evaluateToCVMat().value();
32
33 // multiply for plotting
34 cv_result *= 255.;
35
36 // save to disk and return
37 auto out_file = exe_path / "illuminated_kitchen.png";
38 cv::imwrite(out_file.string(), cv_result);
39
40 return 0;
41}
Follow the 5 minute instructions to build and run the demo.
Tested on version v0.9.51 of blace.ai sdk. Might also work on newer or older releases (check if release notes of blace.ai state breaking changes).
Artifacts
Payload | Demo Project | Header |