-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdetection_custom.py
33 lines (26 loc) · 1.28 KB
/
detection_custom.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#================================================================
#
# Description : object detection image and video example
#
#================================================================
import os
#os.environ['CUDA_VISIBLE_DEVICES'] = '-1'
import cv2
import numpy as np
import tensorflow as tf
from yolov3.yolov3 import Create_Yolov3
from yolov3.utils import load_yolo_weights, detect_image, detect_video, detect_realtime
from yolov3.configs import *
input_size = YOLO_INPUT_SIZE
Darknet_weights = YOLO_DARKNET_WEIGHTS
if TRAIN_YOLO_TINY:
Darknet_weights = YOLO_DARKNET_TINY_WEIGHTS
image_path = "./IMAGES/TATA_12_aug_8.jpg"
video_path = "./IMAGES/city.mp4"
yolo = Create_Yolov3(input_size=input_size, CLASSES=TRAIN_CLASSES)
yolo.load_weights("./checkpoints/yolov3_custom_logo") # use keras weights
# this function returns tuple with label values and image
label, _ = detect_image(yolo, image_path, "./IMAGES/logo_tata12_detect.jpg", input_size=input_size, show=True, CLASSES=TRAIN_CLASSES, rectangle_colors=(255,0,0))
print(label)
#detect_video(yolo, video_path, './IMAGES/detected.mp4', input_size=input_size, show=False, CLASSES=TRAIN_CLASSES, rectangle_colors=(255,0,0))
#detect_realtime(yolo, '', input_size=input_size, show=True, CLASSES=TRAIN_CLASSES, rectangle_colors=(255, 0, 0))