Skip to content

Commit ffcfdff

Browse files
committed
Add a new example and more
- Add an example of retraining all internal reider classifiers for GTA V dataset - Rearrange some examples
1 parent 2ee6a15 commit ffcfdff

File tree

7 files changed

+74
-12
lines changed

7 files changed

+74
-12
lines changed

docs/examples.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ The examples below will help you make the most use of **pyppbox**. Before you tr
2323
examples/example_11
2424
examples/example_12
2525
examples/example_13
26+
examples/example_14
2627

2728
|
2829

docs/examples/example_12.rst

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
Example 12: Use a supported module directly
2-
===========================================
1+
Example 12: Train all the internal reider classifiers for GTA V dataset
2+
=======================================================================
33

4-
- **Description**: Use a supported detector/tracker/reider directly in your code.
4+
- **Description**: Use the standalone :func:`trainReIDClassifier()` to train and save a classifier .PKL files for GTA V dataset.
55
- **Featuring**:
6-
- :py:class:`MyYOLOULT` | :py:class:`pyppbox.modules.detectors.yoloult.MyYOLOULT`
7-
- :py:class:`DCFGYOLOULT` | :py:class:`pyppbox.config.myconfig.DCFGYOLOULT`
6+
- :py:meth:`trainReIDClassifier` | :py:meth:`pyppbox.standalone.trainReIDClassifier`
87

98
ℹ️ **Source code and input file(s)** -> `{pyppbox repo}/examples`_
109

1110
.. _{pyppbox repo}/examples: https://github.com/rathaumons/pyppbox/tree/main/examples
1211

13-
.. literalinclude:: ../../examples/example_12_direct_module.py
12+
.. literalinclude:: ../../examples/example_12_retain_gta5_reid_classifiers.py
1413
:encoding: latin-1

docs/examples/example_13.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
Example 13: Use pyppbox in multithreading application
2-
=====================================================
1+
Example 13: Use a supported module directly
2+
===========================================
33

4-
- **Description**: Use a pyppbox in multithreading application.
4+
- **Description**: Use a supported detector/tracker/reider directly in your code.
55
- **Featuring**:
6-
- :py:class:`MT` | :py:class:`pyppbox.ppb.mt.MT`
7-
- :py:func:`visualizePeople` | :py:func:`pyppbox.utils.visualizetools.visualizePeople`
6+
- :py:class:`MyYOLOULT` | :py:class:`pyppbox.modules.detectors.yoloult.MyYOLOULT`
7+
- :py:class:`DCFGYOLOULT` | :py:class:`pyppbox.config.myconfig.DCFGYOLOULT`
88

99
ℹ️ **Source code and input file(s)** -> `{pyppbox repo}/examples`_
1010

1111
.. _{pyppbox repo}/examples: https://github.com/rathaumons/pyppbox/tree/main/examples
1212

13-
.. literalinclude:: ../../examples/example_13_multithreading.py
13+
.. literalinclude:: ../../examples/example_13_direct_module.py
1414
:encoding: latin-1

docs/examples/example_14.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Example 14: Use pyppbox in multithreading application
2+
=====================================================
3+
4+
- **Description**: Use a pyppbox in multithreading application.
5+
- **Featuring**:
6+
- :py:class:`MT` | :py:class:`pyppbox.ppb.mt.MT`
7+
- :py:func:`visualizePeople` | :py:func:`pyppbox.utils.visualizetools.visualizePeople`
8+
9+
ℹ️ **Source code and input file(s)** -> `{pyppbox repo}/examples`_
10+
11+
.. _{pyppbox repo}/examples: https://github.com/rathaumons/pyppbox/tree/main/examples
12+
13+
.. literalinclude:: ../../examples/example_14_multithreading.py
14+
:encoding: latin-1
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#################################################################################
2+
# Example of retraining all the internal reider classifiers for GTA V dataset
3+
#################################################################################
4+
5+
import os
6+
import pyppbox
7+
from pyppbox.standalone import trainReIDClassifier
8+
9+
10+
pyppbox_root = os.path.dirname(pyppbox.__file__)
11+
12+
gta5_osnet_ain_config = {
13+
'ri_name': 'Torchreid',
14+
'classifier_pkl': f'{pyppbox_root}/data/modules/torchreid/classifier/gta5_osnet_ain_ms_d_c.pkl',
15+
'train_data': f'{pyppbox_root}/data/datasets/GTA_V_DATASET/body_128x256',
16+
'model_name': 'osnet_ain_x1_0',
17+
'model_path': f'{pyppbox_root}/data/modules/torchreid/models/torchreid/osnet_ain_ms_d_c.pth.tar',
18+
'min_confidence': 0.35,
19+
'device': 'cuda'
20+
}
21+
22+
gta5_osnet_config = {
23+
'ri_name': 'Torchreid',
24+
'classifier_pkl': f'{pyppbox_root}/data/modules/torchreid/classifier/gta5_osnet_ms_d_c.pkl',
25+
'train_data': f'{pyppbox_root}/data/datasets/GTA_V_DATASET/body_128x256',
26+
'model_name': 'osnet_x1_0',
27+
'model_path': f'{pyppbox_root}/data/modules/torchreid/models/torchreid/osnet_ms_d_c.pth.tar',
28+
'min_confidence': 0.35,
29+
'device': 'cuda'
30+
}
31+
32+
gta5_facenet_config = {
33+
'ri_name': 'FaceNet',
34+
'gpu_mem': 0.585,
35+
'model_det': f'{pyppbox_root}/data/modules/facenet/models/det',
36+
'model_file': f'{pyppbox_root}/data/modules/facenet/models/20180402-114759/20180402-114759.pb',
37+
'classifier_pkl': f'{pyppbox_root}/data/modules/facenet/classifier/gta5.pkl',
38+
'train_data': f'{pyppbox_root}/data/datasets/GTA_V_DATASET/face_182x182',
39+
'batch_size': 1000,
40+
'min_confidence': 0.75,
41+
'yl_h_calibration': [-125, 75],
42+
'yl_w_calibration': [-55, 55]
43+
}
44+
45+
trainReIDClassifier(reider=gta5_osnet_ain_config)
46+
trainReIDClassifier(reider=gta5_osnet_config)
47+
trainReIDClassifier(reider=gta5_facenet_config)
48+

0 commit comments

Comments
 (0)