Using Tensorflow object detection api Import graph_matcher error

Hi, I am using Tensorflow Object Detection Api with TF2.10, facing a error on .\site-packages\object_detection\exporter.py, error code delow:

(tf2539) E:\Tensorflow\workspace\test_1>python model_main_tf2.py --model_dir=models\my_faster_rcnn_resnet152_v1 --pipeline_config_path=models\my_faster_rcnn_resnet152_v1\pipeline.config
C:\Users\User\anaconda3\envs\tf2539\lib\site-packages\tensorflow_addons\utils\tfa_eol_msg.py:23: UserWarning:

TensorFlow Addons (TFA) has ended development and introduction of new features.
TFA has entered a minimal maintenance and release mode until a planned end of life in May 2024.
Please modify downstream libraries to take dependencies from other repositories in our TensorFlow community (e.g. Keras, Keras-CV, and Keras-NLP).

warnings.warn(
C:\Users\User\anaconda3\envs\tf2539\lib\site-packages\tensorflow_addons\utils\ensure_tf_install.py:53: UserWarning: Tensorflow Addons supports using Python ops for all Tensorflow versions above or equal to 2.12.0 and strictly below 2.15.0 (nightly versions are not supported).
The versions of TensorFlow you are currently using is 2.10.0 and is not supported.
Some things might work, some things might not.
If you were to encounter a bug, do not file an issue.
If you want to make sure you’re using a tested and supported configuration, either change the TensorFlow version or the TensorFlow Addons’s version.
You can find the compatibility matrix in TensorFlow Addon’s readme:

warnings.warn(
Traceback (most recent call last):
File “E:\Tensorflow\workspace\test_1\model_main_tf2.py”, line 31, in
from object_detection import model_lib_v2
File “C:\Users\User\anaconda3\envs\tf2539\lib\site-packages\object_detection\model_lib_v2.py”, line 31, in
from object_detection import model_lib
File “C:\Users\User\anaconda3\envs\tf2539\lib\site-packages\object_detection\model_lib.py”, line 28, in
from object_detection import exporter as exporter_lib
File “C:\Users\User\anaconda3\envs\tf2539\lib\site-packages\object_detection\exporter.py”, line 22, in
from tensorflow.contrib.quantize.python import graph_matcher
ModuleNotFoundError: No module named ‘tensorflow.contrib’

I know this error from TF1.X update TF2.X, and Tensorflow.contrib is delete,
so, I try to change this code to fit TF2.10(I use it) ,but it seem not easy to fix,
I already read Topic Import graph_matcher in tensorflow 2.X
but it still get some error, excute code:
from tensorflow.python.summary.writer.writer import FileWriter
FileWriter(‘logs/’, graph=tf.compat.v1.get_default_graph()).close()

and I got:
RuntimeError: v1.summary.FileWriter is not compatible with eager execution. Use tf.summary.create_file_writer,or a with v1.Graph().as_default(): context

I think this error cant be so complicated, does anyone can help me fix it.Thanks it!

Hi @Kuan, Please try by using tf.summary.create_file_writer which has support while using eager execution. please refer to this gist for code example. Thank You.

Hi @Kiran_Sai_Ramineni ,thanks for you reply, I am not a native English speaker, so I will try my best to understand,.
in the code example, should I type those code in .\site-packages\object_detection\exporter.py,?this seem cant solve my problem, maybe I misunderstand the code work, so I confirm my question clearly,
“In exporter.py code, error text is from tensorflow.contrib.quantize.python import graph_matcher, ModuleNotFoundError: No module named ‘tensorflow.contrib’”
what can I solve this error?
Thank you so much for responding to my question!