TIOModelBundle

@interface TIOModelBundle : NSObject

Encapsulates information about a TIOModel without actually loading the model.

A TIOModelBundle is used by the UI to show model details and is used to instantiate model instances as a model factory. There is currently a one-to-one correspondence between a TIOModelBundle and a .tfbundle folder in the models directory.

A model bundle folder must contain at least a model.json file, which contains information about the model. Some information is required, such as the identifier and name field, while other information may be added as needed by your use case.

See TIOModelBundleJSONSchema.h for a list of required fields and their types.

  • The deserialized information contained in the model.json file.

    Declaration

    Objective-C

    @property (readonly, atomic) NSDictionary *_Nonnull info;

    Swift

    var info: [AnyHashable : Any] { get }
  • The full path to the model bundle folder.

    Declaration

    Objective-C

    @property (readonly, atomic) NSString *_Nonnull path;

    Swift

    var path: String { get }
  • A string uniquely identifying the model represented by this bundle.

    Declaration

    Objective-C

    @property (readonly, atomic) NSString *_Nonnull identifier;

    Swift

    var identifier: String { get }
  • Human readable name of the model represented by this bundle

    Declaration

    Objective-C

    @property (readonly, atomic) NSString *_Nonnull name;

    Swift

    var name: String { get }
  • The version of the model reprsented by this bundle.

    A model’s unique identifier may remain the same as the version is incremented.

    Declaration

    Objective-C

    @property (readonly, atomic) NSString *_Nonnull version;

    Swift

    var version: String { get }
  • Additional information about the model represented by this bundle.

    Declaration

    Objective-C

    @property (readonly, atomic) NSString *_Nonnull details;

    Swift

    var details: String { get }
  • The authors of the model represented by this bundle.

    Declaration

    Objective-C

    @property (readonly, atomic) NSString *_Nonnull author;

    Swift

    var author: String { get }
  • The license of the model represented by this bundle.

    Declaration

    Objective-C

    @property (readonly, atomic) NSString *_Nonnull license;

    Swift

    var license: String { get }
  • A boolean value indicating if this is a placeholder bundle.

    A placeholder bundle has no underlying model and instantiates a TIOModel that does nothing. Placeholders bundles are used to collect labeled data for models that haven’t been trained yet.

    Declaration

    Objective-C

    @property (readonly, getter=isPlaceholder, atomic) BOOL placeholder;

    Swift

    var isPlaceholder: Bool { get }
  • A boolean value indicating if the model represnted by this bundle is quantized or not.

    Declaration

    Objective-C

    @property (readonly, atomic) BOOL quantized;

    Swift

    var quantized: Bool { get }
  • A string indicating the kind of model this is, e.g. image.classification.imagenet

    Declaration

    Objective-C

    @property (readonly, atomic) NSString *_Nonnull type;

    Swift

    var type: String { get }
  • Options associated with the model represented by this bundle.

    Declaration

    Objective-C

    @property (readonly, atomic) TIOModelOptions *_Nonnull options;

    Swift

    var options: TIOModelOptions { get }
  • The file path to the actual underlying model contained in this bundle.

    Currently, only tflite models are supported. If this placeholder is YES this property returns nil.

    Declaration

    Objective-C

    @property (readonly, atomic, nullable) NSString *modelFilepath;

    Swift

    var modelFilepath: String? { get }
  • Designated initializer.

    Declaration

    Objective-C

    - (nullable instancetype)initWithPath:(nonnull NSString *)path;

    Swift

    init?(path: String)

    Parameters

    path

    Fully qualified path to the model bundle folder.

    Return Value

    An instance of a TIOModelBundle or nil if no bundle could be loaded at that path.

  • Unavailable

    Use the designated initializer.

    Declaration

    Objective-C

    - (nonnull instancetype)init;
  • Creates and returns a new instance of the TIOModel represented by this bundle. Returns nil if the model cannot be instantiated.

    Declaration

    Objective-C

    - (nullable id<TIOModel>)newModel;
  • Returns the path to an asset in the bundle

    Declaration

    Objective-C

    - (nonnull NSString *)pathToAsset:(nonnull NSString *)filename;

    Swift

    func path(toAsset filename: String) -> String

    Parameters

    filename

    Asset’s filename, including extension

    Return Value

    NSString The full path to the file