示例#1
0
    def _load_version(cls, state, version):
        """
        A function to load a previously saved ImageClassifier
        instance.

        Parameters
        ----------
        unpickler : GLUnpickler
            A GLUnpickler file handler.

        version : int
            Version number maintained by the class writer.
        """
        _tkutl._model_version_check(version,
                                    cls._PYTHON_IMAGE_SIMILARITY_VERSION)
        from turicreate.toolkits.nearest_neighbors import NearestNeighborsModel

        state["similarity_model"] = NearestNeighborsModel(
            state["similarity_model"])

        # Correct models saved with a previous typo
        if state["model"] == "VisionFeaturePrint_Screen":
            state["model"] = "VisionFeaturePrint_Scene"

        if state["model"] == "VisionFeaturePrint_Scene" and _mac_ver() < (10,
                                                                          14):
            raise _ToolkitError(
                "Can not load model on this operating system. This model uses VisionFeaturePrint_Scene, "
                "which is only supported on macOS 10.14 and higher.")
        state[
            "feature_extractor"] = _image_feature_extractor._create_feature_extractor(
                state["model"])
        state["input_image_shape"] = tuple(
            [int(i) for i in state["input_image_shape"]])
        return ImageSimilarityModel(state)
示例#2
0
    def _load_version(cls, state, version):
        """
        A function to load a previously saved ImageClassifier
        instance.

        Parameters
        ----------
        unpickler : GLUnpickler
            A GLUnpickler file handler.

        version : int
            Version number maintained by the class writer.
        """
        _tkutl._model_version_check(version,
                                    cls._PYTHON_IMAGE_SIMILARITY_VERSION)
        from turicreate.toolkits.nearest_neighbors import NearestNeighborsModel
        state['similarity_model'] = NearestNeighborsModel(
            state['similarity_model'])
        # Load pre-trained model & feature extractor
        ptModel = _pre_trained_models.MODELS[state['model']]()
        feature_extractor = _image_feature_extractor.MXFeatureExtractor(
            ptModel)
        state['feature_extractor'] = feature_extractor
        state['input_image_shape'] = tuple(
            [int(i) for i in state['input_image_shape']])
        return ImageSimilarityModel(state)