Turi Create  4.0
od_serialization.hpp
1 /* Copyright © 2019 Apple Inc. All rights reserved.
2  *
3  * Use of this source code is governed by a BSD-3-clause license that can
4  * be found in the LICENSE.txt file or at
5  * https://opensource.org/licenses/BSD-3-Clause
6  */
7 
8 #ifndef TURI_OBJECT_DETECTION_OD_SERIALIZATION_H_
9 #define TURI_OBJECT_DETECTION_OD_SERIALIZATION_H_
10 
11 #include <ml/neural_net/model_spec.hpp>
12 #include <model_server/lib/extensions/ml_model.hpp>
13 #include <model_server/lib/variant_deep_serialize.hpp>
14 #include <toolkits/coreml_export/mlmodel_include.hpp>
15 
16 namespace turi {
17 namespace object_detection {
18 
19 void set_array_feature(CoreML::Specification::FeatureDescription* feature_desc, std::string name,
20  std::string short_description, const std::vector<size_t>& shape,
21  float value);
22 
23 void _save_impl(oarchive& oarc,
24  const std::map<std::string, variant_type>& state,
25  const neural_net::float_array_map& weights);
26 
27 void _load_version(iarchive& iarc, size_t version,
28  std::map<std::string, variant_type>* state,
29  neural_net::float_array_map* weights);
30 
31 void init_darknet_yolo(neural_net::model_spec& nn_spec,
32  const size_t num_classes, size_t num_anchor_boxes,
33  const std::string& input_name);
34 
35 neural_net::pipeline_spec export_darknet_yolo(
36  const neural_net::float_array_map& weights, const std::string& input_name,
37  const std::string& coordinates_name, const std::string& confidence_name,
38  const std::vector<std::pair<float, float>>& anchor_boxes, size_t num_classes,
39  bool use_nms_layer, size_t output_grid_height, size_t output_grid_width, float iou_threshold,
40  float confidence_threshold, size_t spatial_reduction);
41 
42 } // namespace object_detection
43 } // namespace turi
44 
45 #endif // TURI_OBJECT_DETECTION_OD_SERIALIZATION_H_