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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
#[allow(unused_imports)]
use crate::prelude::*;
#[allow(unused_imports)]
use serde::{Deserialize, Serialize};
#[allow(unused_imports)]
use std::collections::HashMap;
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct BlurMaskInput {
/// Input image url.
/// "https://storage.googleapis.com/falserverless/model_tests/workflow_utils/mask_input.png"
pub image_url: String,
/// The radius of the Gaussian blur.
/// 5
#[serde(skip_serializing_if = "Option::is_none")]
pub radius: Option<i64>,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct BlurMaskOutput {
/// The mask
/// {"content_type":"image/png","height":700,"url":"https://storage.googleapis.com/falserverless/model_tests/workflow_utils/blur_mask_output.png","width":610}
pub image: Image,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct CannyInput {
/// High threshold for the hysteresis procedure
/// 200
#[serde(skip_serializing_if = "Option::is_none")]
pub high_threshold: Option<i64>,
/// Input image url.
/// "https://storage.googleapis.com/falserverless/model_tests/workflow_utils/mask_input.png"
pub image_url: String,
/// Low threshold for the hysteresis procedure
/// 100
#[serde(skip_serializing_if = "Option::is_none")]
pub low_threshold: Option<i64>,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct Color {
/// Blue value
/// 128
#[serde(skip_serializing_if = "Option::is_none")]
pub b: Option<i64>,
/// Green value
/// 128
#[serde(skip_serializing_if = "Option::is_none")]
pub g: Option<i64>,
/// Red value
/// 128
#[serde(skip_serializing_if = "Option::is_none")]
pub r: Option<i64>,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct CompareTextInput {
/// Text to compare against
/// "Hello, World!"
pub compare_text: String,
/// Text to return if the input text does not match the compare text
/// "Hello, Universe!"
pub fail_text: String,
/// Text to return if the input text matches the compare text
/// "Hello, World!"
pub return_text: String,
/// Input text
/// "Hello, World!"
pub text: String,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct CompositeImageInput {
/// Input image url.
/// "https://storage.googleapis.com/falserverless/model_tests/workflow_utils/mask_input.png"
pub background_image_url: String,
/// Optional mask image url.
/// "https://storage.googleapis.com/falserverless/model_tests/workflow_utils/mask_input.png"
#[serde(skip_serializing_if = "Option::is_none")]
pub mask_image_url: Option<String>,
/// Overlay image url.
/// "https://storage.googleapis.com/falserverless/model_tests/workflow_utils/mask_input.png"
pub overlay_image_url: String,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct FaceDetection {
/// Bounding box of the face.
/// [0,0,100,100]
pub bbox: Vec<i64>,
/// Confidence score of the detection.
/// 0.9
pub det_score: f64,
/// Embedding of the face.
/// ""
pub embedding_file: File,
/// Keypoints of the face.
#[serde(skip_serializing_if = "Option::is_none")]
pub kps: Option<Vec<Option<Vec<Option<i64>>>>>,
/// Keypoints of the face on the image.
pub kps_image: Image,
/// Either M or F if available.
/// "M"
#[serde(skip_serializing_if = "Option::is_none")]
pub sex: Option<String>,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct File {
/// The mime type of the file.
/// "image/png"
#[serde(skip_serializing_if = "Option::is_none")]
pub content_type: Option<String>,
/// File data
#[serde(skip_serializing_if = "Option::is_none")]
pub file_data: Option<String>,
/// The name of the file. It will be auto-generated if not provided.
/// "z9RV14K95DvU.png"
#[serde(skip_serializing_if = "Option::is_none")]
pub file_name: Option<String>,
/// The size of the file in bytes.
/// 4404019
#[serde(skip_serializing_if = "Option::is_none")]
pub file_size: Option<i64>,
/// The URL where the file can be downloaded from.
pub url: String,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct GrowMaskInput {
/// Input image url.
/// "https://storage.googleapis.com/falserverless/model_tests/workflow_utils/mask_input.png"
pub image_url: String,
/// The number of pixels to grow the mask.
/// 5
#[serde(skip_serializing_if = "Option::is_none")]
pub pixels: Option<i64>,
/// The threshold to convert the image to a mask. 0-255.
/// 128
#[serde(skip_serializing_if = "Option::is_none")]
pub threshold: Option<i64>,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct GrowMaskOutput {
/// The mask
/// {"content_type":"image/png","height":700,"url":"https://storage.googleapis.com/falserverless/model_tests/workflow_utils/grow_output.png","width":610}
pub image: Image,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct HTTPValidationError {
#[serde(skip_serializing_if = "Option::is_none")]
pub detail: Option<Vec<Option<ValidationError>>>,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct Image {
/// The mime type of the file.
/// "image/png"
#[serde(skip_serializing_if = "Option::is_none")]
pub content_type: Option<String>,
/// File data
#[serde(skip_serializing_if = "Option::is_none")]
pub file_data: Option<String>,
/// The name of the file. It will be auto-generated if not provided.
/// "z9RV14K95DvU.png"
#[serde(skip_serializing_if = "Option::is_none")]
pub file_name: Option<String>,
/// The size of the file in bytes.
/// 4404019
#[serde(skip_serializing_if = "Option::is_none")]
pub file_size: Option<i64>,
/// The height of the image in pixels.
/// 1024
#[serde(skip_serializing_if = "Option::is_none")]
pub height: Option<i64>,
/// The URL where the file can be downloaded from.
pub url: String,
/// The width of the image in pixels.
/// 1024
#[serde(skip_serializing_if = "Option::is_none")]
pub width: Option<i64>,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct ImageInput {
/// Input image url.
/// "https://storage.googleapis.com/falserverless/model_tests/workflow_utils/mask_input.png"
pub image_url: String,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct ImageOutput {
/// The output image
/// {"content_type":"image/png","height":700,"url":"https://storage.googleapis.com/falserverless/model_tests/workflow_utils/invert_mask_output.png","width":610}
pub image: Image,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct ImageSizeOutput {
/// Image size
/// {"height":700,"width":610}
pub image_size: HashMap<String, serde_json::Value>,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct InsertTextInput {
/// Template to insert text into
/// "Hello, {}!"
pub template: String,
/// Input text
/// "Hello, World!"
pub text: String,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct InsightfaceInput {
/// Size of the detection.
/// 640
#[serde(skip_serializing_if = "Option::is_none")]
pub det_size_height: Option<i64>,
/// Size of the detection.
/// 640
#[serde(skip_serializing_if = "Option::is_none")]
pub det_size_width: Option<i64>,
/// Input image url.
/// "https://storage.googleapis.com/falserverless/model_tests/retoucher/GGsAolHXsAA58vn.jpeg"
pub image_url: String,
/// Maximum number of faces to detect.
/// 1
#[serde(skip_serializing_if = "Option::is_none")]
pub max_face_num: Option<i64>,
/// URL of the model weights.
/// "buffalo_l"
/// "antelopev2"
#[serde(skip_serializing_if = "Option::is_none")]
pub model_url: Option<String>,
/// Sorting of the faces.
/// "largest-to-smallest"
/// "smallest-to-largest"
/// "left-to-right"
/// "right-to-left"
#[serde(skip_serializing_if = "Option::is_none")]
pub sorting: Option<String>,
/// Whether to run in sync mode.
#[serde(skip_serializing_if = "Option::is_none")]
pub sync_mode: Option<bool>,
/// Threshold for the edge map.
/// 0.5
#[serde(skip_serializing_if = "Option::is_none")]
pub threshold: Option<f64>,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct InsightfaceOutput {
/// Bounding box of the face.
/// [0,0,100,100]
pub bbox: Vec<f64>,
/// Confidence score of the detection.
/// 0.9
pub det_score: f64,
/// Embedding of the face.
/// ""
pub embedding_file: File,
/// faces detected sorted by size
pub faces: Vec<FaceDetection>,
/// Keypoints of the face.
#[serde(skip_serializing_if = "Option::is_none")]
pub kps: Option<Vec<Option<Vec<Option<f64>>>>>,
/// Keypoints of the face on the image.
pub kps_image: Image,
/// Either M or F if available.
/// "M"
#[serde(skip_serializing_if = "Option::is_none")]
pub sex: Option<String>,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct InvertMaskOutput {
/// The mask
/// {"content_type":"image/png","height":700,"url":"https://storage.googleapis.com/falserverless/model_tests/workflow_utils/invert_mask_output.png","width":610}
pub image: Image,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct MaskInput {
/// Input image url.
/// "https://storage.googleapis.com/falserverless/model_tests/workflow_utils/mask_input.png"
pub image_url: String,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct RGBAToRGBImageInput {
/// Input image url.
/// "https://storage.googleapis.com/falserverless/model_tests/workflow_utils/mask_input.png"
pub image_url: String,
/// Color to replace the transparent pixels with
/// {"b":128,"g":128,"r":128}
pub transparent_color: Color,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct RegexReplaceInput {
/// Pattern to replace
/// "World"
pub pattern: String,
/// Replacement text
/// "Universe"
pub replace: String,
/// Input text
/// "Hello, World!"
pub text: String,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct ResizeImageInput {
/// Position of cropping. Only used when mode is 'crop', default is center
#[serde(skip_serializing_if = "Option::is_none")]
pub cropping_position: Option<String>,
/// Height of the resized image
/// 700
pub height: i64,
/// Input image url.
/// "https://storage.googleapis.com/falserverless/model_tests/workflow_utils/mask_input.png"
pub image_url: String,
/// Resizing mode
pub mode: String,
/// Color of padding. Only used when mode is 'pad', default is black
#[serde(skip_serializing_if = "Option::is_none")]
pub padding_color: Option<String>,
/// Resizing strategy. Only used when mode is 'scale', default is nearest
#[serde(skip_serializing_if = "Option::is_none")]
pub resampling: Option<String>,
/// Proportions of the image. Only used when mode is 'scale', default is fit
#[serde(skip_serializing_if = "Option::is_none")]
pub scaling_proportions: Option<String>,
/// Width of the resized image
/// 610
pub width: i64,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct ResizeToPixelsInput {
/// If set, the output dimensions will be divisible by this value.
/// 32
#[serde(skip_serializing_if = "Option::is_none")]
pub enforce_divisibility: Option<i64>,
/// Input image url.
/// "https://storage.googleapis.com/falserverless/model_tests/retoucher/GGsAolHXsAA58vn.jpeg"
pub image_url: String,
/// Maximum number of pixels in the output image.
/// 1000000
#[serde(skip_serializing_if = "Option::is_none")]
pub max_pixels: Option<i64>,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct ShrinkMaskInput {
/// Input image url.
/// "https://storage.googleapis.com/falserverless/model_tests/workflow_utils/mask_input.png"
pub image_url: String,
/// The number of pixels to shrink the mask.
/// 5
#[serde(skip_serializing_if = "Option::is_none")]
pub pixels: Option<i64>,
/// The threshold to convert the image to a mask. 0-255.
/// 128
#[serde(skip_serializing_if = "Option::is_none")]
pub threshold: Option<i64>,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct ShrinkMaskOutput {
/// The mask
/// {"content_type":"image/png","height":700,"url":"https://storage.googleapis.com/falserverless/model_tests/workflow_utils/shrink_mask_output.png","width":610}
pub image: Image,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct TeedInput {
/// Input image url.
/// "https://storage.googleapis.com/falserverless/model_tests/retoucher/GGsAolHXsAA58vn.jpeg"
pub image_url: String,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct TeedOutput {
/// The edge map.
/// {"content_type":"image/png","height":2048,"url":"https://storage.googleapis.com/falserverless/model_tests/workflow_utils/teed_output.png","width":1246}
pub image: Image,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct TextOutput {
/// The output text
/// "Hello, World!"
pub text: String,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct TransparentImageToMaskInput {
/// Input image url.
/// "https://storage.googleapis.com/falserverless/model_tests/workflow_utils/transparent_image_to_mask_input.png"
pub image_url: String,
/// The threshold to convert the image to a mask.
/// 128
#[serde(skip_serializing_if = "Option::is_none")]
pub threshold: Option<i64>,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct TransparentImageToMaskOutput {
/// The mask
/// {"content_type":"image/png","height":700,"url":"https://storage.googleapis.com/falserverless/model_tests/workflow_utils/transparent_image_to_mask_output.png","width":610}
pub image: Image,
}
#[derive(Debug, Serialize, Deserialize, Default)]
pub struct ValidationError {
pub loc: Vec<serde_json::Value>,
pub msg: String,
#[serde(rename = "type")]
pub ty: String,
}
/// Image Preprocessors
///
/// Category: image-to-image
/// Machine Type: A6000
pub fn insert_text(params: InsertTextInput) -> FalRequest<InsertTextInput, TextOutput> {
FalRequest::new("fal-ai/workflowutils/insert-text", params)
}