forked from tensorlayer/TensorLayer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
781 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
person | ||
bicycle | ||
car | ||
motorbike | ||
aeroplane | ||
bus | ||
train | ||
truck | ||
boat | ||
traffic light | ||
fire hydrant | ||
stop sign | ||
parking meter | ||
bench | ||
bird | ||
cat | ||
dog | ||
horse | ||
sheep | ||
cow | ||
elephant | ||
bear | ||
zebra | ||
giraffe | ||
backpack | ||
umbrella | ||
handbag | ||
tie | ||
suitcase | ||
frisbee | ||
skis | ||
snowboard | ||
sports ball | ||
kite | ||
baseball bat | ||
baseball glove | ||
skateboard | ||
surfboard | ||
tennis racket | ||
bottle | ||
wine glass | ||
cup | ||
fork | ||
knife | ||
spoon | ||
bowl | ||
banana | ||
apple | ||
sandwich | ||
orange | ||
broccoli | ||
carrot | ||
hot dog | ||
pizza | ||
donut | ||
cake | ||
chair | ||
sofa | ||
potted plant | ||
bed | ||
dining table | ||
toilet | ||
tvmonitor | ||
laptop | ||
mouse | ||
remote | ||
keyboard | ||
cell phone | ||
microwave | ||
oven | ||
toaster | ||
sink | ||
refrigerator | ||
book | ||
clock | ||
vase | ||
scissors | ||
teddy bear | ||
hair drier | ||
toothbrush |
Large diffs are not rendered by default.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
examples/app_tutorials/tutorial_object_detection_yolov4_image.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#! /usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
from tensorlayer.app import computer_vision | ||
from tensorlayer import visualize | ||
from tensorlayer.app.computer_vision_object_detection.common import read_class_names | ||
import numpy as np | ||
import cv2 | ||
from PIL import Image | ||
INPUT_SIZE = 416 | ||
image_path = './data/kite.jpg' | ||
|
||
class_names = read_class_names('./model/coco.names') | ||
original_image = cv2.imread(image_path) | ||
image = cv2.cvtColor(np.array(original_image), cv2.COLOR_BGR2RGB) | ||
net = computer_vision.object_detection('yolo4-mscoco') | ||
json_result = net(original_image) | ||
print(type(json_result)) | ||
image = visualize.draw_boxes_and_labels_to_image_with_json(image, json_result, class_names) | ||
image = Image.fromarray(image.astype(np.uint8)) | ||
image.show() |
38 changes: 38 additions & 0 deletions
38
examples/app_tutorials/tutorial_object_detection_yolov4_video.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#! /usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
from tensorlayer.app import computer_vision | ||
from tensorlayer import visualize | ||
from tensorlayer.app.computer_vision_object_detection.common import read_class_names | ||
import cv2 | ||
INPUT_SIZE = 416 | ||
video_path = './data/road.mp4' | ||
|
||
class_names = read_class_names('./model/coco.names') | ||
vid = cv2.VideoCapture(video_path) | ||
''' | ||
vid = cv2.VideoCapture(0) # the serial number of camera on you device | ||
''' | ||
|
||
if not vid.isOpened(): | ||
raise ValueError("Read Video Failed!") | ||
net = computer_vision.object_detection('yolo4-mscoco') | ||
frame_id = 0 | ||
while True: | ||
return_value, frame = vid.read() | ||
if return_value: | ||
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) | ||
else: | ||
if frame_id == vid.get(cv2.CAP_PROP_FRAME_COUNT): | ||
print("Video processing complete") | ||
break | ||
raise ValueError("No image! Try with another video format") | ||
|
||
json_result = net(frame) | ||
image = visualize.draw_boxes_and_labels_to_image_with_json(frame, json_result, class_names) | ||
result = cv2.cvtColor(image, cv2.COLOR_RGB2BGR) | ||
|
||
cv2.namedWindow("result", cv2.WINDOW_AUTOSIZE) | ||
cv2.imshow("result", result) | ||
if cv2.waitKey(1) & 0xFF == ord('q'): break | ||
frame_id += 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters