@teamflojo/floimg-replicate 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +136 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/transforms.d.ts +60 -0
- package/dist/transforms.d.ts.map +1 -0
- package/dist/transforms.js +386 -0
- package/dist/transforms.js.map +1 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Brett Cooke
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# @teamflojo/floimg-replicate
|
|
2
|
+
|
|
3
|
+
Replicate AI model integration for floimg, providing access to popular image processing models.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @teamflojo/floimg-replicate
|
|
9
|
+
# or
|
|
10
|
+
pnpm add @teamflojo/floimg-replicate
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Configuration
|
|
14
|
+
|
|
15
|
+
Set your Replicate API token:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
export REPLICATE_API_TOKEN=your_token_here
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Or pass it directly:
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { replicateTransform } from "@teamflojo/floimg-replicate";
|
|
25
|
+
|
|
26
|
+
const transform = replicateTransform({ apiToken: "your_token_here" });
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Available Transforms
|
|
30
|
+
|
|
31
|
+
### Face Restoration (GFPGAN)
|
|
32
|
+
|
|
33
|
+
Restore and enhance faces in photos:
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
const result = await floimg.transform({
|
|
37
|
+
blob: inputImage,
|
|
38
|
+
op: "faceRestore",
|
|
39
|
+
provider: "replicate-transform",
|
|
40
|
+
params: {
|
|
41
|
+
version: "v1.4", // or "v1.3"
|
|
42
|
+
scale: 2, // upscale factor 1-4
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Colorization (DeOldify)
|
|
48
|
+
|
|
49
|
+
Colorize black and white images:
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
const result = await floimg.transform({
|
|
53
|
+
blob: bwImage,
|
|
54
|
+
op: "colorize",
|
|
55
|
+
provider: "replicate-transform",
|
|
56
|
+
params: {
|
|
57
|
+
renderFactor: 35, // quality 7-45
|
|
58
|
+
artistic: false, // use artistic model for more vibrant colors
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Image Upscaling (Real-ESRGAN)
|
|
64
|
+
|
|
65
|
+
Upscale images with high quality:
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
const result = await floimg.transform({
|
|
69
|
+
blob: inputImage,
|
|
70
|
+
op: "realEsrgan",
|
|
71
|
+
provider: "replicate-transform",
|
|
72
|
+
params: {
|
|
73
|
+
scale: 4, // 2 or 4
|
|
74
|
+
faceEnhance: false, // enable for photos with faces
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Text-Guided Editing (FLUX Kontext)
|
|
80
|
+
|
|
81
|
+
Edit images using natural language:
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
const result = await floimg.transform({
|
|
85
|
+
blob: inputImage,
|
|
86
|
+
op: "fluxEdit",
|
|
87
|
+
provider: "replicate-transform",
|
|
88
|
+
params: {
|
|
89
|
+
prompt: "Make the sky more dramatic with storm clouds",
|
|
90
|
+
aspectRatio: "16:9",
|
|
91
|
+
guidanceScale: 3.5,
|
|
92
|
+
numInferenceSteps: 28,
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Full Example
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
import { createClient } from "@teamflojo/floimg";
|
|
101
|
+
import { replicateTransform } from "@teamflojo/floimg-replicate";
|
|
102
|
+
|
|
103
|
+
const floimg = createClient();
|
|
104
|
+
|
|
105
|
+
// Register the Replicate transform provider
|
|
106
|
+
floimg.registerTransformProvider(
|
|
107
|
+
replicateTransform({
|
|
108
|
+
apiToken: process.env.REPLICATE_API_TOKEN,
|
|
109
|
+
})
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
// Load an image
|
|
113
|
+
const image = await floimg.load("./old-photo.jpg");
|
|
114
|
+
|
|
115
|
+
// Colorize a B&W photo
|
|
116
|
+
const colorized = await floimg.transform({
|
|
117
|
+
blob: image,
|
|
118
|
+
op: "colorize",
|
|
119
|
+
provider: "replicate-transform",
|
|
120
|
+
params: { renderFactor: 40 },
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
// Restore faces
|
|
124
|
+
const restored = await floimg.transform({
|
|
125
|
+
blob: colorized,
|
|
126
|
+
op: "faceRestore",
|
|
127
|
+
provider: "replicate-transform",
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
// Save result
|
|
131
|
+
await floimg.save(restored, "./restored-photo.png");
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## License
|
|
135
|
+
|
|
136
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* floimg-replicate - Replicate AI model integration for floimg
|
|
3
|
+
*
|
|
4
|
+
* This package provides access to popular AI models hosted on Replicate:
|
|
5
|
+
* - GFPGAN: Face restoration and enhancement
|
|
6
|
+
* - DeOldify: Black & white image colorization
|
|
7
|
+
* - Real-ESRGAN: High-quality image upscaling
|
|
8
|
+
* - FLUX Kontext: Text-guided image editing
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
export { replicateTransform, type ReplicateTransformConfig, faceRestoreSchema, colorizeSchema, realEsrganSchema, fluxEditSchema, } from "./transforms.js";
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,kBAAkB,EAClB,KAAK,wBAAwB,EAC7B,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,cAAc,GACf,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* floimg-replicate - Replicate AI model integration for floimg
|
|
3
|
+
*
|
|
4
|
+
* This package provides access to popular AI models hosted on Replicate:
|
|
5
|
+
* - GFPGAN: Face restoration and enhancement
|
|
6
|
+
* - DeOldify: Black & white image colorization
|
|
7
|
+
* - Real-ESRGAN: High-quality image upscaling
|
|
8
|
+
* - FLUX Kontext: Text-guided image editing
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
export { replicateTransform, faceRestoreSchema, colorizeSchema, realEsrganSchema, fluxEditSchema, } from "./transforms.js";
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,kBAAkB,EAElB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,cAAc,GACf,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { TransformProvider, TransformOperationSchema } from "@teamflojo/floimg";
|
|
2
|
+
/**
|
|
3
|
+
* Schema for the face restoration operation using GFPGAN
|
|
4
|
+
*/
|
|
5
|
+
export declare const faceRestoreSchema: TransformOperationSchema;
|
|
6
|
+
/**
|
|
7
|
+
* Schema for the colorization operation using DeOldify
|
|
8
|
+
*/
|
|
9
|
+
export declare const colorizeSchema: TransformOperationSchema;
|
|
10
|
+
/**
|
|
11
|
+
* Schema for the Real-ESRGAN upscaling operation
|
|
12
|
+
*/
|
|
13
|
+
export declare const realEsrganSchema: TransformOperationSchema;
|
|
14
|
+
/**
|
|
15
|
+
* Schema for FLUX Kontext text-guided editing
|
|
16
|
+
*/
|
|
17
|
+
export declare const fluxEditSchema: TransformOperationSchema;
|
|
18
|
+
/**
|
|
19
|
+
* Configuration for the Replicate transform provider
|
|
20
|
+
*/
|
|
21
|
+
export interface ReplicateTransformConfig {
|
|
22
|
+
/** API token for Replicate */
|
|
23
|
+
apiToken?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Create a Replicate transform provider instance
|
|
27
|
+
*
|
|
28
|
+
* Provides AI-powered image transformations via Replicate's model hosting:
|
|
29
|
+
* - faceRestore: Restore and enhance faces using GFPGAN
|
|
30
|
+
* - colorize: Colorize B&W images using DeOldify
|
|
31
|
+
* - realEsrgan: Upscale images using Real-ESRGAN
|
|
32
|
+
* - fluxEdit: Text-guided image editing using FLUX Kontext
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* import createClient from '@teamflojo/floimg';
|
|
37
|
+
* import { replicateTransform } from '@teamflojo/floimg-replicate';
|
|
38
|
+
*
|
|
39
|
+
* const floimg = createClient();
|
|
40
|
+
* floimg.registerTransformProvider(replicateTransform({
|
|
41
|
+
* apiToken: process.env.REPLICATE_API_TOKEN
|
|
42
|
+
* }));
|
|
43
|
+
*
|
|
44
|
+
* // Restore faces in a photo
|
|
45
|
+
* const result = await floimg.transform({
|
|
46
|
+
* blob: inputImage,
|
|
47
|
+
* op: 'faceRestore',
|
|
48
|
+
* provider: 'replicate-transform'
|
|
49
|
+
* });
|
|
50
|
+
*
|
|
51
|
+
* // Colorize a B&W photo
|
|
52
|
+
* const colorized = await floimg.transform({
|
|
53
|
+
* blob: bwImage,
|
|
54
|
+
* op: 'colorize',
|
|
55
|
+
* provider: 'replicate-transform'
|
|
56
|
+
* });
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare function replicateTransform(config?: ReplicateTransformConfig): TransformProvider;
|
|
60
|
+
//# sourceMappingURL=transforms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transforms.d.ts","sourceRoot":"","sources":["../src/transforms.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,iBAAiB,EACjB,wBAAwB,EAGzB,MAAM,mBAAmB,CAAC;AAE3B;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,wBA2B/B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,wBA0B5B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,wBA0B9B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,wBAuD5B,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,8BAA8B;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,GAAE,wBAA6B,GAAG,iBAAiB,CA6Q3F"}
|
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
import Replicate from "replicate";
|
|
2
|
+
/**
|
|
3
|
+
* Schema for the face restoration operation using GFPGAN
|
|
4
|
+
*/
|
|
5
|
+
export const faceRestoreSchema = {
|
|
6
|
+
name: "faceRestore",
|
|
7
|
+
description: "Restore and enhance faces in photos using GFPGAN",
|
|
8
|
+
category: "AI",
|
|
9
|
+
parameters: {
|
|
10
|
+
version: {
|
|
11
|
+
type: "string",
|
|
12
|
+
title: "Version",
|
|
13
|
+
description: "GFPGAN version to use",
|
|
14
|
+
enum: ["v1.3", "v1.4"],
|
|
15
|
+
default: "v1.4",
|
|
16
|
+
},
|
|
17
|
+
scale: {
|
|
18
|
+
type: "number",
|
|
19
|
+
title: "Scale",
|
|
20
|
+
description: "Upscale factor (1-4)",
|
|
21
|
+
default: 2,
|
|
22
|
+
minimum: 1,
|
|
23
|
+
maximum: 4,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
requiredParameters: [],
|
|
27
|
+
inputType: "image",
|
|
28
|
+
outputType: "image",
|
|
29
|
+
isAI: true,
|
|
30
|
+
requiresApiKey: true,
|
|
31
|
+
apiKeyEnvVar: "REPLICATE_API_TOKEN",
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Schema for the colorization operation using DeOldify
|
|
35
|
+
*/
|
|
36
|
+
export const colorizeSchema = {
|
|
37
|
+
name: "colorize",
|
|
38
|
+
description: "Colorize black and white images using DeOldify",
|
|
39
|
+
category: "AI",
|
|
40
|
+
parameters: {
|
|
41
|
+
renderFactor: {
|
|
42
|
+
type: "number",
|
|
43
|
+
title: "Render Factor",
|
|
44
|
+
description: "Quality/speed tradeoff (7-45, higher = better quality but slower)",
|
|
45
|
+
default: 35,
|
|
46
|
+
minimum: 7,
|
|
47
|
+
maximum: 45,
|
|
48
|
+
},
|
|
49
|
+
artistic: {
|
|
50
|
+
type: "boolean",
|
|
51
|
+
title: "Artistic Mode",
|
|
52
|
+
description: "Use artistic colorization model for more vibrant colors",
|
|
53
|
+
default: false,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
requiredParameters: [],
|
|
57
|
+
inputType: "image",
|
|
58
|
+
outputType: "image",
|
|
59
|
+
isAI: true,
|
|
60
|
+
requiresApiKey: true,
|
|
61
|
+
apiKeyEnvVar: "REPLICATE_API_TOKEN",
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Schema for the Real-ESRGAN upscaling operation
|
|
65
|
+
*/
|
|
66
|
+
export const realEsrganSchema = {
|
|
67
|
+
name: "realEsrgan",
|
|
68
|
+
description: "Upscale images using Real-ESRGAN",
|
|
69
|
+
category: "AI",
|
|
70
|
+
parameters: {
|
|
71
|
+
scale: {
|
|
72
|
+
type: "number",
|
|
73
|
+
title: "Scale",
|
|
74
|
+
description: "Upscale factor (2 or 4)",
|
|
75
|
+
default: 4,
|
|
76
|
+
minimum: 2,
|
|
77
|
+
maximum: 4,
|
|
78
|
+
},
|
|
79
|
+
faceEnhance: {
|
|
80
|
+
type: "boolean",
|
|
81
|
+
title: "Face Enhancement",
|
|
82
|
+
description: "Enable face enhancement for photos with faces",
|
|
83
|
+
default: false,
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
requiredParameters: [],
|
|
87
|
+
inputType: "image",
|
|
88
|
+
outputType: "image",
|
|
89
|
+
isAI: true,
|
|
90
|
+
requiresApiKey: true,
|
|
91
|
+
apiKeyEnvVar: "REPLICATE_API_TOKEN",
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Schema for FLUX Kontext text-guided editing
|
|
95
|
+
*/
|
|
96
|
+
export const fluxEditSchema = {
|
|
97
|
+
name: "fluxEdit",
|
|
98
|
+
description: "Edit images using text prompts with FLUX Kontext",
|
|
99
|
+
category: "AI",
|
|
100
|
+
parameters: {
|
|
101
|
+
prompt: {
|
|
102
|
+
type: "string",
|
|
103
|
+
title: "Prompt",
|
|
104
|
+
description: "Describe the desired changes to the image",
|
|
105
|
+
},
|
|
106
|
+
aspectRatio: {
|
|
107
|
+
type: "string",
|
|
108
|
+
title: "Aspect Ratio",
|
|
109
|
+
description: "Output aspect ratio",
|
|
110
|
+
enum: ["1:1", "16:9", "9:16", "4:3", "3:4", "21:9", "9:21"],
|
|
111
|
+
default: "1:1",
|
|
112
|
+
},
|
|
113
|
+
guidanceScale: {
|
|
114
|
+
type: "number",
|
|
115
|
+
title: "Guidance Scale",
|
|
116
|
+
description: "How closely to follow the prompt (1-20)",
|
|
117
|
+
default: 3.5,
|
|
118
|
+
minimum: 1,
|
|
119
|
+
maximum: 20,
|
|
120
|
+
},
|
|
121
|
+
numInferenceSteps: {
|
|
122
|
+
type: "number",
|
|
123
|
+
title: "Inference Steps",
|
|
124
|
+
description: "Number of denoising steps (1-50)",
|
|
125
|
+
default: 28,
|
|
126
|
+
minimum: 1,
|
|
127
|
+
maximum: 50,
|
|
128
|
+
},
|
|
129
|
+
outputFormat: {
|
|
130
|
+
type: "string",
|
|
131
|
+
title: "Output Format",
|
|
132
|
+
description: "Output image format",
|
|
133
|
+
enum: ["webp", "jpg", "png"],
|
|
134
|
+
default: "webp",
|
|
135
|
+
},
|
|
136
|
+
outputQuality: {
|
|
137
|
+
type: "number",
|
|
138
|
+
title: "Output Quality",
|
|
139
|
+
description: "Quality for lossy formats (1-100)",
|
|
140
|
+
default: 80,
|
|
141
|
+
minimum: 1,
|
|
142
|
+
maximum: 100,
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
requiredParameters: ["prompt"],
|
|
146
|
+
inputType: "image",
|
|
147
|
+
outputType: "image",
|
|
148
|
+
isAI: true,
|
|
149
|
+
requiresApiKey: true,
|
|
150
|
+
apiKeyEnvVar: "REPLICATE_API_TOKEN",
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* Create a Replicate transform provider instance
|
|
154
|
+
*
|
|
155
|
+
* Provides AI-powered image transformations via Replicate's model hosting:
|
|
156
|
+
* - faceRestore: Restore and enhance faces using GFPGAN
|
|
157
|
+
* - colorize: Colorize B&W images using DeOldify
|
|
158
|
+
* - realEsrgan: Upscale images using Real-ESRGAN
|
|
159
|
+
* - fluxEdit: Text-guided image editing using FLUX Kontext
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```typescript
|
|
163
|
+
* import createClient from '@teamflojo/floimg';
|
|
164
|
+
* import { replicateTransform } from '@teamflojo/floimg-replicate';
|
|
165
|
+
*
|
|
166
|
+
* const floimg = createClient();
|
|
167
|
+
* floimg.registerTransformProvider(replicateTransform({
|
|
168
|
+
* apiToken: process.env.REPLICATE_API_TOKEN
|
|
169
|
+
* }));
|
|
170
|
+
*
|
|
171
|
+
* // Restore faces in a photo
|
|
172
|
+
* const result = await floimg.transform({
|
|
173
|
+
* blob: inputImage,
|
|
174
|
+
* op: 'faceRestore',
|
|
175
|
+
* provider: 'replicate-transform'
|
|
176
|
+
* });
|
|
177
|
+
*
|
|
178
|
+
* // Colorize a B&W photo
|
|
179
|
+
* const colorized = await floimg.transform({
|
|
180
|
+
* blob: bwImage,
|
|
181
|
+
* op: 'colorize',
|
|
182
|
+
* provider: 'replicate-transform'
|
|
183
|
+
* });
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
export function replicateTransform(config = {}) {
|
|
187
|
+
const apiToken = config.apiToken || process.env.REPLICATE_API_TOKEN;
|
|
188
|
+
if (!apiToken) {
|
|
189
|
+
throw new Error("Replicate API token is required. Set REPLICATE_API_TOKEN environment variable or pass apiToken in config.");
|
|
190
|
+
}
|
|
191
|
+
const replicate = new Replicate({ auth: apiToken });
|
|
192
|
+
const operationSchemas = {
|
|
193
|
+
faceRestore: faceRestoreSchema,
|
|
194
|
+
colorize: colorizeSchema,
|
|
195
|
+
realEsrgan: realEsrganSchema,
|
|
196
|
+
fluxEdit: fluxEditSchema,
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* Convert ImageBlob to data URI for Replicate API
|
|
200
|
+
*/
|
|
201
|
+
function toDataUri(input) {
|
|
202
|
+
const base64 = input.bytes.toString("base64");
|
|
203
|
+
return `data:${input.mime};base64,${base64}`;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Extract URL from Replicate output
|
|
207
|
+
* Different models return different formats (string, array, object with url)
|
|
208
|
+
*/
|
|
209
|
+
function extractUrl(output) {
|
|
210
|
+
if (typeof output === "string") {
|
|
211
|
+
return output;
|
|
212
|
+
}
|
|
213
|
+
if (Array.isArray(output) && output.length > 0) {
|
|
214
|
+
// Some models return array of URLs
|
|
215
|
+
return String(output[0]);
|
|
216
|
+
}
|
|
217
|
+
if (output && typeof output === "object" && "url" in output) {
|
|
218
|
+
return String(output.url);
|
|
219
|
+
}
|
|
220
|
+
throw new Error(`Unexpected output format from Replicate: ${JSON.stringify(output)}`);
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Download result image from URL
|
|
224
|
+
*/
|
|
225
|
+
async function downloadResult(url) {
|
|
226
|
+
const response = await fetch(url);
|
|
227
|
+
if (!response.ok) {
|
|
228
|
+
throw new Error(`Failed to download result: ${response.statusText}`);
|
|
229
|
+
}
|
|
230
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
231
|
+
return Buffer.from(arrayBuffer);
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Restore faces using GFPGAN
|
|
235
|
+
*/
|
|
236
|
+
async function faceRestore(input, params) {
|
|
237
|
+
const { version = "v1.4", scale = 2 } = params;
|
|
238
|
+
const modelVersion = version === "v1.3"
|
|
239
|
+
? "9283608cc6b7be6b65a8e44983db012355fde4132009bf99d976b2f0896856a3"
|
|
240
|
+
: "b9a7ffcc3f0a4b20e8e6d5e3aee40d07d1c4a7d7a9b5b7a7b9a9b7a9b7a9b7a9";
|
|
241
|
+
const output = await replicate.run(`tencentarc/gfpgan:${modelVersion}`, {
|
|
242
|
+
input: {
|
|
243
|
+
img: toDataUri(input),
|
|
244
|
+
version: version,
|
|
245
|
+
scale: scale,
|
|
246
|
+
},
|
|
247
|
+
});
|
|
248
|
+
const resultUrl = extractUrl(output);
|
|
249
|
+
const bytes = await downloadResult(resultUrl);
|
|
250
|
+
return {
|
|
251
|
+
bytes,
|
|
252
|
+
mime: "image/png",
|
|
253
|
+
width: input.width ? input.width * scale : undefined,
|
|
254
|
+
height: input.height ? input.height * scale : undefined,
|
|
255
|
+
source: "ai:replicate:faceRestore",
|
|
256
|
+
metadata: {
|
|
257
|
+
operation: "faceRestore",
|
|
258
|
+
model: "tencentarc/gfpgan",
|
|
259
|
+
version,
|
|
260
|
+
scale,
|
|
261
|
+
},
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Colorize B&W images using DeOldify
|
|
266
|
+
*/
|
|
267
|
+
async function colorize(input, params) {
|
|
268
|
+
const { renderFactor = 35, artistic = false } = params;
|
|
269
|
+
const model = artistic ? "arielreplicate/deoldify_artistic" : "arielreplicate/deoldify_image";
|
|
270
|
+
const output = await replicate.run(model, {
|
|
271
|
+
input: {
|
|
272
|
+
input_image: toDataUri(input),
|
|
273
|
+
render_factor: renderFactor,
|
|
274
|
+
},
|
|
275
|
+
});
|
|
276
|
+
const resultUrl = extractUrl(output);
|
|
277
|
+
const bytes = await downloadResult(resultUrl);
|
|
278
|
+
return {
|
|
279
|
+
bytes,
|
|
280
|
+
mime: "image/png",
|
|
281
|
+
width: input.width,
|
|
282
|
+
height: input.height,
|
|
283
|
+
source: "ai:replicate:colorize",
|
|
284
|
+
metadata: {
|
|
285
|
+
operation: "colorize",
|
|
286
|
+
model,
|
|
287
|
+
renderFactor,
|
|
288
|
+
artistic,
|
|
289
|
+
},
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Upscale images using Real-ESRGAN
|
|
294
|
+
*/
|
|
295
|
+
async function realEsrgan(input, params) {
|
|
296
|
+
const { scale = 4, faceEnhance = false } = params;
|
|
297
|
+
const output = await replicate.run("nightmareai/real-esrgan", {
|
|
298
|
+
input: {
|
|
299
|
+
image: toDataUri(input),
|
|
300
|
+
scale: scale,
|
|
301
|
+
face_enhance: faceEnhance,
|
|
302
|
+
},
|
|
303
|
+
});
|
|
304
|
+
const resultUrl = extractUrl(output);
|
|
305
|
+
const bytes = await downloadResult(resultUrl);
|
|
306
|
+
return {
|
|
307
|
+
bytes,
|
|
308
|
+
mime: "image/png",
|
|
309
|
+
width: input.width ? input.width * scale : undefined,
|
|
310
|
+
height: input.height ? input.height * scale : undefined,
|
|
311
|
+
source: "ai:replicate:realEsrgan",
|
|
312
|
+
metadata: {
|
|
313
|
+
operation: "realEsrgan",
|
|
314
|
+
model: "nightmareai/real-esrgan",
|
|
315
|
+
scale,
|
|
316
|
+
faceEnhance,
|
|
317
|
+
},
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Text-guided image editing using FLUX Kontext
|
|
322
|
+
*/
|
|
323
|
+
async function fluxEdit(input, params) {
|
|
324
|
+
const { prompt, aspectRatio = "1:1", guidanceScale = 3.5, numInferenceSteps = 28, outputFormat = "webp", outputQuality = 80, } = params;
|
|
325
|
+
if (!prompt) {
|
|
326
|
+
throw new Error("prompt is required for FLUX edit");
|
|
327
|
+
}
|
|
328
|
+
const output = await replicate.run("black-forest-labs/flux-kontext", {
|
|
329
|
+
input: {
|
|
330
|
+
image: toDataUri(input),
|
|
331
|
+
prompt,
|
|
332
|
+
aspect_ratio: aspectRatio,
|
|
333
|
+
guidance_scale: guidanceScale,
|
|
334
|
+
num_inference_steps: numInferenceSteps,
|
|
335
|
+
output_format: outputFormat,
|
|
336
|
+
output_quality: outputQuality,
|
|
337
|
+
},
|
|
338
|
+
});
|
|
339
|
+
const resultUrl = extractUrl(output);
|
|
340
|
+
const bytes = await downloadResult(resultUrl);
|
|
341
|
+
// Determine MIME type from output format
|
|
342
|
+
const mimeMap = {
|
|
343
|
+
webp: "image/webp",
|
|
344
|
+
jpg: "image/jpeg",
|
|
345
|
+
png: "image/png",
|
|
346
|
+
};
|
|
347
|
+
return {
|
|
348
|
+
bytes,
|
|
349
|
+
mime: mimeMap[outputFormat] || "image/webp",
|
|
350
|
+
width: input.width,
|
|
351
|
+
height: input.height,
|
|
352
|
+
source: "ai:replicate:fluxEdit",
|
|
353
|
+
metadata: {
|
|
354
|
+
operation: "fluxEdit",
|
|
355
|
+
model: "black-forest-labs/flux-kontext",
|
|
356
|
+
prompt,
|
|
357
|
+
aspectRatio,
|
|
358
|
+
guidanceScale,
|
|
359
|
+
numInferenceSteps,
|
|
360
|
+
},
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
// Operation dispatch map
|
|
364
|
+
const operations = {
|
|
365
|
+
faceRestore: (input, params) => faceRestore(input, params),
|
|
366
|
+
colorize: (input, params) => colorize(input, params),
|
|
367
|
+
realEsrgan: (input, params) => realEsrgan(input, params),
|
|
368
|
+
fluxEdit: (input, params) => fluxEdit(input, params),
|
|
369
|
+
};
|
|
370
|
+
return {
|
|
371
|
+
name: "replicate-transform",
|
|
372
|
+
operationSchemas,
|
|
373
|
+
async transform(input, op, params) {
|
|
374
|
+
const operation = operations[op];
|
|
375
|
+
if (!operation) {
|
|
376
|
+
throw new Error(`Unknown operation: ${op}. Supported: ${Object.keys(operations).join(", ")}`);
|
|
377
|
+
}
|
|
378
|
+
return operation(input, params);
|
|
379
|
+
},
|
|
380
|
+
// Required by interface but we don't support format conversion
|
|
381
|
+
async convert() {
|
|
382
|
+
throw new Error("Replicate transform provider does not support format conversion. Use the sharp provider instead.");
|
|
383
|
+
},
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
//# sourceMappingURL=transforms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transforms.js","sourceRoot":"","sources":["../src/transforms.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAQlC;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAA6B;IACzD,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,kDAAkD;IAC/D,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE;QACV,OAAO,EAAE;YACP,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,SAAS;YAChB,WAAW,EAAE,uBAAuB;YACpC,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;YACtB,OAAO,EAAE,MAAM;SAChB;QACD,KAAK,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,OAAO;YACd,WAAW,EAAE,sBAAsB;YACnC,OAAO,EAAE,CAAC;YACV,OAAO,EAAE,CAAC;YACV,OAAO,EAAE,CAAC;SACX;KACF;IACD,kBAAkB,EAAE,EAAE;IACtB,SAAS,EAAE,OAAO;IAClB,UAAU,EAAE,OAAO;IACnB,IAAI,EAAE,IAAI;IACV,cAAc,EAAE,IAAI;IACpB,YAAY,EAAE,qBAAqB;CACpC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAA6B;IACtD,IAAI,EAAE,UAAU;IAChB,WAAW,EAAE,gDAAgD;IAC7D,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE;QACV,YAAY,EAAE;YACZ,IAAI,EAAE,QAAQ;YACd,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AAE,CAC7E,CAAC;YACJ,CAAC;YACD,OAAO,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAClC,CAAC;QAED,+DAA+D;QAC/D,KAAK,CAAC,OAAO;YACX,MAAM,IAAI,KAAK,CACb,kGAAkG,CACnG,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@teamflojo/floimg-replicate",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Replicate AI model integration for floimg (FLUX, GFPGAN, DeOldify, Real-ESRGAN)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"README.md",
|
|
17
|
+
"LICENSE"
|
|
18
|
+
],
|
|
19
|
+
"keywords": [
|
|
20
|
+
"floimg",
|
|
21
|
+
"replicate",
|
|
22
|
+
"flux",
|
|
23
|
+
"gfpgan",
|
|
24
|
+
"deoldify",
|
|
25
|
+
"real-esrgan",
|
|
26
|
+
"image-generation",
|
|
27
|
+
"image-restoration",
|
|
28
|
+
"ai"
|
|
29
|
+
],
|
|
30
|
+
"author": "Brett Cooke",
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "https://github.com/TeamFlojo/floimg.git",
|
|
35
|
+
"directory": "packages/floimg-replicate"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"@teamflojo/floimg": "^0.2.0"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"replicate": "^1.0.1"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/node": "^22.10.2",
|
|
45
|
+
"typescript": "^5.7.2",
|
|
46
|
+
"vitest": "^2.1.8",
|
|
47
|
+
"@teamflojo/floimg": "0.4.0"
|
|
48
|
+
},
|
|
49
|
+
"engines": {
|
|
50
|
+
"node": ">=18.0.0"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "tsc",
|
|
54
|
+
"dev": "tsc --watch",
|
|
55
|
+
"typecheck": "tsc --noEmit",
|
|
56
|
+
"clean": "rm -rf dist",
|
|
57
|
+
"test": "vitest --run"
|
|
58
|
+
}
|
|
59
|
+
}
|