GithubHelp home page GithubHelp logo

Comments (6)

Gaurav061003 avatar Gaurav061003 commented on May 18, 2024

how to solve this issue please tell me

from models.

laxmareddyp avatar laxmareddyp commented on May 18, 2024

Hi @Gaurav061003 ,

Could you please provide the reproducible code and share the exact repo which you are using for training the models if possible.

Thanks

from models.

Gaurav061003 avatar Gaurav061003 commented on May 18, 2024

##Reproducible code
WORKSPACE_PATH = 'Tensorflow/workspace'
SCRIPTS_PATH = 'Tensorflow/scripts'
APIMODEL_PATH = 'Tensorflow/models'
ANNOTATION_PATH = WORKSPACE_PATH+'/annotations'
IMAGE_PATH = WORKSPACE_PATH+'/images'
MODEL_PATH = WORKSPACE_PATH+'/models'
PRETRAINED_MODEL_PATH = WORKSPACE_PATH+'/pre-trained-models'
CONFIG_PATH = MODEL_PATH+'/my_ssd_mobnet/pipeline.config'
CHECKPOINT_PATH = MODEL_PATH+'/my_ssd_mobnet/'

  1. Create Label Map
    labels = [{'name':'Hello', 'id':1},
    {'name':'Yes', 'id':2},
    {'name':'No', 'id':3},
    {'name':'Thanks', 'id':4},
    {'name':'I Love You', 'id':5},
    ]
    with open(ANNOTATION_PATH + '\label_map.pbtxt', 'w') as f:
    for label in labels:
    f.write('item { \n')
    f.write('\tname:'{}'\n'.format(label['name']))
    f.write('\tid:{}\n'.format(label['id']))
    f.write('}\n')

  2. Create TF records
    import os

    def create_tf_record(image_dir, annotation_path, output_path):
    os.system(f"python {SCRIPTS_PATH}/generate_tfrecord.py -x {image_dir} -l {annotation_path}/label_map.pbtxt -o {output_path}")
    print(f"Successfully created the TFRecord file: {output_path}")

Example usage:

train_image_dir = os.path.join(IMAGE_PATH, 'train')
test_image_dir = os.path.join(IMAGE_PATH, 'test')
train_output_path = os.path.join(ANNOTATION_PATH, 'train.record')
test_output_path = os.path.join(ANNOTATION_PATH, 'test.record')

create_tf_record(train_image_dir, ANNOTATION_PATH, train_output_path)
create_tf_record(test_image_dir, ANNOTATION_PATH, test_output_path)

import os
import urllib.request
import tarfile

def download_pretrained_model(model_name, model_dir):
model_url = f'http://download.tensorflow.org/models/object_detection/tf2/20200711/{model_name}.tar.gz'
model_path = os.path.join(model_dir, f"{model_name}.tar.gz")

# Download the model
urllib.request.urlretrieve(model_url, model_path)

# Extract the downloaded file
with tarfile.open(model_path, 'r:gz') as tar:
    tar.extractall(model_dir)

# Remove the compressed file
os.remove(model_path)

print(f"Download and extraction of {model_name} complete.")

Example usage:

pretrained_model_name = 'ssd_mobilenet_v2_fpnlite_320x320_coco17_tpu-8'
PRETRAINED_MODEL_PATH = 'Tensorflow/workspace/pre-trained-models' # Assuming this is your predefined path
download_pretrained_model(pretrained_model_name, PRETRAINED_MODEL_PATH)

  1. Copy Model Config to Training Folder
    CUSTOM_MODEL_NAME = 'my_ssd_mobnet'
    !mkdir {'Tensorflow\workspace\models\'+CUSTOM_MODEL_NAME}

  2. Update Config For Transfer Learning
    import tensorflow as tf
    from google.protobuf import text_format
    from object_detection.utils import config_util
    from object_detection.protos import pipeline_pb2

##exact repo
C:\Users\RAVI\RealTimeObjectDetection-main\Tensorflow\models\research\object_detection

from models.

laxmareddyp avatar laxmareddyp commented on May 18, 2024

Hi @Gaurav061003,

Support for the older codebase has been discontinued. Could you kindly utilize the official Object Detection models provided by TensorFlow Model Garden.

I strongly suggest utilizing the TensorFlow Official Model Garden to circumvent issues related to outdated code commonly found in research codebases. Unlike the research repositories, the Official Model Garden is consistently updated and aligned with the latest changes in TensorFlow and other libraries.

Hope you understanding and Happy coding.

Thanks

from models.

Gaurav061003 avatar Gaurav061003 commented on May 18, 2024

but im using the updated version of [official Object Detection

from models.

zhangj726 avatar zhangj726 commented on May 18, 2024

hi, I met similar problem that 'cannot import module from 'object_detection.protos', have you solved it? @Gaurav061003
Thanks!

from models.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.