Esempio n. 1
0
 def _create_empty_model_buf(self):
     model = _schema_fb.ModelT()
     model_builder = flatbuffers.Builder(0)
     model_builder.Finish(
         model.Pack(model_builder),
         _metadata.MetadataPopulator.TFLITE_FILE_IDENTIFIER)
     return model_builder.Output()
Esempio n. 2
0
    def _create_model_file_with_metadata_and_buf_fields(self):
        metadata_field = _schema_fb.MetadataT()
        metadata_field.name = "meta"
        buffer_field = _schema_fb.BufferT()
        model = _schema_fb.ModelT()
        model.metadata = [metadata_field, metadata_field]
        model.buffers = [buffer_field, buffer_field, buffer_field]
        model_builder = flatbuffers.Builder(0)
        model_builder.Finish(
            model.Pack(model_builder),
            _metadata.MetadataPopulator.TFLITE_FILE_IDENTIFIER)

        mnodel_file = self.create_tempfile().full_path
        with open(mnodel_file, "wb") as f:
            f.write(model_builder.Output())

        return mnodel_file
Esempio n. 3
0
 def _create_model_buffer_with_wrong_identifier(self):
     wrong_identifier = b"widn"
     model = _schema_fb.ModelT()
     model_builder = flatbuffers.Builder(0)
     model_builder.Finish(model.Pack(model_builder), wrong_identifier)
     return model_builder.Output()