nndeploy C++ API  0.2.0
nndeploy C++ API
utils.h
Go to the documentation of this file.
1 #ifndef _NNDEPLOY_MODEL_STABLE_DIFFUSION_UTILS_H_
2 #define _NNDEPLOY_MODEL_STABLE_DIFFUSION_UTILS_H_
3 
4 #include <chrono>
5 #include <iostream>
6 #include <string>
7 #include <thread>
8 #include <vector>
9 
10 #include "nndeploy/base/param.h"
11 
12 namespace nndeploy {
13 namespace stable_diffusion {
14 
15 // inference param
17  public:
18  base::InferenceType inference_type_ =
22  bool is_path_ = true;
23  std::vector<std::string> model_value_;
24  std::string output_path_;
26 };
27 
28 // 美观的进度条插件封装成一个类
29 class ProgressBar {
30  public:
31  // 构造函数:total为总进度,barWidth为进度条宽度,prefix/suffix用于附加说明
32  ProgressBar(int total, int barWidth = 80, const std::string &prefix = "",
33  const std::string &suffix = "")
34  : total(total),
35  barWidth(barWidth),
36  current(0),
37  prefix(prefix),
38  suffix(suffix),
39  spinnerIndex(0) {
40  spinnerChars = {"|", "/", "-", "\\"};
41  }
42 
43  // 更新进度条显示,value为当前进度值
44  void update(int value);
45 
46  // 结束显示,确保进度条显示满100%并换行
47  void finish();
48 
49  private:
50  int total; // 总进度值
51  int barWidth; // 进度条宽度
52  int current; // 当前进度值
53  std::string prefix; // 前缀说明
54  std::string suffix; // 后缀说明
55  int spinnerIndex; // 旋转效果索引
56  std::vector<std::string> spinnerChars; // 旋转字符序列
57 };
58 
59 } // namespace stable_diffusion
60 } // namespace nndeploy
61 
62 #endif
ProgressBar(int total, int barWidth=80, const std::string &prefix="", const std::string &suffix="")
Definition: utils.h:32
std::vector< std::string > model_value_
Definition: utils.h:23
#define NNDEPLOY_CC_API
api
Definition: macro.h:29
@ kInferenceTypeOnnxRuntime
Definition: common.h:293
@ kModelTypeOnnx
Definition: common.h:246
@ kParallelTypePipeline
Definition: common.h:357
@ kDeviceTypeCodeCpu
Definition: common.h:82