Quick Start
Hook API
useStyleTransfer(props)
Manages a style transfer model instance.
Parameters
Model configuration object
Prevent automatic model loading
Returns
Error object if loading or inference fails
Whether the model is loaded and ready
Whether the model is currently processing
Download progress (0-1)
Apply artistic style to an image. Returns URI of the styled image (base64 or file path).
Available Styles
STYLE_TRANSFER_CANDY
Bright, colorful candy-like artistic style.- Vibrant colors
- Abstract patterns
- Playful aesthetic
- Inference Time: ~200-300ms
STYLE_TRANSFER_MOSAIC
Stained glass mosaic pattern style.- Geometric patterns
- Bold color blocks
- Stained glass effect
- Inference Time: ~200-300ms
STYLE_TRANSFER_RAIN_PRINCESS
Impressionist painting style inspired by Afremov’s work.- Soft, blended colors
- Impressionist brushstrokes
- Romantic atmosphere
- Inference Time: ~200-300ms
STYLE_TRANSFER_UDNIE
Cubist abstract art style.- Abstract geometric forms
- Cubist aesthetic
- Fragmented shapes
- Inference Time: ~200-300ms
Complete Example
Use Cases
Photo Enhancement App
Create artistic photos:Real-Time Camera Effects
Apply styles to camera captures:Batch Processing
Process multiple images:Social Media Filters
Create shareable artistic content:Style Comparison
Compare multiple styles:Performance Tips
Image Size
Resize large images for faster processing:Model Selection
All style transfer models have similar performance characteristics:- Platform-optimized: CoreML on iOS, XNNPACK on Android
- Inference time: ~200-300ms for 512x512 images
- Memory: ~50-100MB per model
Caching Results
Cache styled images to avoid reprocessing:Progressive Enhancement
Show preview while processing:Custom Styles
Train and use custom style transfer models:Custom models must be trained using the Fast Neural Style Transfer architecture and exported to ExecuTorch
.pte format. See the Custom Models guide for training instructions.Output Format
Theforward function returns styled images as:
- Base64 URI:
data:image/jpeg;base64,... - File URI:
file:///path/to/styled-image.jpg
Image component or save them to the photo library.
Saving Styled Images
Type Reference
Related
- Image Embeddings - Feature extraction
- Semantic Segmentation - Pixel classification
- Custom Models - Train custom styles