-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.js
More file actions
199 lines (180 loc) · 5.06 KB
/
Copy pathapi.js
File metadata and controls
199 lines (180 loc) · 5.06 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
import axios from 'axios';
const API_URL = process.env.REACT_APP_API_URL || 'http://localhost:5000';
const api = axios.create({
baseURL: API_URL,
});
// Image Generation
export const generateImages = async (prompt, numImages, resolution, temperature, inferenceSteps) => {
try {
const response = await api.post('/generate', { prompt, numImages, resolution, temperature, inferenceSteps });
return response.data;
} catch (error) {
console.error('Error generating images:', error);
throw error;
}
};
// Image Enhancement
export const enhanceImage = async (imageData, prompt, enhancementOption, temperature) => {
try {
const response = await api.post('/enhance', { imageData, prompt, enhancementOption, temperature });
return response.data;
} catch (error) {
console.error('Error enhancing image:', error);
throw error;
}
};
// Settings Management
export const getGenerationSettings = async () => {
try {
const response = await api.get('/settings');
return response.data;
} catch (error) {
console.error('Error fetching generation settings:', error);
throw error;
}
};
export const updateGenerationSettings = async (settings) => {
try {
const response = await api.put('/settings', settings);
return response.data;
} catch (error) {
console.error('Error updating generation settings:', error);
throw error;
}
};
// Enhancement Options
export const getEnhancementOptions = async () => {
try {
const response = await api.get('/enhancement-options');
return response.data;
} catch (error) {
console.error('Error fetching enhancement options:', error);
throw error;
}
};
// Style Prompts
export const getStylePrompts = async () => {
try {
const response = await api.get('/style-prompts');
return response.data;
} catch (error) {
console.error('Error fetching style prompts:', error);
throw error;
}
};
// Freestyle Enhancement
export const applyFreestyle = async (imageData, prompt, selectedStyle, temperature) => {
try {
const response = await api.post('/apply-freestyle', { imageData, prompt, selectedStyle, temperature });
return response.data;
} catch (error) {
console.error('Error applying Freestyle:', error);
throw error;
}
};
// Upscaler Enhancement
export const applyUpscaler = async (imageData, prompt, outputSize) => {
try {
const response = await api.post('/apply-upscaler', { imageData, prompt, outputSize });
return response.data;
} catch (error) {
console.error('Error applying Upscaler:', error);
throw error;
}
};
// ControlNet Enhancement
export const applyControlNet = async (imageData, prompt) => {
try {
const response = await api.post('/apply-controlnet', { imageData, prompt });
return response.data;
} catch (error) {
console.error('Error applying ControlNet:', error);
throw error;
}
};
// Pixart Enhancement
export const applyPixart = async (imageData, prompt, temperature) => {
try {
const response = await api.post('/apply-pixart', { imageData, prompt, temperature });
return response.data;
} catch (error) {
console.error('Error applying Pixart:', error);
throw error;
}
};
// Model Management
export const downloadModels = async () => {
try {
const response = await api.post('/download-models');
return response.data;
} catch (error) {
console.error('Error downloading models:', error);
throw error;
}
};
export const getModelStatus = async () => {
try {
const response = await api.get('/model-status');
return response.data;
} catch (error) {
console.error('Error fetching model status:', error);
throw error;
}
};
// Image Handling
export const saveImage = async (imageData, fileName) => {
try {
const response = await api.post('/save-image', { imageData, fileName });
return response.data;
} catch (error) {
console.error('Error saving image:', error);
throw error;
}
};
export const getGeneratedImages = async () => {
try {
const response = await api.get('/generated-images');
return response.data;
} catch (error) {
console.error('Error fetching generated images:', error);
throw error;
}
};
// User Input Handling
export const validateUserInput = async (input, inputType, options) => {
try {
const response = await api.post('/validate-input', { input, inputType, options });
return response.data;
} catch (error) {
console.error('Error validating user input:', error);
throw error;
}
};
// Logging
export const getLogs = async (startDate, endDate, logLevel) => {
try {
const response = await api.get('/logs', { params: { startDate, endDate, logLevel } });
return response.data;
} catch (error) {
console.error('Error fetching logs:', error);
throw error;
}
};
export default {
generateImages,
enhanceImage,
getGenerationSettings,
updateGenerationSettings,
getEnhancementOptions,
getStylePrompts,
applyFreestyle,
applyUpscaler,
applyControlNet,
applyPixart,
downloadModels,
getModelStatus,
saveImage,
getGeneratedImages,
validateUserInput,
getLogs,
};