nndeploy C++ API
0.2.0
nndeploy C++ API
plugin
include
nndeploy
stable_diffusion
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
16
class
NNDEPLOY_CC_API
Text2ImageParam
:
public
base::Param
{
17
public
:
18
base::InferenceType
inference_type_ =
19
nndeploy::base::kInferenceTypeOnnxRuntime
;
20
base::DeviceType
device_type_ =
nndeploy::base::kDeviceTypeCodeCpu
;
21
base::ModelType
model_type_ =
nndeploy::base::kModelTypeOnnx
;
22
bool
is_path_ =
true
;
23
std::vector<std::string>
model_value_
;
24
std::string
output_path_
;
25
base::ParallelType
pt_ =
base::kParallelTypePipeline
;
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
nndeploy::base::Param
Definition:
param.h:37
nndeploy::stable_diffusion::ProgressBar
Definition:
utils.h:29
nndeploy::stable_diffusion::ProgressBar::update
void update(int value)
nndeploy::stable_diffusion::ProgressBar::ProgressBar
ProgressBar(int total, int barWidth=80, const std::string &prefix="", const std::string &suffix="")
Definition:
utils.h:32
nndeploy::stable_diffusion::ProgressBar::finish
void finish()
nndeploy::stable_diffusion::Text2ImageParam
Definition:
utils.h:16
nndeploy::stable_diffusion::Text2ImageParam::output_path_
std::string output_path_
Definition:
utils.h:24
nndeploy::stable_diffusion::Text2ImageParam::model_value_
std::vector< std::string > model_value_
Definition:
utils.h:23
NNDEPLOY_CC_API
#define NNDEPLOY_CC_API
api
Definition:
macro.h:29
nndeploy::base::InferenceType
InferenceType
Definition:
common.h:284
nndeploy::base::kInferenceTypeOnnxRuntime
@ kInferenceTypeOnnxRuntime
Definition:
common.h:293
nndeploy::base::ModelType
ModelType
Definition:
common.h:239
nndeploy::base::kModelTypeOnnx
@ kModelTypeOnnx
Definition:
common.h:246
nndeploy::base::ParallelType
ParallelType
Definition:
common.h:353
nndeploy::base::kParallelTypePipeline
@ kParallelTypePipeline
Definition:
common.h:357
nndeploy::base::kDeviceTypeCodeCpu
@ kDeviceTypeCodeCpu
Definition:
common.h:82
nndeploy
Definition:
common.h:10
param.h
nndeploy::base::DeviceType
Definition:
common.h:109
Generated by
1.9.1