מדריך להעברה של ML Kit AutoML Vision Edge

אפשר להעביר מודל סיווג תמונות שהוכשר ל-AutoML לממשקי ה-API של המודל בהתאמה אישית. אפשר להמשיך לקבץ את המודל בתוך האפליקציה או לארח אותו במסוף Firebase כמודל מותאם אישית. ה-API של תיוג התמונות של AutoML הוסר מערכת ML כי הוא הוחלף במלואו ב-Custom Model Image Labeling API.

APIמה משתנה?
API של הוספת תוויות לתמונות ב-AutoML Vision Edge הוא הוחלף במלואו ב-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) בהתאם לטבלה הבאה:

התכונהפריטי מידע ישניםפריט מידע חדש שנוצר בתהליך פיתוח (Artifact)
הוספת תוויות לתמונה 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

מעדכנים את יחסי התלות של הקואופודים ל-iOS ב-ML Kit ב-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)

הנה כמה דוגמאות לשיטות יעד-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];