@umituz/react-native-ai-generation-content 1.17.232 → 1.17.233
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/README.md +236 -261
- package/package.json +1 -1
- package/src/domains/content-moderation/README.md +239 -296
- package/src/domains/creations/README.md +242 -325
- package/src/domains/face-detection/README.md +228 -307
- package/src/domains/prompts/README.md +242 -312
- package/src/features/ai-hug/README.md +381 -219
- package/src/features/ai-kiss/README.md +388 -219
- package/src/features/anime-selfie/README.md +327 -256
- package/src/features/audio-generation/README.md +352 -309
- package/src/features/colorization/README.md +332 -228
- package/src/features/couple-future/README.md +387 -212
- package/src/features/future-prediction/README.md +391 -221
- package/src/features/hd-touch-up/README.md +339 -252
- package/src/features/image-captioning/README.md +359 -299
- package/src/features/image-to-image/README.md +398 -357
- package/src/features/image-to-video/README.md +337 -292
- package/src/features/inpainting/README.md +348 -244
- package/src/features/meme-generator/README.md +350 -269
- package/src/features/remove-background/README.md +335 -234
- package/src/features/remove-object/README.md +341 -288
- package/src/features/replace-background/README.md +353 -236
- package/src/features/script-generator/README.md +358 -287
- package/src/features/shared/README.md +254 -223
- package/src/features/sketch-to-image/README.md +331 -234
- package/src/features/style-transfer/README.md +336 -237
- package/src/features/text-to-video/README.md +360 -193
- package/src/features/text-to-voice/README.md +382 -272
|
@@ -1,361 +1,421 @@
|
|
|
1
|
-
# Image Captioning
|
|
1
|
+
# Image Captioning Feature
|
|
2
2
|
|
|
3
3
|
Generate descriptive captions for images using AI.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## 📍 Import Path
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
- Keyword extraction
|
|
11
|
-
- Scene and object recognition
|
|
7
|
+
```typescript
|
|
8
|
+
import { useImageCaptioningFeature } from '@umituz/react-native-ai-generation-content';
|
|
9
|
+
```
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
**Location**: `src/features/image-captioning/`
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
## 🎯 Feature Purpose
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
npm install @umituz/react-native-ai-generation-content
|
|
19
|
-
```
|
|
15
|
+
Generate detailed, descriptive captions for images using AI. Supports multiple caption styles (detailed, brief, creative, factual) with keyword extraction, object recognition, and scene description capabilities.
|
|
20
16
|
|
|
21
|
-
|
|
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
|
-
```
|
|
17
|
+
---
|
|
101
18
|
|
|
102
|
-
##
|
|
19
|
+
## 📋 Usage Strategy
|
|
103
20
|
|
|
104
|
-
### Feature
|
|
21
|
+
### When to Use This Feature
|
|
105
22
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
onProcessingStart?: () => void;
|
|
113
|
-
onProcessingComplete?: (result: ImageCaptioningResult) => void;
|
|
114
|
-
onError?: (error: string) => void;
|
|
115
|
-
}
|
|
116
|
-
```
|
|
23
|
+
✅ **Use Cases:**
|
|
24
|
+
- Generating social media captions
|
|
25
|
+
- Creating alt text for accessibility
|
|
26
|
+
- Auto-generating image descriptions for CMS
|
|
27
|
+
- SEO-friendly image descriptions
|
|
28
|
+
- Content management and organization
|
|
117
29
|
|
|
118
|
-
|
|
30
|
+
❌ **When NOT to Use:**
|
|
31
|
+
- Generating images from descriptions (use Text to Image)
|
|
32
|
+
- Detailed image analysis beyond captions (use image analysis tools)
|
|
33
|
+
- Real-time video captioning
|
|
34
|
+
- Multi-image comparisons
|
|
119
35
|
|
|
120
|
-
|
|
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
|
-
```
|
|
36
|
+
### Implementation Strategy
|
|
129
37
|
|
|
130
|
-
|
|
38
|
+
1. **Select image** to caption
|
|
39
|
+
2. **Choose caption style** (detailed, brief, creative, factual)
|
|
40
|
+
3. **Configure options** (keywords, objects, scene)
|
|
41
|
+
4. **Generate caption** with progress tracking
|
|
42
|
+
5. **Review result** with metadata
|
|
43
|
+
6. **Copy or share** caption
|
|
131
44
|
|
|
132
|
-
|
|
45
|
+
---
|
|
133
46
|
|
|
134
|
-
|
|
47
|
+
## ⚠️ Critical Rules (MUST FOLLOW)
|
|
135
48
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
49
|
+
### 1. Image Requirements
|
|
50
|
+
- **MUST** provide ONE image to caption
|
|
51
|
+
- **MUST** use clear, appropriate images
|
|
52
|
+
- **MUST** have visible content
|
|
53
|
+
- **MUST NOT** exceed file size limits (10MB max)
|
|
54
|
+
- **MUST** respect copyright and usage rights
|
|
142
55
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
56
|
+
### 2. Configuration
|
|
57
|
+
- **MUST** provide valid `userId` for tracking
|
|
58
|
+
- **MUST** specify `captionStyle` (detailed, brief, creative, factual)
|
|
59
|
+
- **MUST** implement `onError` callback
|
|
60
|
+
- **MUST** implement `onSelectImage` callback
|
|
61
|
+
- **MUST** handle caption display and copying
|
|
147
62
|
|
|
148
|
-
###
|
|
63
|
+
### 3. State Management
|
|
64
|
+
- **MUST** check `isReady` before enabling generate button
|
|
65
|
+
- **MUST** display progress during generation
|
|
66
|
+
- **MUST** handle `isProcessing` state to prevent duplicate requests
|
|
67
|
+
- **MUST** display `error` state with clear messages
|
|
68
|
+
- **MUST** implement proper cleanup on unmount
|
|
149
69
|
|
|
150
|
-
|
|
70
|
+
### 4. Performance
|
|
71
|
+
- **MUST** implement image compression before upload
|
|
72
|
+
- **MUST** show progress indicator for processing
|
|
73
|
+
- **MUST** cache results locally
|
|
74
|
+
- **MUST** allow users to cancel processing
|
|
75
|
+
- **MUST NOT** generate multiple captions simultaneously
|
|
151
76
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
77
|
+
### 5. Content Quality
|
|
78
|
+
- **MUST** provide caption with confidence score
|
|
79
|
+
- **MUST** support optional metadata (keywords, objects, scene)
|
|
80
|
+
- **MUST** handle various image types
|
|
81
|
+
- **MUST** support multiple caption styles
|
|
82
|
+
- **MUST** offer regeneration with different styles
|
|
156
83
|
|
|
157
|
-
|
|
158
|
-
```
|
|
84
|
+
---
|
|
159
85
|
|
|
160
|
-
|
|
86
|
+
## 🚫 Prohibitions (MUST AVOID)
|
|
161
87
|
|
|
162
|
-
|
|
88
|
+
### Strictly Forbidden
|
|
163
89
|
|
|
164
|
-
|
|
165
|
-
const result = await feature.process({
|
|
166
|
-
captionStyle: 'creative',
|
|
167
|
-
});
|
|
90
|
+
❌ **NEVER** do the following:
|
|
168
91
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
92
|
+
1. **No Missing Images**
|
|
93
|
+
- Always validate image is selected
|
|
94
|
+
- Never call process() without image
|
|
95
|
+
- Show clear upload prompt
|
|
96
|
+
|
|
97
|
+
2. **No Auto-Processing**
|
|
98
|
+
- Never start captioning without user action
|
|
99
|
+
- Always require explicit "Generate" button press
|
|
100
|
+
- Show preview before processing
|
|
101
|
+
|
|
102
|
+
3. **No Hardcoded Credentials**
|
|
103
|
+
- Never store API keys in component files
|
|
104
|
+
- Use environment variables or secure storage
|
|
105
|
+
|
|
106
|
+
4. **No Unhandled Errors**
|
|
107
|
+
- Never ignore captioning failures
|
|
108
|
+
- Always explain what went wrong
|
|
109
|
+
- Provide retry or alternative options
|
|
172
110
|
|
|
173
|
-
|
|
111
|
+
5. **No Memory Leaks**
|
|
112
|
+
- Never store both image and caption unnecessarily
|
|
113
|
+
- Clean up temporary images
|
|
114
|
+
- Implement proper image disposal
|
|
174
115
|
|
|
175
|
-
|
|
116
|
+
6. **No Blocked UI**
|
|
117
|
+
- Never block main thread with image processing
|
|
118
|
+
- Always show progress indicator
|
|
119
|
+
- Allow cancellation
|
|
176
120
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
121
|
+
7. **No Copyright Issues**
|
|
122
|
+
- Never claim copyright on generated captions
|
|
123
|
+
- Respect image usage rights
|
|
124
|
+
- Provide attribution when needed
|
|
181
125
|
|
|
182
|
-
|
|
183
|
-
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## 🤖 AI Agent Directions
|
|
129
|
+
|
|
130
|
+
### For AI Code Generation Tools
|
|
131
|
+
|
|
132
|
+
When using this feature with AI code generation tools, follow these guidelines:
|
|
133
|
+
|
|
134
|
+
#### Prompt Template for AI Agents
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
You are implementing an image captioning feature using @umituz/react-native-ai-generation-content.
|
|
138
|
+
|
|
139
|
+
REQUIREMENTS:
|
|
140
|
+
1. Import from: @umituz/react-native-ai-generation-content
|
|
141
|
+
2. Use the useImageCaptioningFeature hook
|
|
142
|
+
3. Select caption style (detailed, brief, creative, factual)
|
|
143
|
+
4. Implement image selection UI
|
|
144
|
+
5. Configure options (keywords, objects, scene)
|
|
145
|
+
6. Validate image before captioning
|
|
146
|
+
7. Display caption with metadata
|
|
147
|
+
8. Handle long processing times with progress
|
|
148
|
+
9. Implement proper error handling
|
|
149
|
+
10. Implement cleanup on unmount
|
|
150
|
+
|
|
151
|
+
CRITICAL RULES:
|
|
152
|
+
- MUST validate image before calling process()
|
|
153
|
+
- MUST display caption with confidence score
|
|
154
|
+
- MUST handle caption style selection
|
|
155
|
+
- MUST handle optional metadata options
|
|
156
|
+
- MUST implement debouncing (300ms)
|
|
157
|
+
- MUST allow regeneration with different styles
|
|
158
|
+
- MUST implement copy to clipboard functionality
|
|
159
|
+
|
|
160
|
+
CONFIGURATION:
|
|
161
|
+
- Provide valid userId (string)
|
|
162
|
+
- Set captionStyle: 'detailed' | 'brief' | 'creative' | 'factual'
|
|
163
|
+
- Set language?: string (caption language, default: 'en')
|
|
164
|
+
- Set includeKeywords?: boolean (include extracted keywords)
|
|
165
|
+
- Set maxCaptionLength?: number (maximum caption length)
|
|
166
|
+
- Implement onSelectImage callback
|
|
167
|
+
- Configure callbacks: onProcessingStart, onProcessingComplete, onError
|
|
168
|
+
|
|
169
|
+
CAPTION STYLES:
|
|
170
|
+
- detailed: Comprehensive, descriptive captions
|
|
171
|
+
- brief: Short, concise captions
|
|
172
|
+
- creative: Artistic and creative descriptions
|
|
173
|
+
- factual: Objective, factual descriptions
|
|
174
|
+
|
|
175
|
+
OPTIONS:
|
|
176
|
+
- includeKeywords: Extract and include keywords (default: false)
|
|
177
|
+
- includeObjects: List detected objects (default: false)
|
|
178
|
+
- includeScene: Describe scene setting (default: false)
|
|
179
|
+
- maxCaptionLength: Limit caption length (default: unlimited)
|
|
180
|
+
- language: Caption language (default: 'en')
|
|
181
|
+
|
|
182
|
+
STRICTLY FORBIDDEN:
|
|
183
|
+
- No missing image validation
|
|
184
|
+
- No auto-processing without user action
|
|
185
|
+
- No hardcoded API keys
|
|
186
|
+
- No unhandled errors
|
|
187
|
+
- No memory leaks
|
|
188
|
+
- No blocking UI
|
|
189
|
+
- No copyright issues
|
|
190
|
+
|
|
191
|
+
QUALITY CHECKLIST:
|
|
192
|
+
- [ ] Image selection implemented
|
|
193
|
+
- [ ] Caption style selector added
|
|
194
|
+
- [ ] Optional metadata toggles included
|
|
195
|
+
- [ ] Validation before process()
|
|
196
|
+
- [ ] Caption display with confidence score
|
|
197
|
+
- [ ] Keywords/objects/scene display (when enabled)
|
|
198
|
+
- [ ] Progress indicator during processing
|
|
199
|
+
- [ ] Error display with retry option
|
|
200
|
+
- [ ] Copy to clipboard functionality
|
|
201
|
+
- [ ] Regeneration with different styles
|
|
184
202
|
```
|
|
185
203
|
|
|
186
|
-
|
|
204
|
+
#### AI Implementation Checklist
|
|
205
|
+
|
|
206
|
+
Use this checklist when generating code:
|
|
207
|
+
|
|
208
|
+
- [ ] Feature imported from correct path
|
|
209
|
+
- [ ] Image selection implemented
|
|
210
|
+
- [ ] Caption style selector added
|
|
211
|
+
- [ ] Metadata toggles implemented
|
|
212
|
+
- [ ] Validation before process()
|
|
213
|
+
- [ ] Caption display with confidence
|
|
214
|
+
- [ ] Keywords display (when enabled)
|
|
215
|
+
- [ ] Objects display (when enabled)
|
|
216
|
+
- [ ] Scene display (when enabled)
|
|
217
|
+
- [ ] Progress indicator during processing
|
|
218
|
+
- [ ] Error display with user-friendly message
|
|
219
|
+
- [ ] Copy to clipboard button
|
|
220
|
+
- [ ] Regeneration option
|
|
221
|
+
- [ ] Cleanup on unmount
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
## 🛠️ Configuration Strategy
|
|
226
|
+
|
|
227
|
+
### Essential Configuration
|
|
228
|
+
|
|
229
|
+
```typescript
|
|
230
|
+
// Required fields
|
|
231
|
+
{
|
|
232
|
+
userId: string
|
|
233
|
+
captionStyle: 'detailed' | 'brief' | 'creative' | 'factual'
|
|
234
|
+
onSelectImage: () => Promise<string | null>
|
|
235
|
+
}
|
|
187
236
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
237
|
+
// Optional callbacks
|
|
238
|
+
{
|
|
239
|
+
includeKeywords?: boolean
|
|
240
|
+
includeObjects?: boolean
|
|
241
|
+
includeScene?: boolean
|
|
242
|
+
maxCaptionLength?: number
|
|
243
|
+
onProcessingStart?: () => void
|
|
244
|
+
onProcessingComplete?: (result) => void
|
|
245
|
+
onError?: (error: string) => void
|
|
196
246
|
}
|
|
197
247
|
```
|
|
198
248
|
|
|
199
|
-
|
|
249
|
+
### Recommended Settings
|
|
200
250
|
|
|
201
|
-
1.
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
6. Copy or Share - Copy to clipboard or share
|
|
251
|
+
1. **Caption Styles**
|
|
252
|
+
- Detailed: Comprehensive descriptions (recommended for CMS)
|
|
253
|
+
- Brief: Short captions (social media, alt text)
|
|
254
|
+
- Creative: Artistic descriptions (marketing, storytelling)
|
|
255
|
+
- Factual: Objective descriptions (accessibility, documentation)
|
|
207
256
|
|
|
208
|
-
|
|
257
|
+
2. **Metadata Options**
|
|
258
|
+
- includeKeywords: Extract key terms for categorization
|
|
259
|
+
- includeObjects: List detected objects
|
|
260
|
+
- includeScene: Describe environment/setting
|
|
209
261
|
|
|
210
|
-
|
|
262
|
+
3. **Length Limits**
|
|
263
|
+
- Alt text: 125 characters recommended
|
|
264
|
+
- Instagram: 2200 characters maximum
|
|
265
|
+
- Twitter: 280 characters maximum
|
|
266
|
+
- No limit for CMS/documentation
|
|
211
267
|
|
|
212
|
-
|
|
213
|
-
import { GridSelector } from '@umituz/react-native-ai-generation-content';
|
|
268
|
+
---
|
|
214
269
|
|
|
215
|
-
|
|
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
|
-
];
|
|
270
|
+
## 📊 State Management
|
|
221
271
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
272
|
+
### Feature States
|
|
273
|
+
|
|
274
|
+
**isReady**: boolean
|
|
275
|
+
- Image selected and validated
|
|
276
|
+
- Check before enabling generate button
|
|
277
|
+
|
|
278
|
+
**isProcessing**: boolean
|
|
279
|
+
- Caption generation in progress
|
|
280
|
+
- Show loading/progress indicator
|
|
281
|
+
- Disable generate button
|
|
228
282
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
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
|
-
);
|
|
283
|
+
**progress**: number (0-100)
|
|
284
|
+
- Generation progress percentage
|
|
285
|
+
- Update progress bar
|
|
286
|
+
|
|
287
|
+
**error**: string | null
|
|
288
|
+
- Error message if generation failed
|
|
289
|
+
- Display to user with clear message
|
|
290
|
+
|
|
291
|
+
**result**: {
|
|
292
|
+
caption: string
|
|
293
|
+
keywords?: string[]
|
|
294
|
+
objects?: string[]
|
|
295
|
+
scene?: string
|
|
296
|
+
confidence: number
|
|
297
|
+
language: string
|
|
288
298
|
}
|
|
289
|
-
```
|
|
290
299
|
|
|
291
|
-
|
|
300
|
+
---
|
|
292
301
|
|
|
293
|
-
|
|
294
|
-
import { Clipboard, Alert } from 'react-native';
|
|
302
|
+
## 🎨 Best Practices
|
|
295
303
|
|
|
296
|
-
|
|
297
|
-
await Clipboard.setString(caption);
|
|
298
|
-
Alert.alert('Copied', 'Caption copied to clipboard');
|
|
299
|
-
};
|
|
300
|
-
```
|
|
304
|
+
### Caption Style Selection
|
|
301
305
|
|
|
302
|
-
|
|
306
|
+
1. **Detailed**
|
|
307
|
+
- Use for: CMS, documentation, comprehensive descriptions
|
|
308
|
+
- Best: High-quality, content-rich images
|
|
309
|
+
- Example: "A serene beach scene at sunset with gentle waves rolling onto the shore. The sky is painted in vibrant shades of orange and pink as the sun dips below the horizon."
|
|
303
310
|
|
|
304
|
-
|
|
311
|
+
2. **Brief**
|
|
312
|
+
- Use for: Social media, quick summaries, alt text
|
|
313
|
+
- Best: Any image type
|
|
314
|
+
- Example: "Beach sunset with orange sky"
|
|
305
315
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
maxCaptionLength: 2200, // Instagram limit
|
|
311
|
-
});
|
|
312
|
-
```
|
|
316
|
+
3. **Creative**
|
|
317
|
+
- Use for: Marketing, storytelling, artistic content
|
|
318
|
+
- Best: Visually striking or emotional images
|
|
319
|
+
- Example: "Nature's daily masterpiece unfolds as the sun bids farewell, painting the sky in a breathtaking symphony of warm hues."
|
|
313
320
|
|
|
314
|
-
|
|
321
|
+
4. **Factual**
|
|
322
|
+
- Use for: Accessibility, documentation, objective needs
|
|
323
|
+
- Best: Any image type
|
|
324
|
+
- Example: "A beach at sunset. Visible elements include sand, ocean water, sky, sun, and birds."
|
|
315
325
|
|
|
316
|
-
|
|
317
|
-
// Generate alt text for accessibility
|
|
318
|
-
const result = await feature.process({
|
|
319
|
-
captionStyle: 'factual',
|
|
320
|
-
maxCaptionLength: 125, // Recommended alt text length
|
|
321
|
-
});
|
|
322
|
-
```
|
|
326
|
+
### Use Case Matching
|
|
323
327
|
|
|
324
|
-
|
|
328
|
+
1. **Social Media**
|
|
329
|
+
- Style: Brief or Creative
|
|
330
|
+
- Length: Match platform limits
|
|
331
|
+
- Include keywords: Yes
|
|
325
332
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
includeKeywords: true,
|
|
331
|
-
includeObjects: true,
|
|
332
|
-
});
|
|
333
|
-
```
|
|
333
|
+
2. **Accessibility (Alt Text)**
|
|
334
|
+
- Style: Factual or Brief
|
|
335
|
+
- Length: 125 characters
|
|
336
|
+
- Include keywords: Optional
|
|
334
337
|
|
|
335
|
-
|
|
338
|
+
3. **CMS/Documentation**
|
|
339
|
+
- Style: Detailed
|
|
340
|
+
- Length: No limit
|
|
341
|
+
- Include all metadata: Yes
|
|
336
342
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
343
|
+
---
|
|
344
|
+
|
|
345
|
+
## 🐛 Common Pitfalls
|
|
346
|
+
|
|
347
|
+
### Quality Issues
|
|
348
|
+
|
|
349
|
+
❌ **Problem**: Caption doesn't match image content
|
|
350
|
+
✅ **Solution**: Try different caption style, improve image quality
|
|
351
|
+
|
|
352
|
+
### Length Issues
|
|
353
|
+
|
|
354
|
+
❌ **Problem**: Caption too long for platform
|
|
355
|
+
✅ **Solution**: Use maxCaptionLength parameter
|
|
356
|
+
|
|
357
|
+
### Missing Metadata
|
|
358
|
+
|
|
359
|
+
❌ **Problem**: Keywords or objects not showing
|
|
360
|
+
✅ **Solution**: Enable includeKeywords and includeObjects options
|
|
361
|
+
|
|
362
|
+
### Confidence Issues
|
|
363
|
+
|
|
364
|
+
❌ **Problem**: Low confidence caption
|
|
365
|
+
✅ **Solution**: Review and edit caption, improve image quality
|
|
366
|
+
|
|
367
|
+
---
|
|
368
|
+
|
|
369
|
+
## 📦 Related Components
|
|
370
|
+
|
|
371
|
+
Use these components from the library:
|
|
372
|
+
|
|
373
|
+
- **PhotoUploadCard**: Upload image interface
|
|
374
|
+
- **CaptionStyleSelector**: Choose caption style
|
|
375
|
+
- **MetadataToggles**: Enable/disable keywords, objects, scene
|
|
376
|
+
- **CaptionDisplay**: Display caption with metadata
|
|
377
|
+
- **CopyButton**: Copy caption to clipboard
|
|
378
|
+
- **ProgressBar**: Progress display
|
|
379
|
+
|
|
380
|
+
Located at: `src/presentation/components/`
|
|
381
|
+
|
|
382
|
+
---
|
|
383
|
+
|
|
384
|
+
## 🔄 Migration Strategy
|
|
385
|
+
|
|
386
|
+
If migrating from previous implementation:
|
|
387
|
+
|
|
388
|
+
1. **Update imports** to new path
|
|
389
|
+
2. **Add caption style selector**
|
|
390
|
+
3. **Implement metadata toggles**
|
|
391
|
+
4. **Add copy to clipboard functionality**
|
|
392
|
+
5. **Update state handling** for new structure
|
|
393
|
+
6. **Display confidence scores**
|
|
394
|
+
7. **Test all caption styles**
|
|
395
|
+
|
|
396
|
+
---
|
|
397
|
+
|
|
398
|
+
## 📚 Additional Resources
|
|
399
|
+
|
|
400
|
+
- Main documentation: `/docs/`
|
|
401
|
+
- API reference: `/docs/api/`
|
|
402
|
+
- Examples: `/docs/examples/basic/image-captioning/`
|
|
403
|
+
- Architecture: `/ARCHITECTURE.md`
|
|
344
404
|
|
|
345
|
-
|
|
405
|
+
---
|
|
346
406
|
|
|
347
|
-
|
|
348
|
-
|
|
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
|
|
407
|
+
**Last Updated**: 2025-01-08
|
|
408
|
+
**Version**: 2.0.0 (Strategy-based Documentation)
|
|
352
409
|
|
|
353
|
-
|
|
410
|
+
---
|
|
354
411
|
|
|
355
|
-
|
|
356
|
-
- [Script Generator](../script-generator) - Generate content scripts
|
|
357
|
-
- [Audio Generation](../audio-generation) - Generate audio content
|
|
412
|
+
## 📝 Changelog
|
|
358
413
|
|
|
359
|
-
|
|
414
|
+
### v2.0.0 - 2025-01-08
|
|
415
|
+
- **BREAKING**: Documentation format changed to strategy-based
|
|
416
|
+
- Removed extensive code examples
|
|
417
|
+
- Added rules, prohibitions, and AI agent directions
|
|
418
|
+
- Focus on best practices and implementation guidance
|
|
360
419
|
|
|
361
|
-
|
|
420
|
+
### v1.0.0 - Initial Release
|
|
421
|
+
- Initial feature documentation
|