Skip to content

Commit 2d651fe

Browse files
committed
add yolo docs
1 parent 6379d01 commit 2d651fe

2 files changed

Lines changed: 51 additions & 1 deletion

File tree

tensorlayer/app/computer_vision.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,33 @@
99

1010

1111
class object_detection(object):
12+
"""Model encapsulation.
13+
14+
Parameters
15+
----------
16+
model_name : str
17+
Choose the model to inference.
18+
19+
Methods
20+
---------
21+
__init__()
22+
Initializing the model.
23+
__call__()
24+
(1)Formatted input and output. (2)Inference model.
25+
list()
26+
Abstract method. Return available a list of model_name.
27+
28+
Examples
29+
---------
30+
Object Detection detection MSCOCO with YOLOv4, see `tutorial_object_detection_yolov4.py
31+
<https://github.com/tensorlayer/tensorlayer/blob/master/example/app_tutorials/tutorial_object_detection_yolov4.py>`__
32+
With TensorLayer
33+
34+
>>> # get the whole model
35+
>>> net = tl.app.computer_vision.object_detection('yolo4-mscoco')
36+
>>> # use for inferencing
37+
>>> output = net(img)
38+
"""
1239

1340
def __init__(self, model_name='yolo4-mscoco'):
1441
self.model_name = model_name

tensorlayer/app/computer_vision_object_detection/yolov4.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#! /usr/bin/python
22
# -*- coding: utf-8 -*-
3-
"""YOLOv4 for MS COCO.
3+
"""YOLOv4 for MS-COCO.
44
55
# Reference:
66
- [tensorflow-yolov4-tflite](
@@ -139,6 +139,29 @@ def cspdarknet53(input_data=None):
139139

140140

141141
def YOLOv4(NUM_CLASS, pretrained=False):
142+
"""Pre-trained YOLOv4 model.
143+
144+
Parameters
145+
------------
146+
NUM_CLASS : int
147+
Number of classes in final prediction.
148+
pretrained : boolean
149+
Whether to load pretrained weights. Default False.
150+
151+
Examples
152+
---------
153+
Object Detection with YOLOv4, see `computer_vision.py
154+
<https://github.com/tensorlayer/tensorlayer/blob/master/tensorlayer/app/computer_vision.py>`__
155+
With TensorLayer
156+
157+
>>> # get the whole model, without pre-trained YOLOv4 parameters
158+
>>> yolov4 = tl.app.YOLOv4(NUM_CLASS=80, pretrained=False)
159+
>>> # get the whole model, restore pre-trained YOLOv4 parameters
160+
>>> yolov4 = tl.app.YOLOv4(NUM_CLASS=80, pretrained=True)
161+
>>> # use for inferencing
162+
>>> output = yolov4(img, is_train=False)
163+
164+
"""
142165

143166
input_layer = Input([None, INPUT_SIZE, INPUT_SIZE, 3])
144167
route_1, route_2, conv = cspdarknet53(input_layer)

0 commit comments

Comments
 (0)