您可以將以 AutoML 訓練的圖片分類模型傳送至自訂模型 相互整合您可以繼續將模型組合到應用程式內,也可以代管模型 做為自訂模型AutoML Image labeling API 已由自訂模型映像檔完全取代,因此已從 ML Kit 中移除 Labeling API。
API | 異動內容 |
---|---|
AutoML Vision Edge 圖片標籤 API | 由 Custom Model image labeling API 完全取代。現有執行個體 移除 AutoML Vision Edge 圖片標籤 API。 |
如果你目前是使用 AutoML Vision Edge API 的 ML Kit 使用者,請 請按照 Android 和 iOS 適用的遷移操作說明進行。
常見問題
異動原因
這有助於簡化 ML Kit API,並讓您輕鬆將 ML Kit 整合至 這項變更實施後,您就能完全使用 AutoML 訓練的模型 將其做為自訂模型此外,您也能透過 AutoML 訓練的模型 物件偵測和追蹤等功能 以及我們 。此外,自訂模型 API 支援這兩種模型 嵌入中繼資料,以及具有個別資訊清單和 標籤檔案
改用新的 SDK 有什麼好處?
- 新功能:能夠針對圖片標籤使用以 AutoML 訓練的模型 物件偵測和透過標籤對應追蹤及使用模型 嵌入至中繼資料
Android 遷移指南
步驟 1:更新 Gradle 匯入作業
更新模組中 ML Kit Android 程式庫的依附元件
(應用程式層級) Gradle 檔案 (通常為 app/build.gradle
),定義如下:
資料表:
功能 | 古物 | 新增構件 |
---|---|---|
不必下載遠端模型,而是替 AutoML 建立圖片標籤 | com.google.mlkit:image-labeling-automl:16.2.1 | com.google.mlkit:image-labeling-custom:16.0.0-beta5 |
使用遠端模型下載為 AutoML 加上標籤的圖片 |
com.google.mlkit:image-labeling-automl:16.2.1 com.google.mlkit:linkfirebase:16.0.1 |
com.google.mlkit:image-labeling-custom:16.0.0-beta5 com.google.mlkit:linkfirebase:17.0.0 |
步驟 2:更新類別名稱
如果課程在此表格中,請進行對應的變更:
舊類別 | 新課程 |
---|---|
com.google.mlkit.vision.label.automl.AutoMLImageLabelerLocalModel | com.google.mlkit.common.model.LocalModel |
com.google.mlkit.vision.label.automl.AutoMLImageLabelerRemoteModel | com.google.mlkit.common.model.CustomRemoteModel |
com.google.mlkit.vision.label.automl.AutoMLImageLabelerOptions | com.google.mlkit.vision.label.custom.CustomImageLabelerOptions |
步驟 3:更新方法名稱
幾乎不需要變更程式碼:
LocalModel
現在可以透過模型檔案路徑 (如果模型擁有包含標籤對應的中繼資料) 或模型資訊清單檔案路徑 (如果資訊清單、模型和標籤位於不同的檔案) 來初始化。- 您可以透過 Firebase 控制台從遠端託管自訂模型,並使用
FirebaseModelSource
初始化CustomRemoteModel
。
以下列舉幾個舊版和新的 Kotlin 方法:
舊優惠
val localModel = AutoMLImageLabelerLocalModel.Builder() .setAssetFilePath("automl/manifest.json") // or .setAbsoluteFilePath(absolute file path to manifest file) .build() val optionsWithLocalModel = AutoMLImageLabelerOptions.Builder(localModel) .setConfidenceThreshold(0.5f) .build() val remoteModel = AutoMLImageLabelerRemoteModel.Builder("automl_remote_model") .build() val optionsWithRemoteModel = AutoMLImageLabelerOptions.Builder(remoteModel) .build()
新功能
val localModel = LocalModel.Builder() .setAssetManifestFilePath("automl/manifest.json") // or .setAbsoluteManifestFilePath(absolute file path to manifest file) .build() val optionsWithLocalModel = CustomImageLabelerOptions.Builder(localModel) .setConfidenceThreshold(0.5f) .build() val firebaseModelSource = FirebaseModelSource.Builder("automl_remote_model") .build() val remoteModel = CustomRemoteModel.Builder(firebaseModelSource).build() val optionsWithRemoteModel = CustomImageLabelerOptions.Builder(remoteModel) .build()
以下列舉幾個新舊 Java 方法的範例:
舊優惠
AutoMLImageLabelerLocalModel localModel = new AutoMLImageLabelerLocalModel.Builder() .setAssetFilePath("automl/manifest.json") // or .setAbsoluteFilePath(absolute file path to manifest file) .build(); AutoMLImageLabelerOptions optionsWithLocalModel = new AutoMLImageLabelerOptions.Builder(localModel) .setConfidenceThreshold(0.5f) .build(); AutoMLImageLabelerRemoteModel remoteModel = new AutoMLImageLabelerRemoteModel.Builder("automl_remote_model").build(); AutoMLImageLabelerOptions optionsWithRemoteModel = new AutoMLImageLabelerOptions.Builder(remoteModel) .build();
新功能
LocalModel localModel = new LocalModel.Builder() .setAssetManifestFilePath("automl/manifest.json") // or .setAbsoluteManifestFilePath(absolute file path to manifest file) .build() CustomImageLabelerOptions optionsWithLocalModel = new CustomImageLabelerOptions.Builder(localModel) .setConfidenceThreshold(0.5f) .build(); FirebaseModelSource firebaseModelSource = new FirebaseModelSource.Builder("automl_remote_model").build(); CustomRemoteModel remoteModel = new CustomRemoteModel.Builder(firebaseModelSource).build(); CustomImageLabelerOptions optionsWithRemoteModel = new CustomImageLabelerOptions.Builder(remoteModel).build();
iOS 遷移指南
必要條件
- 必須使用 Xcode 13.2.1 以上版本。
步驟 1:更新 Cocoapods
在應用程式的 Podfile 中,更新 ML Kit iOS Cocoapod 的依附元件:
功能 | 舊 Pod 名稱 | 新 Pod 名稱 |
---|---|---|
不必下載遠端模型,而是替 AutoML 建立圖片標籤 | GoogleMLKit/ImageLabelingAutoML | GoogleMLKit/ImageLabelingCustom |
使用遠端模型下載為 AutoML 加上標籤的圖片 |
GoogleMLKit/ImageLabelingAutoML GoogleMLKit/LinkFirebase |
GoogleMLKit/ImageLabelingCustom GoogleMLKit/LinkFirebase |
步驟 2:更新類別名稱
如果課程在此表格中,請進行對應的變更:
Swift
舊類別 | 新課程 |
---|---|
AutoMLImageLabelerLocalModel | LocalModel |
AutoMLImageLabelerRemoteModel | CustomRemoteModel |
AutoMLImageLabelerOptions | CustomImageLabelerOptions |
Objective-C
舊類別 | 新課程 |
---|---|
MLKAutoMLImageLabelerLocalModel | MLKLocalModel |
MLKAutoMLImageLabelerRemoteModel | MLKCustomRemoteModel |
MLKAutoMLImageLabelerOptions | MLKCustomImageLabelerOptions |
Objective-C
步驟 3:更新方法名稱
幾乎不需要變更程式碼:
LocalModel
現在可以透過模型檔案路徑 (如果模型擁有包含標籤對應的中繼資料) 或模型資訊清單檔案路徑 (如果資訊清單、模型和標籤位於不同的檔案) 來初始化。- 您可以透過 Firebase 控制台從遠端託管自訂模型,並使用
FirebaseModelSource
初始化CustomRemoteModel
。
以下列舉幾種 Swift 方法:
舊優惠
let localModel = AutoMLImageLabelerLocalModel(manifestPath: "automl/manifest.json") let optionsWithLocalModel = AutoMLImageLabelerOptions(localModel: localModel) let remoteModel = AutoMLImageLabelerRemoteModel(name: "automl_remote_model") let optionsWithRemoteModel = AutoMLImageLabelerOptions(remoteModel: remoteModel)
新功能
guard let localModel = LocalModel(manifestPath: "automl/manifest.json") else { return } let optionsWithLocalModel = CustomImageLabelerOptions(localModel: localModel) let firebaseModelSource = FirebaseModelSource(name: "automl_remote_model") let remoteModel = CustomRemoteModel(remoteModelSource: firebaseModelSource) let optionsWithRemoteModel = CustomImageLabelerOptions(remoteModel: remoteModel)
以下提供一些新舊 Objective-C 方法的範例:
舊優惠
MLKAutoMLImageLabelerLocalModel *localModel = [[MLKAutoMLImageLabelerLocalModel alloc] initWithManifestPath:"automl/manifest.json"]; MLKAutoMLImageLabelerOptions *optionsWithLocalModel = [[MLKAutoMLImageLabelerOptions alloc] initWithLocalModel:localModel]; MLKAutoMLImageLabelerRemoteModel *remoteModel = [[MLKAutoMLImageLabelerRemoteModel alloc] initWithManifestPath:"automl/manifest.json"]; MLKAutoMLImageLabelerOptions *optionsWithRemoteModel = [[MLKAutoMLImageLabelerOptions alloc] initWithRemoteModel:remoteModel];
新功能
MLKLocalModel *localModel = [[MLKLocalModel alloc] initWithManifestPath:"automl/manifest.json"]; MLKCustomImageLabelerOptions *optionsWithLocalModel = [[MLKCustomImageLabelerOptions alloc] initWithLocalModel:localModel]; MLKFirebaseModelSource *firebaseModelSource = [[MLKFirebaseModelSource alloc] initWithName:@"automl_remote_model"]; MLKCustomRemoteModel *remoteModel = [[MLKCustomRemoteModel alloc] initWithRemoteModelSource:firebaseModelSource]; MLKCustomImageLabelerOptions *optionsWithRemoteModel = [[MLKCustomImageLabelerOptions alloc] initWithRemoteModel:remoteModel];