Florence-2 β€” Core ML

Microsoft, 2024

Vision-language captioning, OCR, and VQA. Three-stage encoder-decoder. 768Γ—768 input.

Florence-2 demo Florence-2 demo

Core ML conversion of microsoft/Florence-2 for on-device inference on iPhone, iPad and Mac. Converted with coremltools; the packages are stateless, so all sequencing and buffering lives in your Swift code.

Task image text to text
Upstream microsoft/Florence-2
Packages 3
Download size 229 MB
Minimum iOS 17.0
Peak RAM ~1200 MB

Files

File Size Compute units SHA-256
Florence2VisionEncoder.mlpackage.zip 77 MB cpuOnly 9422f189c21220a0…
Florence2TextEncoder.mlpackage.zip 69 MB cpuOnly f985deeef0408ea8…
Florence2Decoder.mlpackage.zip 81 MB cpuOnly fe85a6faab528127…
florence2_vocab.json 976 KB - 861fee9af5520403…
Total 229 MB

compute_units is not a suggestion -- it is the configuration the conversion was verified against. Moving a package to a different compute unit can silently change the numerics (FP16 attention overflow) or crash on the GPU.

Download

hf download mlboydaisuke/coreml-zoo --include "florence2/*" --local-dir ./florence2
unzip './florence2/florence2/*.zip' -d ./florence2

Use in Swift

import CoreML

let config = MLModelConfiguration()
config.computeUnits = .cpuOnly   // as converted β€” see the table above

// Unzip the .mlpackage, drop it into your Xcode target and Xcode compiles it
// at build time:
let model = try Florence2VisionEncoder(configuration: config)

// ...or compile a downloaded .mlpackage at runtime:
let compiled = try await MLModel.compileModel(at: mlpackageURL)
let model = try MLModel(contentsOf: compiled, configuration: config)

This model is split into 3 Core ML packages that are driven in sequence from Swift. Load them one at a time, copy the outputs out of the MLMultiArray buffers and release each model before loading the next β€” two large Core ML models resident at once will OOM on an iPhone.

Demo

  • Sample app β€” sample_apps/Florence2Demo, a standalone SwiftUI project.
  • Models Zoo β€” this model is downloadable and runnable inside the Models Zoo app on the App Store, no build required.

Conversion

License

The conversion inherits the upstream license: MIT.

Credits

Downloads last month
20
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for mlboydaisuke/Florence-2-base-CoreML

Quantized
(3)
this model

Collection including mlboydaisuke/Florence-2-base-CoreML