<jupyter_start><jupyter_text><jupyter_code>!pip install tensorflow-gpu==2.7.0
import tensorflow as tf
print(tf.__version__)
!git clone https://github.com/tensorflow/models.git
pwd
cd /content/models/research
pwd
# From within TensorFlow/models/research/
!protoc object_detection/protos/*.proto --python_out=.
!git clone https://github.com/cocodataset/cocoapi.git
cd cocoapi/PythonAPI
!make
cp -r pycocotools /content/models/research<jupyter_output><empty_output><jupyter_text>Install Object Detection API<jupyter_code>pwd
cd ..
cd /content/models/research
cp object_detection/packages/tf2/setup.py .
!python -m pip install .
# From within TensorFlow/models/research/
!python object_detection/builders/model_builder_tf2_test.py
cd /content/training_demo/pre-trained-models 
!wget http://download.tensorflow.org/models/object_detection/tf2/20200711/ssd_resnet101_v1_fpn_640x640_coco17_tpu-8.tar.gz
!tar -xvf ssd_resnet101_v1_fpn_640x640_coco17_tpu-8.tar.gz
pwd
cd /content/training_demo
ls
!python generate_tfrecord.py -x /content/training_demo/images/train -l /content/training_demo/annotations/label_map.pbtxt -o /content/training_demo/annotations/train.record

!python generate_tfrecord.py -x /content/training_demo/images/test -l /content/training_demo/annotations/label_map.pbtxt -o /content/training_demo/annotations/test.record

pwd

!pip uninstall opencv-python-headless==4.5.5.62
!pip install opencv-python-headless==4.5.2.52
cd training_demo
!python model_main_tf2.py --model_dir=/content/training_demo/models/my_resnet_model --pipeline_config_path=/content/training_demo/models/my_resnet_model/pipeline-2.config
pwd
cd ..
!zip -r training_demo.zip training_demo
import tensorflow as tf

def solve_cudnn_error():
    gpus = tf.config.experimental.list_physical_devices('GPU')
    if gpus:
        try:
            # Currently, memory growth needs to be the same across GPUs
            for gpu in gpus:
                tf.config.experimental.set_memory_growth(gpu, True)
            logical_gpus = tf.config.experimental.list_logical_devices('GPU')
            print(len(gpus), "Physical GPUs,", len(logical_gpus), "Logical GPUs")
        except RuntimeError as e:
            # Memory growth must be set before GPUs have been initialized
            print(e)
solve_cudnn_error()
import os
os.environ['TF_FORCE_GPU_ALLOW_GROWTH'] = 'true'<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10437710437710437, 'fraction_numerical': 0.021885521885521887, 'mean_word_length': 4.566744730679157, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '597455', 'license': 'MIT', 'n_tokens_mistral': 865, 'n_tokens_neox': 819, 'n_words': 149, 'path': 'Custom_Object_Detection/Custom_Object_Detection.ipynb', 'repo_name': 'kunalgaur7983/AI-Snake', 'size': '2376'}