Hi,
I’m building an iOS app which uses object detection model (yolov8). I’ve already trained my model and uploaded the weights on roboflow. The model is available here: Sign in to Roboflow
But, when I’m trying to load the model using swift with this code:
import Foundation
import Roboflow
import SwiftUI
class RoboflowManager: ObservableObject{
@Published var model : RFObjectDetectionModel?
private let rf = RoboflowMobile(apiKey: "API_KEY")
init(){
Task.init{
await loadModel()
}
}
private func loadModel() async{
let (loadedModel, loadError, _, _) = await rf.load(model: "MODEL", modelVersion: MODEL_VERSION)
if let error = loadError{
print("Error loading model : \(error)")
}else{
loadedModel!.configure(threshold:0.5, overlap:0.8, maxObjects: 2)
self.model = loadedModel
}
}
func detect(image: UIImage) async -> [RFObjectDetectionPrediction]?{
guard let model = model else{
print("Model not loaded")
return nil
}
let (predictions, detectError) = await model.detect(image: image)
if let error = detectError{
print("Error detecting objects: \(error)")
return nil
}else{
return predictions
}
}
}
I have the following error raised :
No Model Found. Trying Again.
Error Loading Model. Check your API_KEY, project name, and version along with your network connection.
I obviously checked several times and the data are correct.
Note that I have the same issue when using python and Pycharm on my local device. BUT, when I’m trying to load the model using Google Colab it finally works.
I hope someone will have an answer to my question.