示例#1
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--video',
                        type=str,
                        default='IMAGES/test1.mp4',
                        help='video path')
    parser.add_argument('--out', type=str, default='./', help='output path')
    args = parser.parse_args()

    input_size = YOLO_INPUT_SIZE

    yolo = Create_Yolov3(input_size=input_size, CLASSES=TRAIN_CLASSES)
    yolo.load_weights("./checkpoints/yolov3_face_Tiny.h5")

    vid_path = args.video
    out_path = args.out + 'output.mp4'
    detect_video(yolo,
                 vid_path,
                 out_path,
                 show=True,
                 CLASSES=TRAIN_CLASSES,
                 iou_threshold=0.25)
import numpy as np
import tensorflow as tf

from utils import setup_tf_conf
setup_tf_conf()

#from yolov3.yolov3 import Create_Yolov3
from yolov3.yolov4 import Create_Yolo
from yolov3.utils import load_yolo_weights, detect_image, detect_video, detect_realtime
from yolov3.configs import *

if YOLO_TYPE == "yolov4":
    Darknet_weights = YOLO_V4_TINY_WEIGHTS if TRAIN_YOLO_TINY else YOLO_V4_WEIGHTS
if YOLO_TYPE == "yolov3":
    Darknet_weights = YOLO_V3_TINY_WEIGHTS if TRAIN_YOLO_TINY else YOLO_V3_WEIGHTS

image_path = "./IMAGES/kite.jpg"
video_path = "./IMAGES/test.mp4"

yolo = Create_Yolo(input_size=YOLO_INPUT_SIZE)
load_yolo_weights(yolo, Darknet_weights)  # use Darknet weights

#detect_image(yolo, image_path, '', input_size=YOLO_INPUT_SIZE, show=True, rectangle_colors=(255,0,0))
detect_video(yolo,
             video_path,
             './IMAGES/test_pred.mp4',
             input_size=YOLO_INPUT_SIZE,
             show=False,
             rectangle_colors=(255, 0, 0))
#detect_realtime(yolo, '', input_size=YOLO_INPUT_SIZE, show=True, rectangle_colors=(255, 0, 0))
示例#3
0
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
import cv2
import numpy as np
import tensorflow as tf
from yolov3.utils import detect_image, detect_realtime, detect_video, Load_Yolo_model, detect_video_realtime_mp
from yolov3.configs import *

#image_path   = "./IMAGES/kite.jpg"
video_path = "./model_data/test.mp4"

yolo = Load_Yolo_model()
#detect_image(yolo, image_path, "./IMAGES/kite_pred.jpg", input_size=YOLO_INPUT_SIZE, show=True, rectangle_colors=(255,0,0))
detect_video(yolo,
             video_path,
             "./model_data/test_pred_Gul_GPU_test2.mp4",
             input_size=YOLO_INPUT_SIZE,
             show=False,
             rectangle_colors=(255, 0, 0))
#detect_realtime(yolo, '', input_size=YOLO_INPUT_SIZE, show=True, rectangle_colors=(255, 0, 0))

#detect_video_realtime_mp(video_path, "./model_data/test_pred.mp4", input_size=YOLO_INPUT_SIZE, show=False, rectangle_colors=(255,0,0), realtime=False)
#================================================================
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
import cv2
import numpy as np
import tensorflow as tf
#from yolov3.yolov3 import Create_Yolov3
from yolov3.yolov4 import Create_Yolo
from yolov3.utils import load_yolo_weights, detect_image, detect_video, detect_realtime
from yolov3.configs import *

if YOLO_TYPE == "yolov4":
    Darknet_weights = YOLO_V4_TINY_WEIGHTS if TRAIN_YOLO_TINY else YOLO_V4_WEIGHTS
if YOLO_TYPE == "yolov3":
    Darknet_weights = YOLO_V3_TINY_WEIGHTS if TRAIN_YOLO_TINY else YOLO_V3_WEIGHTS

image_path = "./IMAGES/kite.jpg"
video_path = "./IMAGES/test.mp4"

yolo = Create_Yolo(input_size=YOLO_INPUT_SIZE)
load_yolo_weights(yolo, Darknet_weights)  # use Darknet weights

#detect_image(yolo, image_path, '', input_size=YOLO_INPUT_SIZE, show=True, rectangle_colors=(255,0,0))
detect_video(yolo,
             video_path,
             '',
             input_size=YOLO_INPUT_SIZE,
             show=True,
             rectangle_colors=(255, 0, 0))
#detect_realtime(yolo, '', input_size=YOLO_INPUT_SIZE, show=True, rectangle_colors=(255, 0, 0))
示例#5
0
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
import cv2
import numpy as np
import tensorflow as tf
from yolov3.utils import detect_image, detect_realtime, detect_video, Load_Yolo_model, detect_video_realtime_mp
from yolov3.configs import *

image_path   = "./IMAGES/"
video_path   = "./IMAGES/"

yolo = Load_Yolo_model()
#detect_image(yolo, image_path, "./IMAGES/................", input_size=YOLO_INPUT_SIZE, show=True, CLASSES=TRAIN_CLASSES, rectangle_colors=(255,0,0))
detect_video(yolo, video_path, './IMAGES/detected.mp4', input_size=YOLO_INPUT_SIZE, show=False, CLASSES=TRAIN_CLASSES, rectangle_colors=(255,0,0))
#detect_realtime(yolo, '', input_size=YOLO_INPUT_SIZE, show=True, CLASSES=TRAIN_CLASSES, rectangle_colors=(255, 0, 0))

#detect_video_realtime_mp(video_path, "Output.mp4", input_size=YOLO_INPUT_SIZE, show=True, CLASSES=TRAIN_CLASSES, rectangle_colors=(255,0,0), realtime=False)
#   Website     : https://pylessons.com/
#   GitHub      : https://github.com/pythonlessons/TensorFlow-2.x-YOLOv3
#   Description : object detection image and video example
#
#================================================================
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
import cv2
import numpy as np
import tensorflow as tf
#from yolov3.yolov4 import Create_Yolo
from yolov3.utils import detect_image, detect_realtime, detect_video, Load_Yolo_model, detect_video_realtime_mp,load_yolo_weights
from yolov3.utils import detect_video, Load_Yolo_model
from yolov3.configs import *

image_path   = "./IMAGES/drone1.png"

#video_path   = "rtsp://192.168.123.91/axis-media/media.amp"
#video_path = "./IMAGES/20210325_164706_2550.mp4"
video_path = "./IMAGES/cla.mp4"

#yolo = Create_Yolo(input_size=YOLO_INPUT_SIZE, CLASSES=TRAIN_CLASSES)
#yolo.load_weights("./checkpoints/yolov3_custom") # use keras weights, i add
yolo = Load_Yolo_model()
#detect_image(yolo, image_path, "./IMAGES/drone1.png", input_size=YOLO_INPUT_SIZE, show=True, CLASSES=TRAIN_CLASSES,score_threshold=0.4, rectangle_colors=(255,0,0))
detect_video(yolo, video_path, "./IMAGES/output1.mp4", input_size=YOLO_INPUT_SIZE, show=True, CLASSES=TRAIN_CLASSES, score_threshold=0.6,rectangle_colors=(255,0,0))
#detect_realtime(yolo, '', input_size=YOLO_INPUT_SIZE, show=True, CLASSES=TRAIN_CLASSES, rectangle_colors=(255, 0, 0))

#detect_video_realtime_mp(video_path, "", input_size=YOLO_INPUT_SIZE, show=True, CLASSES=TRAIN_CLASSES, rectangle_colors=(255,0,0), realtime=False)
#try1(yolo)
Darknet_weights = YOLO_DARKNET_WEIGHTS
# if TRAIN_YOLO_TINY:
#     Darknet_weights = YOLO_DARKNET_TINY_WEIGHTS
time_s = time.time()
video_path = ["Test_Video/people_walking_3.mp4"]
# image_path = ["test_images_and_videos/deer_cow.jpg",
# 			"test_images_and_videos/84353914_188324fbb9_b.jpg",
# 			"test_images_and_videos/87180235_d8bb660c55_b.jpg",
# 			"test_images_and_videos/91693053_6c39a7192c_o.jpg",
# 			"test_images_and_videos/manymanydeers.jpg"]
yolo = Create_Yolov3(input_size=input_size, CLASSES=TRAIN_CLASSES)
# yolo.load_weights("./checkpoints/yolov3_custom") # use keras weights
yolo.load_weights(
    "./checkpoints/yolov3_custom_combined_dataset")  # use keras weights
count = 0
# for i in image_path:
# 	detect_image(yolo, i, "./IMAGES/new_image_"+str(count)+".jpg", input_size=input_size, show=True, CLASSES=TRAIN_CLASSES, rectangle_colors=(255,0,0))
# 	count+=1
for v in video_path:
    detect_video(yolo,
                 v,
                 "./IMAGES/Result_CCTV_Video_Combined_2" + ".mp4",
                 input_size=input_size,
                 show=False,
                 CLASSES=TRAIN_CLASSES,
                 rectangle_colors=(255, 0, 0))
time_end = time.time()
time_total = time_end - time_s
print('Total Time YOLO V3: > ', time_total)
#detect_realtime(yolo, '', input_size=input_size, show=True, CLASSES=TRAIN_CLASSES, rectangle_colors=(255, 0, 0))