File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -67,19 +67,20 @@ public class RFInstanceSegmentationModel: RFObjectDetectionModel {
67
67
do {
68
68
try handler. perform ( [ coreMLRequest] )
69
69
guard let detectResults = coreMLRequest. results else { return }
70
+
71
+ let castDetectResults0 = ( detectResults [ 0 ] as! VNCoreMLFeatureValueObservation ) . featureValue. multiArrayValue!
72
+ let castDetectResults1 = ( detectResults [ 1 ] as! VNCoreMLFeatureValueObservation ) . featureValue. multiArrayValue!
70
73
71
- let predictions = detectResults [ 1 ] as! VNCoreMLFeatureValueObservation
72
- let protos = detectResults [ 0 ] as! VNCoreMLFeatureValueObservation
73
-
74
- let pred = predictions. featureValue. multiArrayValue!
75
- let proto = protos. featureValue. multiArrayValue!
74
+ let pred = castDetectResults0. shape. count == 3 ? castDetectResults0 : castDetectResults1
75
+ let proto = castDetectResults1. shape. count == 4 ? castDetectResults1 : castDetectResults0
76
76
77
77
let numMasks = 32
78
78
let numCls = self . colors. count
79
79
80
80
// --- flatten MLMultiArray to Swift [Float] for speed
81
81
let p = pred. dataPointer. bindMemory ( to: Float . self,
82
82
capacity: pred. count)
83
+
83
84
let preds = UnsafeBufferPointer ( start: p, count: pred. count)
84
85
let protoShape = ( c: Int ( truncating: proto. shape [ 1 ] ) ,
85
86
h: Int ( truncating: proto. shape [ 2 ] ) ,
You can’t perform that action at this time.
0 commit comments