-
Notifications
You must be signed in to change notification settings - Fork 0
/
canvasinferer.h
61 lines (45 loc) · 1.21 KB
/
canvasinferer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef CANVASINFERER_H
#define CANVASINFERER_H
#include <QThread>
#include <QObject>
#include <QImage>
#include "threadsafequeue.hpp"
#include "Include/Axodox.MachineLearning.h"
#include "stablediffusionmodel.h"
struct CanvasOrder{
QString Prompt;
QString NegativePrompt;
Axodox::MachineLearning::StableDiffusionOptions Options;
uint32_t BatchCount;
QImage InputImage;
QImage InputMask;
VaeMode Vae;
bool Cancel = false;
};
/*
* CanvasInferer is the dedicated inference thread class for Canvas
* Unlike its normal Inferer counterpart, this one:
* - Always runs
* - Uses a thread-safe queue and constantly processes for its orders
* - Can only do img2img.
*/
class CanvasInferer : public QThread
{
Q_OBJECT
private:
void ProcessOrder(CanvasOrder& Ord);
protected:
void run() override;
public:
CanvasInferer();
Axodox::Threading::async_operation_source* AsyncSrc;
StableDiffusionModel* Model;
bool Stop;
ThreadSafeQueue<CanvasOrder> Queue;
signals:
void Done(QImage Img);
void PreviewsAvailable(std::vector<QImage> Imgs);
public slots:
void OnPreviewsAvailable(std::vector<Axodox::Graphics::TextureData> Previews);
};
#endif // CANVASINFERER_H