คำแนะนำในการย้ายข้อมูล AutoML Vision Edge ของ ML Kit

คุณส่งโมเดลการจัดประเภทอิมเมจที่ฝึกด้วย AutoML ไปยังโมเดลที่กำหนดเองได้ API คุณจะรวมโมเดลไว้ในแอปหรือโฮสต์โมเดลนั้นต่อก็ได้ ในคอนโซล Firebase เป็นโมเดลที่กำหนดเอง เราได้ทำการติดป้ายกำกับรูปภาพ AutoML ถูกนำออกจาก ML Kit เนื่องจากมีการแทนที่ทั้งหมดด้วยรูปภาพโมเดลที่กำหนดเอง Labeling API

APIสิ่งที่เปลี่ยนแปลง
API การติดป้ายกำกับรูปภาพ AutoML Vision Edge แต่มี API การติดป้ายกำกับรูปภาพโมเดลที่กำหนดเองมาแทนที่โดยสมบูรณ์ ที่มีอยู่ นำ API การติดป้ายกำกับรูปภาพ AutoML Vision Edge ออกแล้ว

หากคุณเป็นผู้ใช้ ML Kit ที่ใช้ AutoML Vision Edge API อยู่ในขณะนี้ โปรด ทำตามวิธีการย้ายข้อมูลสำหรับ Android และ iOS

คำถามที่พบบ่อย

เหตุผลในการเปลี่ยนแปลงครั้งนี้

โดยช่วยลดความซับซ้อนของ ML Kit API และผสานรวม ML Kit ได้ง่ายขึ้น แอปของคุณ การเปลี่ยนแปลงนี้ช่วยให้คุณใช้โมเดลที่ฝึกด้วย AutoML ใน ในลักษณะเดียวกับโมเดลที่กำหนดเอง นอกจากนี้ ยังช่วยให้คุณใช้โมเดลที่ฝึกด้วย AutoML ได้ ในการตรวจหาและติดตามวัตถุ นอกเหนือจากการติดป้ายกำกับรูปภาพซึ่งเรา สนับสนุนอยู่ในปัจจุบัน นอกจากนี้ API โมเดลที่กำหนดเองยังรองรับทั้ง 2 โมเดลที่มี แมปป้ายกำกับที่ฝังอยู่ในข้อมูลเมตา และโมเดลที่มีไฟล์ Manifest และ ไฟล์ป้ายกำกับ

ฉันจะได้รับประโยชน์อะไรจากการเปลี่ยนมาใช้ SDK ใหม่

  • ฟีเจอร์ใหม่: ความสามารถในการใช้โมเดลที่ฝึกด้วย AutoML สำหรับทั้งการติดป้ายกำกับรูปภาพ และการตรวจจับออบเจ็กต์ & การติดตามและความสามารถในการใช้โมเดลกับแมปป้ายกำกับ ที่ฝังอยู่ในข้อมูลเมตา

คู่มือการย้ายข้อมูลสำหรับ Android

ขั้นตอนที่ 1: อัปเดตการนำเข้า Gradle

อัปเดตทรัพยากร Dependency สำหรับไลบรารี 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 ด้วยเส้นทางไฟล์โมเดล (หากโมเดลมีข้อมูลเมตาที่มีการแมปป้ายกำกับ) หรือเส้นทางไฟล์ Manifest ของโมเดล (หากไฟล์ Manifest, โมเดล และป้ายกำกับอยู่ในไฟล์แยกต่างหาก)
  • คุณโฮสต์โมเดลที่กำหนดเองจากระยะไกลได้ผ่านคอนโซล 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

อัปเดตทรัพยากร Dependency สำหรับ 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 ด้วยเส้นทางไฟล์โมเดล (หากโมเดลมีข้อมูลเมตาที่มีการแมปป้ายกำกับ) หรือเส้นทางไฟล์ Manifest ของโมเดล (หากไฟล์ Manifest, โมเดล และป้ายกำกับอยู่ในไฟล์แยกต่างหาก)
  • คุณโฮสต์โมเดลที่กำหนดเองจากระยะไกลได้ผ่านคอนโซล 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];