react-native-yolo 0.0.9 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -17,7 +17,7 @@ public class HybridYoloModel: HybridYoloModelSpec {
|
|
|
17
17
|
|
|
18
18
|
private let threadLock = NSLock()
|
|
19
19
|
|
|
20
|
-
public required
|
|
20
|
+
public required init(modelPath: String) throws {
|
|
21
21
|
super.init()
|
|
22
22
|
try load(modelPath: modelPath)
|
|
23
23
|
}
|
|
@@ -32,8 +32,8 @@ public class HybridYoloModel: HybridYoloModelSpec {
|
|
|
32
32
|
|
|
33
33
|
try localInterpreter.allocateTensors()
|
|
34
34
|
|
|
35
|
-
let inputTensor = try localInterpreter.
|
|
36
|
-
let outputTensor = try localInterpreter.
|
|
35
|
+
let inputTensor = try localInterpreter.input(at: 0)
|
|
36
|
+
let outputTensor = try localInterpreter.output(at: 0)
|
|
37
37
|
|
|
38
38
|
let shape = inputTensor.shape.dimensions
|
|
39
39
|
|
|
@@ -81,7 +81,7 @@ public class HybridYoloModel: HybridYoloModelSpec {
|
|
|
81
81
|
try localInterpreter.invoke()
|
|
82
82
|
|
|
83
83
|
// Récupération des résultats du tenseur de sortie
|
|
84
|
-
let outputTensor = try localInterpreter.
|
|
84
|
+
let outputTensor = try localInterpreter.output(at: 0)
|
|
85
85
|
|
|
86
86
|
// Extraction et conversion de la structure des tenseurs [1, 300, 6] en Float
|
|
87
87
|
let nativeOutputs = outputTensor.data.withUnsafeBytes { (ptr: UnsafeRawBufferPointer) -> [Float] in
|
|
@@ -104,7 +104,7 @@ public class YoloModelLoader {
|
|
|
104
104
|
*/
|
|
105
105
|
public func makeInputBuffer(interpreter: Interpreter) throws -> Data {
|
|
106
106
|
// Récupérer le premier tenseur d'entrée du modèle TFLite
|
|
107
|
-
let inputTensor = try interpreter.
|
|
107
|
+
let inputTensor = try interpreter.input(at: 0)
|
|
108
108
|
let shape = inputTensor.shape.dimensions // Généralement: [1, 640, 640, 3]
|
|
109
109
|
let dataType = inputTensor.dataType
|
|
110
110
|
|
|
@@ -8,7 +8,9 @@ public enum Yuv420ToNv12Converter {
|
|
|
8
8
|
public static func convert(frame: any HybridFrameSpec, width: Int, height: Int) -> [UInt8] {
|
|
9
9
|
do {
|
|
10
10
|
let nativeBuffer = try frame.getNativeBuffer()
|
|
11
|
-
guard let rawPointer = nativeBuffer.pointer else {
|
|
11
|
+
guard let rawPointer = UnsafeRawPointer(bitPattern: UInt(nativeBuffer.pointer)) else {
|
|
12
|
+
return []
|
|
13
|
+
}
|
|
12
14
|
|
|
13
15
|
let pixelBuffer = Unmanaged<CVPixelBuffer>
|
|
14
16
|
.fromOpaque(rawPointer)
|