CoreML Converter Missing Tensorflow Package

I am trying to convert my Tensorflow 2.0 model to a CoreML model so I can deploy it to a mobile app. However, I continually get the error:

ValueError: Converter was called with source="tensorflow", but missing tensorflow package

I am working in a virtual environment with Python 3.7, Tensorflow 2.11, and Coremltools 5.3.1. I had saved the Tensorflow model by using tensorflow.saved_model.save and was attempting to convert the model with the following:

import coremltools as ct

image_input = ct.ImageType(shape=(1, 250, 250, 3,),
                           bias=[-1,-1,-1], scale=1/255)

classifier_config = ct.ClassifierConfig(['Billy','Not_Billy'])

core_model = ct.convert(
    <path_to_saved_model>,
    convert_to='mlprogram',
    inputs=[image_input],
    classifier_config=classifier_config,
    source='tensorflow'
)

I keep receiving this error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/var/folders/7n/vj_bf6q122bg43h_xm957hp80000gn/T/ipykernel_11024/1565729572.py in 
      6     inputs=[image_input],
      7     classifier_config=classifier_config,
----> 8     source='tensorflow'
      9 )

~/Documents/Python/.venv/lib/python3.7/site-packages/coremltools/converters/_converters_entry.py in convert(model, source, inputs, outputs, classifier_config, minimum_deployment_target, convert_to, compute_precision, skip_model_load, compute_units, package_dir, debug, pass_pipeline)
    466     _validate_conversion_arguments(model, exact_source, inputs, outputs_as_tensor_or_image_types,
    467                                    classifier_config, compute_precision,
--> 468                                    exact_target, minimum_deployment_target)
    469 
    470     if pass_pipeline is None:

~/Documents/Python/.venv/lib/python3.7/site-packages/coremltools/converters/_converters_entry.py in _validate_conversion_arguments(model, exact_source, inputs, outputs, classifier_config, compute_precision, convert_to, minimum_deployment_target)
    722         if exact_source == "tensorflow" and not _HAS_TF_1:
    723             raise ValueError(
--> 724                 'Converter was called with source="tensorflow", but missing ' "tensorflow package"
    725             )
    726 

ValueError: Converter was called with source="tensorflow", but missing tensorflow package

EDIT: This issue is happening on a 2021 MacBook Pro with the M1 Pro chip and Ventura 13.4 MacOS

This your environment does not have tensorflow installed while your script uses it. Install tensorflow package and run it again.

Plus import tensorflow in the script.

import tensorflow as tf

CoreML Converter Missing Tensorflow Package
 
 
Q