Skip to content

Commit 8d80393

Browse files
Merge pull request #11 from roboflow/cursor/add-resnet-models-for-ios-classification-9247
Cursor/add resnet models for ios classification 9247
2 parents 5c3b848 + 737f4fa commit 8d80393

31 files changed

+2010
-195
lines changed

.github/workflows/swift.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ jobs:
6262
- name: Run Swift package tests
6363
run: |
6464
swift test
65+
66+
- name: Run Xcode tests
67+
run: |
68+
xcodebuild test -scheme RoboflowTests -destination 'platform=iOS Simulator,OS=18.5,name=iPhone 16'
6569
6670
- name: Validate package structure
67-
run: swift package describe
71+
run: swift package describe

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,6 @@ fastlane/test_output
9090
iOSInjectionProject/
9191

9292
.DS_Store
93+
94+
**/*.mlpackage
95+
**/*.mlmodel

Package.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ let package = Package(
2020
name: "Roboflow",
2121
dependencies: [], path: "Sources/Roboflow"
2222
),
23-
.testTarget(name:"RoboflowTests", dependencies: ["Roboflow"])
23+
.testTarget(
24+
name: "RoboflowTests",
25+
dependencies: ["Roboflow"],
26+
path: "Tests/RoboflowTests",
27+
resources: [
28+
.copy("assets")
29+
]
30+
)
2431
]
2532
)

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,11 @@ If you've previously installed the Roboflow SDK via Cocoapods, you'll need to up
178178
The SDK includes a comprehensive test suite that validates model loading and inference functionality. To run the tests:
179179

180180
```bash
181+
# for swift only tests
181182
swift test
183+
184+
# for iOS simulator tests
185+
xcodebuild test -scheme RoboflowTests -destination 'platform=iOS Simulator,arch=arm64,OS=18.5,name=iPhone 16'
182186
```
183187

184188
The test suite includes:

Sources/Roboflow/Classes/Roboflow.docc/Roboflow.md

100755100644
File mode changed.

Sources/Roboflow/Classes/Roboflow.swift

Lines changed: 162 additions & 39 deletions
Large diffs are not rendered by default.

Sources/Roboflow/Classes/UIKit/RFModel+UIKit.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import UIKit
1212

1313
extension RFModel {
1414
/// Run image through model and return detections
15-
public func detect(image: UIImage, completion: @escaping (([RFObjectDetectionPrediction]?, Error?) -> Void)) {
15+
public func detect(image: UIImage, completion: @escaping (([RFPrediction]?, Error?) -> Void)) {
1616
let size = image.size
1717
let attrs = [
1818
kCVPixelBufferCGImageCompatibilityKey: kCFBooleanTrue!,
@@ -71,7 +71,6 @@ extension RFModel {
7171
}
7272
}
7373
}
74-
7574
#endif
7675

7776
func hexStringToCGColor (hex:String) -> CGColor {

Sources/Roboflow/Classes/Utils/RoboflowErrors.swift

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,45 @@ public struct UnsupportedOSError: Error, LocalizedError, CustomStringConvertible
2424
"[UnsupportedOSError] \(message)"
2525
}
2626
}
27+
28+
public struct DetectionError: Error, LocalizedError, CustomStringConvertible {
29+
30+
// MARK: Stored properties
31+
public let message: String
32+
33+
// MARK: Initialiser
34+
public init(
35+
message: String = "Error performing detection."
36+
) {
37+
self.message = message
38+
}
39+
40+
// MARK: LocalizedError
41+
public var errorDescription: String? { message }
42+
43+
// MARK: CustomStringConvertible
44+
public var description: String {
45+
"[DetectionError] \(message)"
46+
}
47+
}
48+
49+
public struct ModelLoadError: Error, LocalizedError, CustomStringConvertible {
50+
51+
// MARK: Stored properties
52+
public let message: String
53+
54+
// MARK: Initialiser
55+
public init(
56+
message: String = "Error loading model."
57+
) {
58+
self.message = message
59+
}
60+
61+
// MARK: LocalizedError
62+
public var errorDescription: String? { message }
63+
64+
// MARK: CustomStringConvertible
65+
public var description: String {
66+
"[ModelLoadError] \(message)"
67+
}
68+
}

0 commit comments

Comments
 (0)