@umituz/react-native-ai-generation-content 1.17.228 → 1.17.230
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 +346 -0
- package/package.json +1 -3
- package/src/domain/README.md +503 -0
- package/src/domains/content-moderation/README.md +363 -0
- package/src/domains/creations/README.md +394 -0
- package/src/domains/face-detection/README.md +395 -0
- package/src/domains/prompts/README.md +387 -0
- package/src/features/ai-hug/README.md +276 -0
- package/src/features/ai-kiss/README.md +276 -0
- package/src/features/anime-selfie/README.md +325 -0
- package/src/features/audio-generation/README.md +370 -0
- package/src/features/colorization/README.md +289 -0
- package/src/features/couple-future/README.md +270 -0
- package/src/features/face-swap/README.md +234 -0
- package/src/features/future-prediction/README.md +281 -0
- package/src/features/hd-touch-up/README.md +309 -0
- package/src/features/image-captioning/README.md +361 -0
- package/src/features/image-to-image/README.md +418 -0
- package/src/features/image-to-video/README.md +369 -0
- package/src/features/inpainting/README.md +302 -0
- package/src/features/meme-generator/README.md +327 -0
- package/src/features/photo-restoration/README.md +286 -0
- package/src/features/remove-background/README.md +292 -0
- package/src/features/remove-object/README.md +352 -0
- package/src/features/replace-background/README.md +288 -0
- package/src/features/script-generator/README.md +362 -0
- package/src/features/shared/README.md +280 -0
- package/src/features/sketch-to-image/README.md +296 -0
- package/src/features/style-transfer/README.md +301 -0
- package/src/features/text-to-image/README.md +228 -0
- package/src/features/text-to-video/README.md +245 -0
- package/src/features/text-to-voice/README.md +335 -0
- package/src/features/upscaling/README.md +247 -0
- package/src/infrastructure/config/README.md +310 -0
- package/src/infrastructure/middleware/README.md +378 -0
- package/src/infrastructure/orchestration/README.md +362 -0
- package/src/infrastructure/services/README.md +382 -0
- package/src/infrastructure/utils/README.md +523 -0
- package/src/infrastructure/wrappers/README.md +336 -0
- package/src/presentation/components/README.md +535 -0
- package/src/presentation/hooks/README.md +380 -0
- package/src/presentation/hooks/base/use-dual-image-feature.ts +4 -4
- package/src/presentation/hooks/base/use-image-with-prompt-feature.ts +4 -4
- package/src/presentation/hooks/base/utils/feature-state.factory.ts +1 -1
- package/src/presentation/layouts/README.md +374 -0
- package/src/presentation/layouts/types/layout-props.ts +1 -1
- package/src/presentation/screens/README.md +430 -0
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
# Image Captioning
|
|
2
|
+
|
|
3
|
+
Generate descriptive captions for images using AI.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Generate detailed image descriptions
|
|
8
|
+
- Multiple caption styles (detailed, brief, creative)
|
|
9
|
+
- Support for various image types
|
|
10
|
+
- Keyword extraction
|
|
11
|
+
- Scene and object recognition
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
This feature is part of `@umituz/react-native-ai-generation-content`.
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @umituz/react-native-ai-generation-content
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Basic Usage
|
|
22
|
+
|
|
23
|
+
### Using the Hook
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
import { useImageCaptioning } from '@umituz/react-native-ai-generation-content';
|
|
27
|
+
import * as ImagePicker from 'react-native-image-picker';
|
|
28
|
+
|
|
29
|
+
function ImageCaptioningScreen() {
|
|
30
|
+
const [image, setImage] = useState<string | null>(null);
|
|
31
|
+
|
|
32
|
+
const feature = useImageCaptioning({
|
|
33
|
+
config: {
|
|
34
|
+
captionStyle: 'detailed',
|
|
35
|
+
onProcessingStart: () => console.log('Generating caption...'),
|
|
36
|
+
onProcessingComplete: (result) => console.log('Complete:', result),
|
|
37
|
+
onError: (error) => console.error('Error:', error),
|
|
38
|
+
},
|
|
39
|
+
onSelectImage: async () => {
|
|
40
|
+
const result = await ImagePicker.launchImageLibrary({ mediaType: 'photo' });
|
|
41
|
+
if (result.assets && result.assets[0].uri) {
|
|
42
|
+
const base64 = await convertToBase64(result.assets[0].uri);
|
|
43
|
+
setImage(base64);
|
|
44
|
+
return base64;
|
|
45
|
+
}
|
|
46
|
+
return null;
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<View>
|
|
52
|
+
<PhotoUploadCard
|
|
53
|
+
image={image}
|
|
54
|
+
onSelectImage={feature.selectImage}
|
|
55
|
+
title="Select Image to Caption"
|
|
56
|
+
/>
|
|
57
|
+
|
|
58
|
+
<CaptionStyleSelector
|
|
59
|
+
selectedStyle={feature.state.captionStyle}
|
|
60
|
+
onSelectStyle={feature.setCaptionStyle}
|
|
61
|
+
/>
|
|
62
|
+
|
|
63
|
+
<Button
|
|
64
|
+
title="Generate Caption"
|
|
65
|
+
onPress={feature.process}
|
|
66
|
+
disabled={!feature.isReady || feature.state.isProcessing}
|
|
67
|
+
/>
|
|
68
|
+
|
|
69
|
+
{feature.state.isProcessing && (
|
|
70
|
+
<ActivityIndicator />
|
|
71
|
+
)}
|
|
72
|
+
|
|
73
|
+
{feature.state.result && (
|
|
74
|
+
<View>
|
|
75
|
+
<Text style={{ fontSize: 16, fontWeight: 'bold' }}>
|
|
76
|
+
Caption:
|
|
77
|
+
</Text>
|
|
78
|
+
<Text>{feature.state.result.caption}</Text>
|
|
79
|
+
|
|
80
|
+
{feature.state.result.keywords && (
|
|
81
|
+
<View>
|
|
82
|
+
<Text style={{ fontSize: 14, fontWeight: 'bold' }}>
|
|
83
|
+
Keywords:
|
|
84
|
+
</Text>
|
|
85
|
+
{feature.state.result.keywords.map(keyword => (
|
|
86
|
+
<Text key={keyword}>• {keyword}</Text>
|
|
87
|
+
))}
|
|
88
|
+
</View>
|
|
89
|
+
)}
|
|
90
|
+
|
|
91
|
+
<Button
|
|
92
|
+
title="Copy Caption"
|
|
93
|
+
onPress={() => Clipboard.setString(feature.state.result.caption)}
|
|
94
|
+
/>
|
|
95
|
+
</View>
|
|
96
|
+
)}
|
|
97
|
+
</View>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Configuration Options
|
|
103
|
+
|
|
104
|
+
### Feature Config
|
|
105
|
+
|
|
106
|
+
```tsx
|
|
107
|
+
interface ImageCaptioningFeatureConfig {
|
|
108
|
+
captionStyle?: 'detailed' | 'brief' | 'creative' | 'factual';
|
|
109
|
+
language?: string; // Caption language (default: 'en')
|
|
110
|
+
includeKeywords?: boolean; // Include extracted keywords
|
|
111
|
+
maxCaptionLength?: number; // Maximum caption length
|
|
112
|
+
onProcessingStart?: () => void;
|
|
113
|
+
onProcessingComplete?: (result: ImageCaptioningResult) => void;
|
|
114
|
+
onError?: (error: string) => void;
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Generation Options
|
|
119
|
+
|
|
120
|
+
```tsx
|
|
121
|
+
interface ImageCaptioningOptions {
|
|
122
|
+
captionStyle: 'detailed' | 'brief' | 'creative' | 'factual';
|
|
123
|
+
language?: string;
|
|
124
|
+
includeKeywords?: boolean;
|
|
125
|
+
includeObjects?: boolean; // List detected objects
|
|
126
|
+
includeScene?: boolean; // Describe scene setting
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Caption Styles
|
|
131
|
+
|
|
132
|
+
### Detailed
|
|
133
|
+
|
|
134
|
+
Comprehensive, descriptive captions:
|
|
135
|
+
|
|
136
|
+
```tsx
|
|
137
|
+
const result = await feature.process({
|
|
138
|
+
captionStyle: 'detailed',
|
|
139
|
+
includeObjects: true,
|
|
140
|
+
includeScene: true,
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
// Example: "A serene beach scene at sunset with gentle waves rolling onto the shore.
|
|
144
|
+
// The sky is painted in vibrant shades of orange and pink as the sun dips
|
|
145
|
+
// below the horizon. Seagulls can be seen flying in the distance."
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Brief
|
|
149
|
+
|
|
150
|
+
Short, concise captions:
|
|
151
|
+
|
|
152
|
+
```tsx
|
|
153
|
+
const result = await feature.process({
|
|
154
|
+
captionStyle: 'brief',
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
// Example: "Beach sunset with orange sky"
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Creative
|
|
161
|
+
|
|
162
|
+
Artistic and creative descriptions:
|
|
163
|
+
|
|
164
|
+
```tsx
|
|
165
|
+
const result = await feature.process({
|
|
166
|
+
captionStyle: 'creative',
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
// Example: "Nature's daily masterpiece unfolds as the sun bids farewell,
|
|
170
|
+
// painting the sky in a breathtaking symphony of warm hues."
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Factual
|
|
174
|
+
|
|
175
|
+
Objective, factual descriptions:
|
|
176
|
+
|
|
177
|
+
```tsx
|
|
178
|
+
const result = await feature.process({
|
|
179
|
+
captionStyle: 'factual',
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
// Example: "A beach at sunset. Visible elements include sand, ocean water,
|
|
183
|
+
// sky, sun, and birds. Lighting is natural with warm tones."
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Result Structure
|
|
187
|
+
|
|
188
|
+
```tsx
|
|
189
|
+
interface ImageCaptioningResult {
|
|
190
|
+
caption: string;
|
|
191
|
+
keywords?: string[];
|
|
192
|
+
objects?: string[];
|
|
193
|
+
scene?: string;
|
|
194
|
+
confidence: number;
|
|
195
|
+
language: string;
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## Usage Flow
|
|
200
|
+
|
|
201
|
+
1. Select **Image** - Choose an image to caption
|
|
202
|
+
2. Choose **Caption Style** - Select the desired style
|
|
203
|
+
3. Configure **Options** - Enable/disable keywords, objects, scene
|
|
204
|
+
4. Tap **Generate** - Create the caption
|
|
205
|
+
5. View Result - See the generated caption and metadata
|
|
206
|
+
6. Copy or Share - Copy to clipboard or share
|
|
207
|
+
|
|
208
|
+
## Component Examples
|
|
209
|
+
|
|
210
|
+
### Caption Style Selector
|
|
211
|
+
|
|
212
|
+
```tsx
|
|
213
|
+
import { GridSelector } from '@umituz/react-native-ai-generation-content';
|
|
214
|
+
|
|
215
|
+
const styles = [
|
|
216
|
+
{ id: 'detailed', name: 'Detailed', description: 'Comprehensive description' },
|
|
217
|
+
{ id: 'brief', name: 'Brief', description: 'Short and concise' },
|
|
218
|
+
{ id: 'creative', name: 'Creative', description: 'Artistic description' },
|
|
219
|
+
{ id: 'factual', name: 'Factual', description: 'Objective description' },
|
|
220
|
+
];
|
|
221
|
+
|
|
222
|
+
<GridSelector
|
|
223
|
+
options={styles}
|
|
224
|
+
selectedOption={selectedStyle}
|
|
225
|
+
onSelectOption={setSelectedStyle}
|
|
226
|
+
/>
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Caption Display
|
|
230
|
+
|
|
231
|
+
```tsx
|
|
232
|
+
import { View, Text } from 'react-native';
|
|
233
|
+
|
|
234
|
+
function CaptionDisplay({ result }) {
|
|
235
|
+
return (
|
|
236
|
+
<View style={{ padding: 16 }}>
|
|
237
|
+
<Text style={{ fontSize: 18, fontWeight: 'bold', marginBottom: 8 }}>
|
|
238
|
+
{result.caption}
|
|
239
|
+
</Text>
|
|
240
|
+
|
|
241
|
+
{result.keywords && (
|
|
242
|
+
<View style={{ marginTop: 16 }}>
|
|
243
|
+
<Text style={{ fontSize: 14, fontWeight: 'bold', marginBottom: 4 }}>
|
|
244
|
+
Keywords:
|
|
245
|
+
</Text>
|
|
246
|
+
<View style={{ flexDirection: 'row', flexWrap: 'wrap' }}>
|
|
247
|
+
{result.keywords.map(keyword => (
|
|
248
|
+
<View
|
|
249
|
+
key={keyword}
|
|
250
|
+
style={{
|
|
251
|
+
backgroundColor: '#E0E0E0',
|
|
252
|
+
borderRadius: 16,
|
|
253
|
+
padding: 8,
|
|
254
|
+
marginRight: 8,
|
|
255
|
+
marginBottom: 8,
|
|
256
|
+
}}
|
|
257
|
+
>
|
|
258
|
+
<Text>{keyword}</Text>
|
|
259
|
+
</View>
|
|
260
|
+
))}
|
|
261
|
+
</View>
|
|
262
|
+
</View>
|
|
263
|
+
)}
|
|
264
|
+
|
|
265
|
+
{result.objects && (
|
|
266
|
+
<View style={{ marginTop: 16 }}>
|
|
267
|
+
<Text style={{ fontSize: 14, fontWeight: 'bold', marginBottom: 4 }}>
|
|
268
|
+
Objects:
|
|
269
|
+
</Text>
|
|
270
|
+
<Text>{result.objects.join(', ')}</Text>
|
|
271
|
+
</View>
|
|
272
|
+
)}
|
|
273
|
+
|
|
274
|
+
{result.scene && (
|
|
275
|
+
<View style={{ marginTop: 16 }}>
|
|
276
|
+
<Text style={{ fontSize: 14, fontWeight: 'bold', marginBottom: 4 }}>
|
|
277
|
+
Scene:
|
|
278
|
+
</Text>
|
|
279
|
+
<Text>{result.scene}</Text>
|
|
280
|
+
</View>
|
|
281
|
+
)}
|
|
282
|
+
|
|
283
|
+
<Text style={{ marginTop: 16, fontSize: 12, color: '#666' }}>
|
|
284
|
+
Confidence: {Math.round(result.confidence * 100)}%
|
|
285
|
+
</Text>
|
|
286
|
+
</View>
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### Copy to Clipboard
|
|
292
|
+
|
|
293
|
+
```tsx
|
|
294
|
+
import { Clipboard, Alert } from 'react-native';
|
|
295
|
+
|
|
296
|
+
const handleCopy = async (caption: string) => {
|
|
297
|
+
await Clipboard.setString(caption);
|
|
298
|
+
Alert.alert('Copied', 'Caption copied to clipboard');
|
|
299
|
+
};
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
## Use Cases
|
|
303
|
+
|
|
304
|
+
### Social Media Captions
|
|
305
|
+
|
|
306
|
+
```tsx
|
|
307
|
+
// Generate Instagram/Twitter captions
|
|
308
|
+
const result = await feature.process({
|
|
309
|
+
captionStyle: 'creative',
|
|
310
|
+
maxCaptionLength: 2200, // Instagram limit
|
|
311
|
+
});
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
### Accessibility
|
|
315
|
+
|
|
316
|
+
```tsx
|
|
317
|
+
// Generate alt text for accessibility
|
|
318
|
+
const result = await feature.process({
|
|
319
|
+
captionStyle: 'factual',
|
|
320
|
+
maxCaptionLength: 125, // Recommended alt text length
|
|
321
|
+
});
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
### Content Management
|
|
325
|
+
|
|
326
|
+
```tsx
|
|
327
|
+
// Auto-generate image descriptions for CMS
|
|
328
|
+
const result = await feature.process({
|
|
329
|
+
captionStyle: 'detailed',
|
|
330
|
+
includeKeywords: true,
|
|
331
|
+
includeObjects: true,
|
|
332
|
+
});
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
### SEO
|
|
336
|
+
|
|
337
|
+
```tsx
|
|
338
|
+
// Generate SEO-friendly image descriptions
|
|
339
|
+
const result = await feature.process({
|
|
340
|
+
captionStyle: 'detailed',
|
|
341
|
+
includeKeywords: true,
|
|
342
|
+
});
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
## Best Practices
|
|
346
|
+
|
|
347
|
+
1. **Image Quality**: Clear, high-quality images produce better captions
|
|
348
|
+
2. **Style Selection**: Match style to your use case
|
|
349
|
+
3. **Length Control**: Use maxCaptionLength for platform limits
|
|
350
|
+
4. **Review**: Always review and edit generated captions
|
|
351
|
+
5. **Keywords**: Enable keywords for better categorization
|
|
352
|
+
|
|
353
|
+
## Related Features
|
|
354
|
+
|
|
355
|
+
- [Text to Image](../text-to-image) - Generate images from descriptions
|
|
356
|
+
- [Script Generator](../script-generator) - Generate content scripts
|
|
357
|
+
- [Audio Generation](../audio-generation) - Generate audio content
|
|
358
|
+
|
|
359
|
+
## License
|
|
360
|
+
|
|
361
|
+
MIT
|