คําแนะนําในการย้ายข้อมูล ML Edge Vision Edge

จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ

คุณส่งโมเดลการแยกประเภทรูปภาพที่ฝึกด้วย AutoML ไปยัง API โมเดลที่กําหนดเองได้ คุณสามารถรวมโมเดลไว้ในแอปหรือฝากไว้ใน Firebase Console ในรูปแบบที่กําหนดเองก็ได้ นํา API การติดป้ายกํากับรูปภาพ AutoML ออกจาก ML Kit แล้ว เนื่องจาก 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 โมเดลที่กําหนดเองยังรองรับทั้งโมเดลที่มีการแมปป้ายกํากับที่ฝังอยู่ในข้อมูลเมตา และโมเดลที่มีไฟล์ Manifest และไฟล์ป้ายกํากับแยกกัน

ฉันจะได้รับสิทธิประโยชน์อะไรบ้างจากการย้ายข้อมูลไปยัง SDK ใหม่

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

คําแนะนําในการย้ายข้อมูลสําหรับ Android

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

อัปเดตทรัพยากร Dependency สําหรับไลบรารี Android ของ ML Kit ในโมดูล (ระดับแอป) Gradle (โดยปกติจะเป็น app/build.gradle) ตามตารางต่อไปนี้

ฟีเจอร์อาร์ติแฟกต์เก่าอาร์ติแฟกต์ใหม่
การติดป้ายกํากับรูปภาพ AutoML โดยไม่ต้องดาวน์โหลดโมเดลระยะไกล com.google.mlkit:image-labeling-automl:16.2.1 com.google.mlkit:รูปภาพ-ป้ายกํากับ-กําหนดเอง:16.0.0-เบต้า4
การติดป้ายกํากับรูปภาพ 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-beta4
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.Custom RemoteModel
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 ใน ML Kit ใน Podfile ของแอป โดยทําดังนี้

ฟีเจอร์ชื่อพ็อดเก่าชื่อพ็อดใหม่
การติดป้ายกํากับรูปภาพ AutoML โดยไม่ต้องดาวน์โหลดโมเดลระยะไกล GoogleMLKit/ImageLabelingAutoML GoogleMLKit/ImageLabelingCustom
การติดป้ายกํากับรูปภาพ AutoML ที่ดาวน์โหลดโมเดลระยะไกล GoogleMLKit/ImageLabelingAutoML
GoogleMLKit/LinkFirebase
GoogleMLKit/ImageLabelingCustom
GoogleMLKit/LinkFirebase

ขั้นตอนที่ 2: อัปเดตชื่อชั้นเรียน

หากชั้นเรียนปรากฏในตารางนี้ โปรดทําการเปลี่ยนแปลงที่ระบุ

Swift

ชั้นเรียนเก่าชั้นเรียนใหม่
รูปแบบการระบุแหล่งที่มาในเครื่องของ AutoMLImage โมเดลในพื้นที่
รูปแบบระยะไกลของ AutoMLImageLabeler รูปแบบระยะไกลที่กําหนดเอง
ตัวเลือก AutoMLImageLabeler ตัวเลือกป้ายกํากับรูปภาพที่กําหนดเอง

Objective-C

ชั้นเรียนเก่าชั้นเรียนใหม่
MLKAutoMLImageLabelerLocalModel โมเดล MLKLocal
MLKAutoMLImageImageerLabelModel รูปแบบระยะไกลของ MLKCustom
ตัวเลือกป้ายกํากับรูปภาพ MLKAutoMLML ตัวเลือกป้ายกํากับรูปภาพที่กําหนดเอง MLK

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];