usama-x930 / VT-LPR

Automatic Toll Tax Collection With Vehicle Type And License Plate Recognition Using Deep Learning
35 stars 12 forks source link

detect.py with multiple input images not working #5

Open pmfcdb opened 1 year ago

pmfcdb commented 1 year ago

Hello, detect.py with multiple input images not working. Runing in windows11, python3.8, tensorflow 2.10.1, cuda 11.2, cuDNN 8.1

In this example I have 2 input images: --images ./data/images/car.jpg,./data/images/car1.jpg and only the first get's predicted.

(ALPR_VT-LPR-yolov4) D:\Documents\alpr_ocr\docr03\VT-LPR-main\tensorflow_yolov4_tflite>python detect.py --weights ./checkpoints/custom-416 --size 416 --model yolov4 --images ./data/images/car.jpg,./data/images/car1.jpg
2023-03-24 11:55:07.429861: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2023-03-24 11:55:07.766596: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1616] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 5490 MB memory:  -> device: 0, name: NVIDIA GeForce RTX 3070 Laptop GPU, pci bus id: 0000:01:00.0, compute capability: 8.6
2023-03-24 11:55:07.783455: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1616] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 5490 MB memory:  -> device: 0, name: NVIDIA GeForce RTX 3070 Laptop GPU, pci bus id: 0000:01:00.0, compute capability: 8.6
['./data/images/car.jpg', './data/images/car1.jpg']
./data/images/car.jpg
2023-03-24 11:55:18.834372: I tensorflow/stream_executor/cuda/cuda_dnn.cc:384] Loaded cuDNN version 8100
2023-03-24 11:55:20.592446: I tensorflow/stream_executor/cuda/cuda_blas.cc:1614] TensorFloat-32 will be used for the matrix multiplication. This will only be logged once.
tf.Tensor([0.79416025 0.35244757 0.8548766  0.43816927], shape=(4,), dtype=float32)
tf.Tensor(0.9769959, shape=(), dtype=float32)
./data/images/car1.jpg
tf.Tensor([0. 0. 0. 0.], shape=(4,), dtype=float32)
tf.Tensor(0.0, shape=(), dtype=float32)

If I load the model inside the image loop it will work, but that is not time eficient.

for count, image_path in enumerate(images, 1):
    ...
    saved_model_loaded = tf.saved_model.load(FLAGS.weights, tags=[tag_constants.SERVING])

I'm printing the boxes and scores to see the bbox of the LP and the score.

      print(boxes[0][0])
        print(scores[0][0])
        pred_bbox = [boxes.numpy(), scores.numpy(), classes.numpy(), valid_detections.numpy()]

Here is the result when I load the model inside the image loop.

(ALPR_VT-LPR-yolov4) D:\Documents\alpr_ocr\docr03\VT-LPR-main\tensorflow_yolov4_tflite>python detect.py --weights ./checkpoints/custom-416 --size 416 --model yolov4 --images ./data/images/car.jpg,./data/images/car1.jpg
2023-03-24 12:05:24.396268: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2023-03-24 12:05:24.740876: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1616] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 5490 MB memory:  -> device: 0, name: NVIDIA GeForce RTX 3070 Laptop GPU, pci bus id: 0000:01:00.0, compute capability: 8.6
2023-03-24 12:05:24.757496: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1616] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 5490 MB memory:  -> device: 0, name: NVIDIA GeForce RTX 3070 Laptop GPU, pci bus id: 0000:01:00.0, compute capability: 8.6
['./data/images/car.jpg', './data/images/car1.jpg']
./data/images/car.jpg
2023-03-24 12:05:35.841978: I tensorflow/stream_executor/cuda/cuda_dnn.cc:384] Loaded cuDNN version 8100
2023-03-24 12:05:37.604676: I tensorflow/stream_executor/cuda/cuda_blas.cc:1614] TensorFloat-32 will be used for the matrix multiplication. This will only be logged once.
tf.Tensor([0.79416025 0.35244757 0.8548766  0.43816927], shape=(4,), dtype=float32)
tf.Tensor(0.9769959, shape=(), dtype=float32)
./data/images/car1.jpg
tf.Tensor([0.5381658  0.28271842 0.6058951  0.37036377], shape=(4,), dtype=float32)
tf.Tensor(0.9372273, shape=(), dtype=float32)

@usama-x930

did you test several images in detect.py?