jackliu333 / object_detection_using_tensorflow

9 stars 2 forks source link

Change tensorflow by yolov8 as prediction model #2

Open Leprechault opened 6 months ago

Leprechault commented 6 months ago

Hi @jackliu333 ,

First I like so much you app. Please, I need a help to make some customizations in the code in image_classification.py file, because I used yolov8 and not tensorflow as prediction model.

For applying the yolov8 normally I just need:

# install yolov8
from ultralytics import YOLO

# Import my trained model 
model = YOLO (r"C:\Users\fores\dashbord\best.pt") 

# Load detection model 
detection_model = model()

But if change in the image_clasdification.py:

def load_model(model_name):
    base_url = 'http://download.tensorflow.org/models/object_detection/'
    model_file = model_name + '.tar.gz'
    model_dir = tf.keras.utils.get_file(
    fname=model_name, 
    origin=base_url + model_file,
    untar=True)

    model_dir = pathlib.Path(model_dir)/"saved_model"

    model = tf.saved_model.load(str(model_dir))
    model = model.signatures['serving_default']

    return model

# Pipeline configuration file
PATH_TO_PIPELINE_CONFIG = 'Tensorflow/workspace/models/my_ssd_mobnet/pipeline.config'
configs = config_util.get_configs_from_pipeline_file(PATH_TO_PIPELINE_CONFIG)

# Load detection model
detection_model = model_builder.build(model_config=configs['model'], is_training=False)

By my code the dashboard doesn't work. Please @jackliu333 could you help me?