Skip to main content

Lens Remote Models

The Remote Models flavor is the smallest Lens SDK. There is no smaller build. It covers the wide document set (receipts, checks, W-2, W-9, bank statements, Any Documents, and the other types listed below). A receipts-only or checks-only flavor is still the right package when the app must stay on that single document type.

Counterpart to the full flavor

Remote Models is the counterpart to the full VeryfiLens flavor (veryfi-lens-sdk). It supports all the features Lens provides, but it downloads only the models your use case needs, instead of shipping every model in the app.

Downloads happen on the first successful configure

The first successful configure downloads the models for the document types and features in that call. A normal integration stops there and shows the camera. Do not call forceDownloadNativeModels unless the first camera session must already include those extra features.

forceDownloadNativeModels is only for a seamless first session when the user may be on a poor connection. It waits until the named models are stored, then you open the camera. If you skip it, configure still downloads in the background: capture can start immediately, and the extra checks start working once the files arrive.

Tradeoff. Installed size is as small as this SDK gets. Legacy cropping ships in the binary and works with no model download and no network. Screenshot detection, blur detection, LCD checks, and the other extra features in the tables below run only after their models have downloaded, so the first session needs a stable internet connection for those features. Later launches reuse the files already on the device.

Installed size​

These figures are the estimated size added to the app, from SDK binary sizes. They are smaller than the file you download from the package repository, because the store build keeps only the architecture for the device.

PlatformRemote ModelsFull SDKMeasured on
iOS14.3 MB24.4 MBSPM 3.0.24, CocoaPods 3.0.24.4
Android (arm64-v8a)19.7 MB31.1 MBLens SDK 2.7.0.7

Install​

Credentials are the same Lens repository username and password created in the Veryfi Hub. iOS uses the Lens: Cocoapods (iOS) / SPM key. Android uses the Lens: Maven (Android) key. API credentials (clientId, username, API key, URL) are separate and are passed to configure.

Add this flavor on its own. A second Lens artifact in the same app target pulls the full model set back in.

Swift Package Manager​

  1. In Xcode, choose File → Add Package Dependencies…
  2. Enter this package URL:
https://repo.veryfi.com/shared/lens/veryfi-lens-spm-remote-models.git
  1. Sign in with the Lens SPM username and password when Xcode asks.
  2. Add the VeryfiLens library product to the app target that calls Lens.
  3. Import it as import VeryfiLens.

This URL is the Remote Models package. The full SDK package is a different repository (veryfi-lens-spm.git). Point the app at one of them.

To resolve the package from a terminal or CI job, store the same credentials for that host (replace COCOAPODS_USERNAME and COCOAPODS_PASSWORD):

git credential approve <<EOF
protocol=https
host=repo.veryfi.com
path=shared/lens/veryfi-lens-spm-remote-models.git
username=COCOAPODS_USERNAME
password=COCOAPODS_PASSWORD

EOF

The CocoaPods pod for this flavor is VeryfiLens-RemoteModels. CocoaPods installation is deprecated; new apps should use the Swift package above.

Document types​

On Android this artifact accepts the same document types as the full SDK: receipt, long receipt, invoice, other, check, business card, W-2, W-9, barcode, bank statement, Any Documents, and the Any Documents shortcuts (insurance card, passport, driver license, nutrition facts, shipping label, prescription label). Credit card capture stays on the Credit Cards flavor.

On iOS the package supports that same set and also credit cards. Credit card capture downloads its own models, listed below.

How downloads follow configure​

The first successful configure starts the download. The settings in that call choose the set. A receipts configuration with blur detection downloads the blur model. A checks configuration with TIFF generation downloads the check TIFF model. A feature left off stays on the server.

Legacy cropping does not wait on that download. Screenshot detection, blur detection, LCD checks, on-device fields, and the other extra features run after their models are stored. On iOS the pass starts inside configure and runs again after account validation, because field detection and fraud also depend on the account. On Android the same set is selected from the settings passed to configure.

Files are stored on the device and reused on the next launch. Until a file arrives, that feature waits. The camera can still open and crop with the legacy crop models.

Optional: download before the camera​

Skip this section for a normal integration. configure already downloads the models.

Call forceDownloadNativeModels only when the first camera open must already have the extra features, for example a user on a poor connection. It downloads the names you pass (replacing any copy already on disk) and reports when that pass finishes, so you can open the camera after those features are ready. Call it only after configure. Before that, the callback returns a single "*" entry and nothing is downloaded:

Call VeryfiLens.configure before forcing a model download

The callback runs on the main thread. The map is model name to failure reason. An empty map means every requested model was stored. Unknown names are returned in that map and are not fetched.

Pass the unversioned name from the tables below, for example blur_detector. A versioned file name such as blur_detector_v5 is accepted too. Versions change between SDK releases, so the unversioned name is the stable one. An empty list downloads every model this flavor can fetch. local_extraction and mobile_words_spm are a pair: requesting either name downloads both.

import VeryfiLens

let credentials = VeryfiLensCredentials(
clientId: "CLIENT_ID",
username: "USERNAME",
apiKey: "API_KEY",
url: "URL"
)

let settings = VeryfiLensSettings()
settings.documentTypes = ["receipt"]
settings.blurDetectionIsOn = true
settings.allowSubmittingScreenshots = false

VeryfiLens.shared().configure(with: credentials, settings: settings) { success in
guard success else { return }

let models = ["blur_detector", "detect_screenshot"]
VeryfiLens.shared().utils.forceDownloadNativeModels(models) { failures in
guard failures.isEmpty else { return }
VeryfiLens.shared().showCamera(in: self)
}
}

The names in those samples are one receipts setup: blur detection on and screenshot submission off. Swap the list for the use case you actually configure. A checks flow that validates the check side and builds a TIFF uses this list:

["detect_check_side", "ppocr_det_fp16"]
listOf(
"detect_check_side",
"ppocr_det_fp16"
)

Model names by use case​

configure downloads a name only when the condition in the table is true. forceDownloadNativeModels downloads the names you pass, including when the file is already on disk. A receipts configure downloads whichever extra-feature models below are enabled.

Checks​

ModelPlatformWhen it is included
detect_check_sideiOS and AndroidvalidateCheckSides is on
ppocr_det_fp16iOS and AndroidretrieveCheckTiffIsOn is on

ppocr_det_fp16 is the text detector used to build the check TIFF. The checks-only SDK leaves that file out of the binary; this flavor downloads it.

Credit cards​

iOS, when documentTypes includes credit_card:

Model
read_card_fields
read_card_num
read_date_cvv
read_card_holder
tongrams_full (required on Android)

Credit card capture on Android uses the Credit Cards flavor.

Blur​

ModelPlatformWhen it is included
blur_detectoriOSblurDetectionIsOn, blur detection during autocapture, or the non-interactive blur check
blur_detectorAndroidblurDetectionIsOn (default on)

Screenshots​

ModelPlatformWhen it is included
detect_screenshotiOSallowSubmittingScreenshots is off, or auto-crop is on for the gallery or the browser
detect_screenshotAndroidallowSubmittingScreenshots is off (default on, so this model stays put until you disable that setting)

Fraud​

Fraud models are included when fraudDetectionIsOn is on. On iOS, lcd_detect and object_detector also require fraud detection on the account. lcd_card is included for business cards and credit cards. On Android the three models are requested together.

ModelRole
lcd_detectLCD / screen recapture on documents
lcd_cardLCD / screen recapture on cards
object_detectorExtra object check used with fraud detection

On-device fields​

Included when documentFieldsToDetect is non-empty and the account has on-device field detection. Supported field ids are vendor, date, time, total, and tax. On Android this runs for receipt, long receipt, invoice, and other.

Model
local_extraction
mobile_words_spm

Requesting either name downloads both. A receipts app that confirms vendor, date, and total before upload passes both, for example together with blur:

local_extraction
mobile_words_spm
blur_detector

Auto skew​

ModelPlatformWhen it is included
simple_ocriOSautoSkewCorrectionIsOn

On Android, simple_ocr ships in the SDK, so it is not a download name.