iOS SDK
学習済みの Roboflow モデルを iOS アプリにデプロイします
最終更新
役に立ちましたか?
役に立ちましたか?
import Roboflow
...
//API キーで初期化
let rf = RoboflowMobile(apiKey: "API_KEY")
var model: RFModel?
...
//model はモデルのプロジェクト名
rf.load(model: "YOUR-MODEL-ID", modelVersion: YOUR-MODEL-VERSION-#) { [self] model, error, modelName, modelType in
if error != nil {
print(error?.localizedDescription as Any)
} else {
model?.configure(threshold: threshold, overlap: overlap, maxObjects: maxObjects
processingMode: .performance or .balanced or .quality, // インスタンスセグ
maxNumberPoints: マスク処理ポイントの最大数) // インスタンスセグ
self.model = model
}
}
...
//model?.detect は UIImage を受け取り、推論を実行します
let img = UIImage(named: "example.jpeg") // または CVPixelBuffer
model?.detect(image: img!) { predictions, error in
if error != nil {
print(error)
} else {
print(predictions)
}
}import Roboflow
...
//API キーで初期化
let rf = RoboflowMobile(apiKey: "API_KEY")
...
//model はモデルのプロジェクト名
let (model, loadingError, modelName, modelType) = await rf.load(model: "YOUR-MODEL-ID", modelVersion: YOUR-MODEL-VERSION-#)
model!.configure(threshold: threshold, overlap: overlap, maxObjects: maxObjects)
...
//model?.detect は UIImage を受け取り、推論を実行します
let img = UIImage(named: "example.jpeg")
let (predictions, predictionError) = await model!.detect(image: img!)
print(predictions)x:Float //物体 x の中心
y:Float //物体 y の中心
width:Float
height:Float
className:String
confidence:Float
color:UIColor
box:CGRect
points:[CGPoint] // インスタンスセグメンテーションモデルのみ