diff --git a/README.md b/README.md index fc4e75f..a4198d6 100644 --- a/README.md +++ b/README.md @@ -194,19 +194,54 @@ example.pn.cc Finally you could use the funcition in the files to extract your label data. ### FAQ - 1. If you still get errors like after finishing the above instruction: - ``` - Invalid argument: No OpKernel was registered to support Op 'xxx' with these attrs. Registered devices: [CPU], Registered kernels: - - ``` - - Solution: First check if you use the certain ops_to_register.h for the model you choose. - Then check the file "tensorflow/contrib/makefile/tf_op_files.txt" and add the "tensorflow/core/kernels/cwise_op_xxx.cc" into the txt file if it is not in there. - - 2. Make sure you've added the "-O3 -DANDROID_TYPES=ANDROID_TYPES_FULL -DSELECTIVE_REGISTRATION -DSUPPORT_SELECTIVE_REGISTRATION" when run the "compile_ios_tensorflow_s.sh". - +1. If you still get errors like after finishing the above instruction: +``` +Invalid argument: No OpKernel was registered to support Op 'xxx' with these attrs. Registered devices: [CPU], Registered kernels: + +``` +- Solution: First check if you use the certain ops_to_register.h for the model you choose. +Then check the file "tensorflow/contrib/makefile/tf_op_files.txt" and add the "tensorflow/core/kernels/cwise_op_xxx.cc" into the txt file if it is not in there. - 3. Invalid argument: No OpKernel was registered to support Op 'Conv2D' with these attrs. Registered devices: [CPU], Registered kernels: - ``` - [[Node: FeatureExtractor/InceptionV2/InceptionV2/Conv2d_1a_7x7/separable_conv2d = Conv2D[T=DT_FLOAT, data_format="NHWC", padding="VALID", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true](FeatureExtractor/InceptionV2/InceptionV2/Conv2d_1a_7x7/separable_conv2d/depthwise, FeatureExtractor/InceptionV2/Conv2d_1a_7x7/pointwise_weights/read)]] - ``` - - Solution: Because of the special structure of models, they include the GEMM function in the conv layers. However, the default Makefile does not use the GEMM for conv layer, so that you need to munually replace the line in the ops_to_register.h. In your ops_to_register.h replace the line "Conv2DOp" with "Conv2DUsingGemmOp< float, Im2ColConvFunctor>>" and the problem will be solved. +2. Make sure you've added the "-O3 -DANDROID_TYPES=ANDROID_TYPES_FULL -DSELECTIVE_REGISTRATION -DSUPPORT_SELECTIVE_REGISTRATION" when run the "compile_ios_tensorflow_s.sh". + + +3. Invalid argument: No OpKernel was registered to support Op 'Conv2D' with these attrs. Registered devices: [CPU], Registered kernels: +``` +[[Node: FeatureExtractor/InceptionV2/InceptionV2/Conv2d_1a_7x7/separable_conv2d = Conv2D[T=DT_FLOAT, data_format="NHWC", padding="VALID", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true](FeatureExtractor/InceptionV2/InceptionV2/Conv2d_1a_7x7/separable_conv2d/depthwise, FeatureExtractor/InceptionV2/Conv2d_1a_7x7/pointwise_weights/read)]] +``` +- Solution: Because of the special structure of models, they include the GEMM function in the conv layers. However, the default Makefile does not use the GEMM for conv layer, so that you need to munually replace the line in the ops_to_register.h. In your ops_to_register.h replace the line "Conv2DOp" with "Conv2DUsingGemmOp< float, Im2ColConvFunctor>>" and the problem will be solved. + +4. GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +\#error This file was generated by an older version of protoc which is +\#error incompatible with your Protocol Buffer headers. Please +\#error regenerate this file with a newer version of protoc. + +- Solution: This means that the version of Protobuf which is being included from the TF_ROOT does not match the version which was used to generate the .cc and .h interface files. The easiest thing to do is just to re-generate them from the original .proto spec file. +Either check the CHANGES.txt file in your TF_ROOT: +``` +$ cat $TF_ROOT/tensorflow/contrib/makefile/downloads/protobuf/CHANGES.txt +``` +The newest version number of that lib will be at the top. +Or look at the IF statement in the .h file +If it says: +\#if GOOGLE_PROTOBUF_VERSION < 3004000 +That means Protobuf 3.4.0 + +Then get the correct version binary for your system +https://github.com/google/protobuf/releases + +The original .proto file is from here: +https://github.com/tensorflow/models/blob/master/research/object_detection/protos/string_int_label_map.proto + +Then run something like: +``` +$ ./protoc --version +libprotoc 3.4.0 \# correct version +$ ./protoc --cpp_out=./ ./string_int_label_map.proto +``` + +Then replace the files in the ex_SSD_Mobilenet_TF folder with the newly generated ones: +- string_int_label_map.pb.cc +- string_int_label_map.pb.h + +The app should now compile. diff --git a/TF_Graph/.blank b/TF_Graph/.blank new file mode 100644 index 0000000..e69de29 diff --git a/ex_SSD_Mobilenet_TF/string_int_label_map.pb.cc b/ex_SSD_Mobilenet_TF/string_int_label_map.pb.cc index dcfe6dd..0f8e818 100644 --- a/ex_SSD_Mobilenet_TF/string_int_label_map.pb.cc +++ b/ex_SSD_Mobilenet_TF/string_int_label_map.pb.cc @@ -19,9 +19,15 @@ namespace object_detection { namespace protos { -class StringIntLabelMapItemDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed { +class StringIntLabelMapItemDefaultTypeInternal { +public: + ::google::protobuf::internal::ExplicitlyConstructed + _instance; } _StringIntLabelMapItem_default_instance_; -class StringIntLabelMapDefaultTypeInternal : public ::google::protobuf::internal::ExplicitlyConstructed { +class StringIntLabelMapDefaultTypeInternal { +public: + ::google::protobuf::internal::ExplicitlyConstructed + _instance; } _StringIntLabelMap_default_instance_; namespace protobuf_string_5fint_5flabel_5fmap_2eproto { @@ -34,21 +40,21 @@ ::google::protobuf::Metadata file_level_metadata[2]; } // namespace PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTableField - const TableStruct::entries[] = { + const TableStruct::entries[] GOOGLE_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { {0, 0, 0, ::google::protobuf::internal::kInvalidMask, 0, 0}, }; PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::AuxillaryParseTableField - const TableStruct::aux[] = { + const TableStruct::aux[] GOOGLE_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { ::google::protobuf::internal::AuxillaryParseTableField(), }; PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTable const - TableStruct::schema[] = { - { NULL, NULL, 0, -1, -1, false }, - { NULL, NULL, 0, -1, -1, false }, + TableStruct::schema[] GOOGLE_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { + { NULL, NULL, 0, -1, -1, -1, -1, NULL, false }, + { NULL, NULL, 0, -1, -1, -1, -1, NULL, false }, }; -const ::google::protobuf::uint32 TableStruct::offsets[] = { +const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(StringIntLabelMapItem, _has_bits_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(StringIntLabelMapItem, _internal_metadata_), ~0u, // no _extensions_ @@ -68,8 +74,7 @@ const ::google::protobuf::uint32 TableStruct::offsets[] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(StringIntLabelMap, item_), ~0u, }; - -static const ::google::protobuf::internal::MigrationSchema schemas[] = { +static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { { 0, 8, sizeof(StringIntLabelMapItem)}, { 11, 17, sizeof(StringIntLabelMap)}, }; @@ -101,29 +106,24 @@ void protobuf_RegisterTypes(const ::std::string&) { } } // namespace - -void TableStruct::Shutdown() { - _StringIntLabelMapItem_default_instance_.Shutdown(); - delete file_level_metadata[0].reflection; - _StringIntLabelMap_default_instance_.Shutdown(); - delete file_level_metadata[1].reflection; -} - void TableStruct::InitDefaultsImpl() { GOOGLE_PROTOBUF_VERIFY_VERSION; ::google::protobuf::internal::InitProtobufDefaults(); - _StringIntLabelMapItem_default_instance_.DefaultConstruct(); - _StringIntLabelMap_default_instance_.DefaultConstruct(); -} + _StringIntLabelMapItem_default_instance_._instance.DefaultConstruct(); + ::google::protobuf::internal::OnShutdownDestroyMessage( + &_StringIntLabelMapItem_default_instance_);_StringIntLabelMap_default_instance_._instance.DefaultConstruct(); + ::google::protobuf::internal::OnShutdownDestroyMessage( + &_StringIntLabelMap_default_instance_);} void InitDefaults() { static GOOGLE_PROTOBUF_DECLARE_ONCE(once); ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl); } +namespace { void AddDescriptorsImpl() { InitDefaults(); - static const char descriptor[] = { + static const char descriptor[] GOOGLE_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { "\n\032string_int_label_map.proto\022\027object_det" "ection.protos\"G\n\025StringIntLabelMapItem\022\014" "\n\004name\030\001 \001(\t\022\n\n\002id\030\002 \001(\005\022\024\n\014display_name" @@ -135,14 +135,14 @@ void AddDescriptorsImpl() { descriptor, 209); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "string_int_label_map.proto", &protobuf_RegisterTypes); - ::google::protobuf::internal::OnShutdown(&TableStruct::Shutdown); } +} // anonymous namespace void AddDescriptors() { static GOOGLE_PROTOBUF_DECLARE_ONCE(once); ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl); } -// Force AddDescriptors() to be called at static initialization time. +// Force AddDescriptors() to be called at dynamic initialization time. struct StaticDescriptorInitializer { StaticDescriptorInitializer() { AddDescriptors(); @@ -228,12 +228,17 @@ StringIntLabelMapItem* StringIntLabelMapItem::New(::google::protobuf::Arena* are void StringIntLabelMapItem::Clear() { // @@protoc_insertion_point(message_clear_start:object_detection.protos.StringIntLabelMapItem) - if (_has_bits_[0 / 32] & 3u) { - if (has_name()) { + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + cached_has_bits = _has_bits_[0]; + if (cached_has_bits & 3u) { + if (cached_has_bits & 0x00000001u) { GOOGLE_DCHECK(!name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); (*name_.UnsafeRawStringPointer())->clear(); } - if (has_display_name()) { + if (cached_has_bits & 0x00000002u) { GOOGLE_DCHECK(!display_name_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited())); (*display_name_.UnsafeRawStringPointer())->clear(); } @@ -256,11 +261,11 @@ bool StringIntLabelMapItem::MergePartialFromCodedStream( // optional string name = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(10u)) { + static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), this->name().length(), + this->name().data(), static_cast(this->name().length()), ::google::protobuf::internal::WireFormat::PARSE, "object_detection.protos.StringIntLabelMapItem.name"); } else { @@ -272,7 +277,7 @@ bool StringIntLabelMapItem::MergePartialFromCodedStream( // optional int32 id = 2; case 2: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(16u)) { + static_cast< ::google::protobuf::uint8>(16u /* 16 & 0xFF */)) { set_has_id(); DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( @@ -286,11 +291,11 @@ bool StringIntLabelMapItem::MergePartialFromCodedStream( // optional string display_name = 3; case 3: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(26u)) { + static_cast< ::google::protobuf::uint8>(26u /* 26 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadString( input, this->mutable_display_name())); ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->display_name().data(), this->display_name().length(), + this->display_name().data(), static_cast(this->display_name().length()), ::google::protobuf::internal::WireFormat::PARSE, "object_detection.protos.StringIntLabelMapItem.display_name"); } else { @@ -301,13 +306,11 @@ bool StringIntLabelMapItem::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -331,7 +334,7 @@ void StringIntLabelMapItem::SerializeWithCachedSizes( // optional string name = 1; if (cached_has_bits & 0x00000001u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), this->name().length(), + this->name().data(), static_cast(this->name().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "object_detection.protos.StringIntLabelMapItem.name"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -346,7 +349,7 @@ void StringIntLabelMapItem::SerializeWithCachedSizes( // optional string display_name = 3; if (cached_has_bits & 0x00000002u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->display_name().data(), this->display_name().length(), + this->display_name().data(), static_cast(this->display_name().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "object_detection.protos.StringIntLabelMapItem.display_name"); ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased( @@ -355,7 +358,7 @@ void StringIntLabelMapItem::SerializeWithCachedSizes( if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); + _internal_metadata_.unknown_fields(), output); } // @@protoc_insertion_point(serialize_end:object_detection.protos.StringIntLabelMapItem) } @@ -371,7 +374,7 @@ ::google::protobuf::uint8* StringIntLabelMapItem::InternalSerializeWithCachedSiz // optional string name = 1; if (cached_has_bits & 0x00000001u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->name().data(), this->name().length(), + this->name().data(), static_cast(this->name().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "object_detection.protos.StringIntLabelMapItem.name"); target = @@ -387,7 +390,7 @@ ::google::protobuf::uint8* StringIntLabelMapItem::InternalSerializeWithCachedSiz // optional string display_name = 3; if (cached_has_bits & 0x00000002u) { ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField( - this->display_name().data(), this->display_name().length(), + this->display_name().data(), static_cast(this->display_name().length()), ::google::protobuf::internal::WireFormat::SERIALIZE, "object_detection.protos.StringIntLabelMapItem.display_name"); target = @@ -397,7 +400,7 @@ ::google::protobuf::uint8* StringIntLabelMapItem::InternalSerializeWithCachedSiz if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); + _internal_metadata_.unknown_fields(), target); } // @@protoc_insertion_point(serialize_to_array_end:object_detection.protos.StringIntLabelMapItem) return target; @@ -410,7 +413,7 @@ size_t StringIntLabelMapItem::ByteSizeLong() const { if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + _internal_metadata_.unknown_fields()); } if (_has_bits_[0 / 32] & 7u) { // optional string name = 1; @@ -504,12 +507,13 @@ void StringIntLabelMapItem::Swap(StringIntLabelMapItem* other) { InternalSwap(other); } void StringIntLabelMapItem::InternalSwap(StringIntLabelMapItem* other) { + using std::swap; name_.Swap(&other->name_); display_name_.Swap(&other->display_name_); - std::swap(id_, other->id_); - std::swap(_has_bits_[0], other->_has_bits_[0]); + swap(id_, other->id_); + swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); - std::swap(_cached_size_, other->_cached_size_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata StringIntLabelMapItem::GetMetadata() const { @@ -733,6 +737,10 @@ StringIntLabelMap* StringIntLabelMap::New(::google::protobuf::Arena* arena) cons void StringIntLabelMap::Clear() { // @@protoc_insertion_point(message_clear_start:object_detection.protos.StringIntLabelMap) + ::google::protobuf::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + item_.Clear(); _has_bits_.Clear(); _internal_metadata_.Clear(); @@ -751,7 +759,7 @@ bool StringIntLabelMap::MergePartialFromCodedStream( // repeated .object_detection.protos.StringIntLabelMapItem item = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == - static_cast< ::google::protobuf::uint8>(10u)) { + static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) { DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( input, add_item())); } else { @@ -762,13 +770,11 @@ bool StringIntLabelMap::MergePartialFromCodedStream( default: { handle_unusual: - if (tag == 0 || - ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); + input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } @@ -789,14 +795,15 @@ void StringIntLabelMap::SerializeWithCachedSizes( (void) cached_has_bits; // repeated .object_detection.protos.StringIntLabelMapItem item = 1; - for (unsigned int i = 0, n = this->item_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast(this->item_size()); i < n; i++) { ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 1, this->item(i), output); + 1, this->item(static_cast(i)), output); } if (_internal_metadata_.have_unknown_fields()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); + _internal_metadata_.unknown_fields(), output); } // @@protoc_insertion_point(serialize_end:object_detection.protos.StringIntLabelMap) } @@ -809,15 +816,16 @@ ::google::protobuf::uint8* StringIntLabelMap::InternalSerializeWithCachedSizesTo (void) cached_has_bits; // repeated .object_detection.protos.StringIntLabelMapItem item = 1; - for (unsigned int i = 0, n = this->item_size(); i < n; i++) { + for (unsigned int i = 0, + n = static_cast(this->item_size()); i < n; i++) { target = ::google::protobuf::internal::WireFormatLite:: InternalWriteMessageNoVirtualToArray( - 1, this->item(i), deterministic, target); + 1, this->item(static_cast(i)), deterministic, target); } if (_internal_metadata_.have_unknown_fields()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); + _internal_metadata_.unknown_fields(), target); } // @@protoc_insertion_point(serialize_to_array_end:object_detection.protos.StringIntLabelMap) return target; @@ -830,16 +838,16 @@ size_t StringIntLabelMap::ByteSizeLong() const { if (_internal_metadata_.have_unknown_fields()) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); + _internal_metadata_.unknown_fields()); } // repeated .object_detection.protos.StringIntLabelMapItem item = 1; { - unsigned int count = this->item_size(); + unsigned int count = static_cast(this->item_size()); total_size += 1UL * count; for (unsigned int i = 0; i < count; i++) { total_size += ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->item(i)); + this->item(static_cast(i))); } } @@ -898,10 +906,11 @@ void StringIntLabelMap::Swap(StringIntLabelMap* other) { InternalSwap(other); } void StringIntLabelMap::InternalSwap(StringIntLabelMap* other) { + using std::swap; item_.InternalSwap(&other->item_); - std::swap(_has_bits_[0], other->_has_bits_[0]); + swap(_has_bits_[0], other->_has_bits_[0]); _internal_metadata_.Swap(&other->_internal_metadata_); - std::swap(_cached_size_, other->_cached_size_); + swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata StringIntLabelMap::GetMetadata() const { diff --git a/ex_SSD_Mobilenet_TF/string_int_label_map.pb.h b/ex_SSD_Mobilenet_TF/string_int_label_map.pb.h index 1b53a68..a834acd 100644 --- a/ex_SSD_Mobilenet_TF/string_int_label_map.pb.h +++ b/ex_SSD_Mobilenet_TF/string_int_label_map.pb.h @@ -8,12 +8,12 @@ #include -#if GOOGLE_PROTOBUF_VERSION < 3003000 +#if GOOGLE_PROTOBUF_VERSION < 3004000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif -#if 3003002 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#if 3004000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. @@ -51,8 +51,9 @@ struct TableStruct { static const ::google::protobuf::internal::AuxillaryParseTableField aux[]; static const ::google::protobuf::internal::ParseTable schema[]; static const ::google::protobuf::uint32 offsets[]; + static const ::google::protobuf::internal::FieldMetadata field_metadata[]; + static const ::google::protobuf::internal::SerializationTable serialization_table[]; static void InitDefaultsImpl(); - static void Shutdown(); }; void AddDescriptors(); void InitDefaults(); @@ -71,11 +72,24 @@ class StringIntLabelMapItem : public ::google::protobuf::Message /* @@protoc_ins CopyFrom(from); return *this; } + #if LANG_CXX11 + StringIntLabelMapItem(StringIntLabelMapItem&& from) noexcept + : StringIntLabelMapItem() { + *this = ::std::move(from); + } + inline StringIntLabelMapItem& operator=(StringIntLabelMapItem&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { return _internal_metadata_.unknown_fields(); } - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { return _internal_metadata_.mutable_unknown_fields(); } @@ -91,6 +105,9 @@ class StringIntLabelMapItem : public ::google::protobuf::Message /* @@protoc_ins 0; void Swap(StringIntLabelMapItem* other); + friend void swap(StringIntLabelMapItem& a, StringIntLabelMapItem& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- @@ -199,11 +216,24 @@ class StringIntLabelMap : public ::google::protobuf::Message /* @@protoc_inserti CopyFrom(from); return *this; } + #if LANG_CXX11 + StringIntLabelMap(StringIntLabelMap&& from) noexcept + : StringIntLabelMap() { + *this = ::std::move(from); + } + inline StringIntLabelMap& operator=(StringIntLabelMap&& from) noexcept { + if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + #endif inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { return _internal_metadata_.unknown_fields(); } - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { return _internal_metadata_.mutable_unknown_fields(); } @@ -219,6 +249,9 @@ class StringIntLabelMap : public ::google::protobuf::Message /* @@protoc_inserti 1; void Swap(StringIntLabelMap* other); + friend void swap(StringIntLabelMap& a, StringIntLabelMap& b) { + a.Swap(&b); + } // implements Message ---------------------------------------------- @@ -287,6 +320,10 @@ class StringIntLabelMap : public ::google::protobuf::Message /* @@protoc_inserti // =================================================================== #if !PROTOBUF_INLINE_NOT_IN_HEADERS +#ifdef __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif // __GNUC__ // StringIntLabelMapItem // optional string name = 1; @@ -473,6 +510,9 @@ StringIntLabelMap::item() const { return item_; } +#ifdef __GNUC__ + #pragma GCC diagnostic pop +#endif // __GNUC__ #endif // !PROTOBUF_INLINE_NOT_IN_HEADERS // ------------------------------------------------------------------- diff --git a/ex_SSD_Mobilenet_TF/string_int_label_map.proto b/ex_SSD_Mobilenet_TF/string_int_label_map.proto new file mode 100644 index 0000000..95abac9 --- /dev/null +++ b/ex_SSD_Mobilenet_TF/string_int_label_map.proto @@ -0,0 +1,24 @@ +// Message to store the mapping from class label strings to class id. Datasets +// use string labels to represent classes while the object detection framework +// works with class ids. This message maps them so they can be converted back +// and forth as needed. +syntax = "proto2"; + +package object_detection.protos; + +message StringIntLabelMapItem { + // String name. The most common practice is to set this to a MID or synsets + // id. + optional string name = 1; + + // Integer id that maps to the string name above. Label ids should start from + // 1. + optional int32 id = 2; + + // Human readable string label. + optional string display_name = 3; +}; + +message StringIntLabelMap { + repeated StringIntLabelMapItem item = 1; +}; \ No newline at end of file