fast_style_transfer_flutter 0.0.2
fast_style_transfer_flutter: ^0.0.2 copied to clipboard
A Flutter package for running **Fast Neural Style Transfer** using **TensorFlow Lite (TFLite)** models, enabling real-time image transformation on **Android** and **iOS** devices **locally** (no inter [...]
Fast Style Transfer Flutter π¨ #
A Flutter package for running Fast Neural Style Transfer using TensorFlow Lite (TFLite) models, enabling real-time image transformation on Android and iOS devices locally (no internet connection required).
π‘ Based on the original Fast Style Transfer by Logan Engstrom and inspired by luiscib3r/style_transfer. Special thanks to them!
π§ How It Works #
- Loads two models:
predict.tflite
: extracts style featurestransfer.tflite
: applies style to the input image
- Preprocesses the input content & style images
- Runs both models sequentially
- Returns JPEG-encoded image as
Uint8List
π Supported Model Loading #
You can load models from:
- Assets (recommended)
- File path (
File
) - Raw bytes (
Uint8List
)
π Installation #
dependencies:
fast_style_transfer_flutter: ^0.0.2
πΈ Example #
final styleTransfer = FastStyleTransferFlutter.init(
config: FastStyleTransferConfig(
thread: 4,
useGPU: true,
loaderConfig: FastStyleAssetsLoaderConfig(
predictResource: 'models/predict.tflite',
styleTransferResource: 'models/transfer.tflite',
),
),
);
final resultImage = await styleTransfer.run(
request: RunTransferRequest(
image: imageBytes, // content image (Uint8List)
style: styleBytes, // style image (Uint8List)
),
);
// Use resultImage as Uint8List (e.g., display or save)
πΈ Screenshots #
[Screen 1] [Screen 2] [Screen 3] [Screen 3]
π₯ Model Download #
You can use pre-trained models provided by TensorFlow:
- magenta_arbitrary-image-stylization-v1-256_int8_prediction_1.tflite
- magenta_arbitrary-image-stylization-v1-256_int8_transfer_1.tflite
These models are compatible with this package and ready to be used.
You can also train or convert your own models based on:
- Original: Fast Style Transfer
- Mobile conversion guide: luiscib3r/style_transfer
π Credits #
- Huge thanks to Logan Engstrom for the original Fast Style Transfer.
- Special appreciation to luiscib3r for mobile adaptation inspiration and open-source contribution.