אפשר להעביר מודל לסיווג תמונות שאומן באמצעות AutoML לממשקי ה-API של המודל המותאם אישית. אתם יכולים להמשיך לארוז את המודל בתוך האפליקציה או לארח אותו במסוף Firebase בתור מודל בהתאמה אישית. הסרנו את AutoML image labeling API מ-ML Kit כי הוא הוחלף באופן מלא על ידי Custom Model Image Labeling API.
| API | מה ישתנה? |
|---|---|
| AutoML Vision Edge image labeling API | הוא הוחלף לגמרי ב-API של תיוג תמונות במודל בהתאמה אישית. הוסר API קיים של AutoML Vision Edge לתוויות של תמונות. |
אם אתם משתמשים כרגע ב-ML Kit באמצעות AutoML Vision Edge API, אתם צריכים לפעול לפי הוראות המיגרציה ל-Android ול-iOS.
שאלות נפוצות
מה הסיבה לשינוי?
השינוי הזה עוזר לפשט את ממשקי ה-API של ML Kit, ומקל על השילוב של ML Kit באפליקציה. בעקבות השינוי, אפשר להשתמש במודל שאומן באמצעות AutoML בדיוק כמו במודל מותאם אישית. בנוסף, תוכלו להשתמש במודלים שאומנו באמצעות AutoML לזיהוי ולמעקב אחר אובייקטים, בנוסף לתיוג תמונות שאנחנו תומכים בו כרגע. בנוסף, ה-API של המודלים בהתאמה אישית תומך גם במודלים עם מפת תוויות שמוטמעת במטא-נתונים שלהם, וגם במודלים עם קובצי מניפסט ותוויות נפרדים.
אילו יתרונות יש למעבר לגרסה החדשה של ה-SDK?
- תכונות חדשות: אפשרות להשתמש במודלים שאומנו ב-AutoML גם לתוויות של תמונות וגם לזיהוי ומעקב של אובייקטים, ואפשרות להשתמש במודלים עם מפת תוויות שמוטמעת במטא-נתונים שלהם.
מדריך להעברת נתונים (מיגרציה) ל-Android
שלב 1: עדכון של Gradle Imports
מעדכנים את יחסי התלות של ספריות 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, ולהפעיל
CustomRemoteModelעםFirebaseModelSource.
הנה כמה דוגמאות לשיטות ישנות וחדשות של 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
מעדכנים את יחסי התלות ב-ML Kit iOS cocoapods בקובץ Podfile של האפליקציה:
| תכונה | שמות הפודים הקודמים | שמות הפודים החדשים |
|---|---|---|
| הוספת תוויות לתמונות באמצעות 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, ולהפעיל
CustomRemoteModelעםFirebaseModelSource.
הנה כמה דוגמאות לשיטות ישנות וחדשות של 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];