Skip to content

Commit

Permalink
Add a new example and more
Browse files Browse the repository at this point in the history
- Add an example of retraining all internal reider classifiers for GTA V dataset
- Rearrange some examples
  • Loading branch information
rathaROG committed Jan 10, 2025
1 parent 2ee6a15 commit ffcfdff
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 12 deletions.
1 change: 1 addition & 0 deletions docs/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ The examples below will help you make the most use of **pyppbox**. Before you tr
examples/example_11
examples/example_12
examples/example_13
examples/example_14

|
11 changes: 5 additions & 6 deletions docs/examples/example_12.rst
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
Example 12: Use a supported module directly
===========================================
Example 12: Train all the internal reider classifiers for GTA V dataset
=======================================================================

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

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

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

.. literalinclude:: ../../examples/example_12_direct_module.py
.. literalinclude:: ../../examples/example_12_retain_gta5_reid_classifiers.py
:encoding: latin-1
12 changes: 6 additions & 6 deletions docs/examples/example_13.rst
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Example 13: Use pyppbox in multithreading application
=====================================================
Example 13: Use a supported module directly
===========================================

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

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

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

.. literalinclude:: ../../examples/example_13_multithreading.py
.. literalinclude:: ../../examples/example_13_direct_module.py
:encoding: latin-1
14 changes: 14 additions & 0 deletions docs/examples/example_14.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Example 14: Use pyppbox in multithreading application
=====================================================

- **Description**: Use a pyppbox in multithreading application.
- **Featuring**:
- :py:class:`MT` | :py:class:`pyppbox.ppb.mt.MT`
- :py:func:`visualizePeople` | :py:func:`pyppbox.utils.visualizetools.visualizePeople`

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

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

.. literalinclude:: ../../examples/example_14_multithreading.py
:encoding: latin-1
48 changes: 48 additions & 0 deletions examples/example_12_retain_gta5_reid_classifiers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#################################################################################
# Example of retraining all the internal reider classifiers for GTA V dataset
#################################################################################

import os
import pyppbox
from pyppbox.standalone import trainReIDClassifier


pyppbox_root = os.path.dirname(pyppbox.__file__)

gta5_osnet_ain_config = {
'ri_name': 'Torchreid',
'classifier_pkl': f'{pyppbox_root}/data/modules/torchreid/classifier/gta5_osnet_ain_ms_d_c.pkl',
'train_data': f'{pyppbox_root}/data/datasets/GTA_V_DATASET/body_128x256',
'model_name': 'osnet_ain_x1_0',
'model_path': f'{pyppbox_root}/data/modules/torchreid/models/torchreid/osnet_ain_ms_d_c.pth.tar',
'min_confidence': 0.35,
'device': 'cuda'
}

gta5_osnet_config = {
'ri_name': 'Torchreid',
'classifier_pkl': f'{pyppbox_root}/data/modules/torchreid/classifier/gta5_osnet_ms_d_c.pkl',
'train_data': f'{pyppbox_root}/data/datasets/GTA_V_DATASET/body_128x256',
'model_name': 'osnet_x1_0',
'model_path': f'{pyppbox_root}/data/modules/torchreid/models/torchreid/osnet_ms_d_c.pth.tar',
'min_confidence': 0.35,
'device': 'cuda'
}

gta5_facenet_config = {
'ri_name': 'FaceNet',
'gpu_mem': 0.585,
'model_det': f'{pyppbox_root}/data/modules/facenet/models/det',
'model_file': f'{pyppbox_root}/data/modules/facenet/models/20180402-114759/20180402-114759.pb',
'classifier_pkl': f'{pyppbox_root}/data/modules/facenet/classifier/gta5.pkl',
'train_data': f'{pyppbox_root}/data/datasets/GTA_V_DATASET/face_182x182',
'batch_size': 1000,
'min_confidence': 0.75,
'yl_h_calibration': [-125, 75],
'yl_w_calibration': [-55, 55]
}

trainReIDClassifier(reider=gta5_osnet_ain_config)
trainReIDClassifier(reider=gta5_osnet_config)
trainReIDClassifier(reider=gta5_facenet_config)

File renamed without changes.
File renamed without changes.

0 comments on commit ffcfdff

Please sign in to comment.