forked from apple/coremltools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CoreMLPythonUtils.h
38 lines (30 loc) · 1.34 KB
/
CoreMLPythonUtils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <string>
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wexit-time-destructors"
#pragma clang diagnostic ignored "-Wdocumentation"
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#pragma clang diagnostic pop
#import <Foundation/Foundation.h>
#import <CoreML/CoreML.h>
namespace py = pybind11;
namespace CoreML {
namespace Python {
namespace Utils {
NSURL * stringToNSURL(const std::string& str);
void handleError(NSError *error);
// python -> objc
MLDictionaryFeatureProvider * dictToFeatures(const py::dict& dict, NSError **error);
MLFeatureValue * convertValueToObjC(const py::handle& handle);
// objc -> cpp
std::vector<size_t> convertNSArrayToCpp(NSArray<NSNumber *> *array);
NSArray<NSNumber *>* convertCppArrayToObjC(const std::vector<size_t>& array);
// objc -> python
py::dict featuresToDict(id<MLFeatureProvider> features);
py::object convertValueToPython(MLFeatureValue *value);
py::object convertArrayValueToPython(MLMultiArray *value);
py::object convertDictionaryValueToPython(NSDictionary<NSObject *,NSNumber *> * value);
py::object convertImageValueToPython(CVPixelBufferRef value);
}
}
}