Skip to content

Commit 831fa91

Browse files
authored
release 1.0.1 (#15)
1 parent 5003a10 commit 831fa91

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1651
-1418
lines changed

.gitattributes

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
models/*.tar.gz filter=lfs diff=lfs merge=lfs -text
2+
*.mp4 filter=lfs diff=lfs merge=lfs -text
3+
*.log filter=lfs diff=lfs merge=lfs -text

.gitignore

+3-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
__pycache__/
33
*.py[cod]
44
*$py.class
5-
pavimentados/models/artifacts/
65

76
# C extensions
87
*.so
@@ -131,13 +130,11 @@ dmypy.json
131130

132131
.idea/
133132
.DS_Store
133+
.tmp/
134134

135135
# Models
136136
models/artifacts
137-
models/*.tar.gz
138-
docs/
139137

140-
*.csv
138+
# Results files
139+
*/outputs/
141140
*.mp4
142-
*.log
143-
*.jpg

.pre-commit-config.yaml

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
default_language_version:
2-
python: python3.9
2+
python: python3.10
33

44
repos:
55
- repo: https://github.com/pycqa/isort
@@ -9,21 +9,21 @@ repos:
99
args: ["--profile", "black", "--filter-files"]
1010

1111
- repo: https://github.com/psf/black
12-
rev: 24.3.0
12+
rev: 24.10.0
1313
hooks:
1414
- id: black
1515
args: ["--config", ".code_quality/pyproject_black.toml"]
1616

1717
- repo: https://github.com/PyCQA/bandit
18-
rev: 1.7.8
18+
rev: 1.7.10
1919
hooks:
2020
- id: bandit
2121
args:
2222
- -c
2323
- .code_quality/bandit.yaml
2424

2525
- repo: https://github.com/pycqa/flake8
26-
rev: 7.0.0
26+
rev: 7.1.1
2727
hooks:
2828
- id: flake8
2929
args:
@@ -35,3 +35,11 @@ repos:
3535
hooks:
3636
- id: prettier
3737
types: [yaml]
38+
39+
- repo: https://github.com/PyCQA/docformatter
40+
rev: v1.7.5
41+
hooks:
42+
- id: docformatter
43+
additional_dependencies: [tomli]
44+
args: [--in-place, --config]
45+
exclude: ^(tests|notebooks|docs|models)/

MANIFEST.in

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
1-
include pavimentados/configs/images_processor.json
21
include pavimentados/configs/models_general.json
3-
include pavimentados/configs/processor.json
4-
include pavimentados/configs/siamese_config.json
5-
include pavimentados/configs/state_signal_config.json
6-
include pavimentados/configs/yolo_config.json
2+
include pavimentados/configs/workflows_general.json

MODELS.md

-59
This file was deleted.

README.md

+106-76
Original file line numberDiff line numberDiff line change
@@ -1,142 +1,172 @@
1-
[![Downloads](https://pepy.tech/badge/pavimentados)](https://pepy.tech/project/pavimentados)
2-
# Pavimentados
3-
4-
## Project Description
5-
---
1+
<div align="center">
2+
<h1>Pavimentados</h1>
63

7-
Pavimentados is a tool that allows the identification of pavement faults located on highways or roads, as well as vertical and horizontal signage. This library is an environment around the computer vision models developed to allow the detection of the different elements. The faults and detected elements are then used to generate metrics that help in road maintenance planning.
4+
[User Manual](docs/manual_202410.pdf)
85

9-
You can download models files from this [link](https://github.com/EL-BID/pavimentados/raw/e1cdb42d01f6ae323b7dc02d6e05d3c8b3b625a8/models/models.tar.gz?download=).
6+
![analytics image (flat)](https://raw.githubusercontent.com/vitr/google-analytics-beacon/master/static/badge-flat.gif)
7+
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=EL-BID_pavimentados&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=EL-BID_pavimentados)
8+
[![Downloads](https://pepy.tech/badge/pavimentados)](https://pepy.tech/project/pavimentados)
109

11-
These models require images or videos taken with the specifications that will be explained in later sections.
10+
![video_results.gif](docs/assets/video_results.gif)
11+
</div>
1212

13-
So far the system uses 4 models involved in different phases of detection and categorization.
13+
## Description
14+
---
15+
Pavimentados is a tool that allows the identification of pavement faults located on highways or roads.
16+
This library provides an environment to use computer vision models developed to detect different elements.
17+
The detected elements are then used to generate metrics that aid the process of planning road maintenance.
1418

15-
| Model Name | Description | Classes |
16-
|------------------------|---------------------------------------------------- | ------- |
17-
| Paviment failures | Detection of failures on the road and classifies it | 8 |
18-
| Signage detection | Detection of signage on the road | 2 |
19-
| Signage classification | Classifies the signage detected | 314 |
20-
| Signage State | Detect if the signage is in good or bad state | 3 |
19+
The model files can be downloaded from this [link](https://github.com/EL-BID/pavimentados/raw/feature/v1.0.0/models/model_20240818.tar.gz?download=).
2120

22-
To understand each model in detail see the [models](https://github.com/EL-BID/pavimentados/blob/main/MODELS.md) section.
21+
> **Important changes**: Unlike the previous version, this new version does not include traffic sign detection. We hope to be able to
22+
> include it again in future versions.
2323
2424
## Main Features
2525
---
2626

27-
Some of the features now available are as follows:
27+
Some of the features available are:
2828

29-
- Scoring using the models already developed
30-
- Workflows for image acquisition and assessment
29+
- Scoring using the models already developed.
30+
- Workflows for image acquisition and assessment.
3131
- Evaluation of gps information to determine the location of faults and elements.
32-
- Image or video support
33-
- Support for GPS data in different formats (GPRRA, csv, embedded in image)
34-
- Download models directly into the root of the package
32+
- Image or video support.
33+
- Support for GPS data in different formats (GPRRA, csv, embedded in image).
3534

3635
## Instalation
3736
---
3837

39-
To install you can use the following commands
38+
Install the library using the following command:
4039

4140
```
4241
pip install pavimentados
4342
```
4443

45-
Then to download the models use the following commands
44+
Next,
45+
* [download the model](https://github.com/EL-BID/pavimentados/raw/feature/v1.0.0/models/model_20240818.tar.gz?download=) from this link
4646

47+
* Decompress it using the following command
48+
```bash
49+
tar -xzvf model_20240818.tar.gz
4750
```
48-
from pavimentados import download_models
49-
50-
download_models(url = <signed_url>)
51-
```
52-
53-
Or alternativily
54-
55-
```
56-
from pavimentados import download_models
57-
58-
download_models(aws_access_key = <aws_access_key>, signature = <signature>, expires = <expiration_time>)
59-
```
60-
61-
62-
To obtain the corresponding credentials for downloading the models, please contact the Inter-American Development Bank at [email protected]
63-
64-
You can also clone the repository but remember that the package is configured to download the models and place them in the root of the environment.
6551

6652
## Quick Start
6753
---
6854

69-
To make use of the tool import the components that create a workflow with images
55+
In the `notebooks` folder there is a complete example of how to process both images and videos present
56+
in `notebooks/road_videos` and `notebooks/road_images`. The results are saved to `notebooks/outputs`.
7057

58+
The first step is to import the components that create a workflow with images:
7159
```
7260
from pavimentados.processing.processors import MultiImage_Processor
7361
from pavimentados.processing.workflows import Workflow_Processor
7462
```
7563

76-
In this example, we have the image processor object MultiImage_Processor, which is in charge of taking the images and analyzing them individually using the models. In addition, we have the Workflow_Processor object that is in charge of the image processing workflow.
64+
In this example, there is the image processor object MultiImage_Processor which is in charge of taking the images and analyzing them individually using the models. In addition, there is the Workflow_Processor object that is in charge of the image processing workflow.
7765

7866
Internally, the Workflow_Processor has objects that can interpret different image sources or GPS information.
7967

80-
Among the allowed image sources we have:
68+
Among the allowed image sources are:
8169

82-
- image_routes: A list of image routes
83-
- image_folder: a folder with all images
84-
- images: images already loaded in numpy format
85-
- video: The path to a video file
70+
- image_routes: A list of image routes.
71+
- image_folder: A folder with all images.
72+
- video: The path to a video file.
8673

87-
Among the allowed GPS data sources we have:
74+
Among the allowed GPS data sources are:
8875

89-
- image_routes: A list of the routes of the images that have the gps data embedded in them.
90-
- image_folder: A folder with all the images that have the gps data embedded in them.
91-
- loc: A file in GPRRA format
92-
- csv: A gps file with the gps information in columns and rows.
76+
- image_routes: A list of paths to the routes of the images that have the gps data embedded in them.
77+
- image_folder: A path to a folder with all the images that have the gps data embedded in them.
78+
- loc: A file in [NMEA format](docs%2Fgps_data_formats.md).
79+
80+
Once these elements are imported, the processor is instantiated as follows:
9381

94-
Once these elements are imported, the processor is instantiated as follows
82+
```python
83+
from pathlib import Path
84+
models_path = Path("./artifacts") # Path to downloaded model
85+
ml_processor = MultiImage_Processor(artifacts_path=str(models_path))
86+
```
9587

88+
Alternatively, an additional JSON file can be specified to set or overwrite certain configuration parameters of the models.
89+
90+
```python
91+
ml_processor = MultiImage_Processor(artifacts_path=str(models_path), config_file="./models_config.json")
9692
```
97-
ml_processor = MultiImage_Processor(assign_devices = True, gpu_enabled = True)
93+
These parameters allow the specification of parameter such as the confidence, iou, or maximum amount of detections per frame.
94+
95+
Example of the configuration file:
96+
```json
97+
{
98+
"paviment_model": {
99+
"yolo_threshold": 0.20,
100+
"yolo_iou": 0.45,
101+
"yolo_max_detections": 100
102+
}
103+
}
98104
```
99105

100-
The processor has the ability to allocate GPU usage automatically assuming that 6GB is available, it can be parameterized so that it is not automatically allocated, pass the allocation as a parameter, or even not work with the GPU.
101-
102-
You can modify the devices used according to the TensorFlow documentation regarding GPU usage (see https://www.tensorflow.org/guide/gpu)
106+
The workflow object receives the instantiated processor. Without it is not able to execute the workflow.
103107

104-
The workflow object is able to receive the instantiated processor, without it it is not able to execute the workflow.
108+
```python
109+
input_video_file = "sample.mp4"
110+
input_gps_file = "sample.log"
105111

106-
```
107-
workflow = Workflow_Processor(route, image_source_type='image_folder', gps_source_type = 'image_folder')
112+
# Create a workflow for videos
113+
workflow = Workflow_Processor(
114+
input_video_file, image_source_type="video", gps_source_type="loc", gps_input=input_gps_file, adjust_gps=True
115+
)
108116
```
109117

110-
The complete execution code would be as follows:
118+
The last step is to execute the workflow:
111119

120+
```python
121+
results = workflow.execute(ml_processor,
122+
batch_size=16,
123+
video_output_file="processed_video.mp4"
124+
)
112125
```
113-
from pavimentados.processing.processors import MultiImage_Processor
114-
from pavimentados.processing.workflows import Workflow_Processor
115-
from pathlib import Path
116126

117-
### Image with the GPS data embebed
118-
route = Path(<route with the images for processing>)
127+
> * `video_output_file` and `image_folder_output` are optional and are only to save output video or image files along detections.
119128
120-
ml_processor = MultiImage_Processor(assign_devices = True, gpu_enabled = True)
129+
The results can be saved in csv format or used for further processing.
121130

122-
workflow = Workflow_Processor(route, image_source_type='image_folder', gps_source_type = 'image_folder')
123-
124-
results = workflow.execute(ml_processor)
131+
```python
132+
# Save results to outputs directory
133+
import pandas as pd
134+
for result_name in results.keys():
135+
pd.DataFrame(results[result_name]).to_csv(f"{result_name}.csv")
125136
```
126137

127-
In results you will find the following:
138+
In the `results` object you will find the following:
128139

129140
1. table_summary_sections: DataFrame with summary table by sections.
130-
2. data_resulting: DataFrame with results per frame
141+
2. data_resulting: DataFrame with results per frame.
131142
3. data_resulting_fails: DataFrame with results by unique faults encountered.
132-
4. signals_summary: DataFrame with all the information about the signals.
133-
5. raw_results: Raw results totals
134143

135-
## Autores
144+
To see more details about the results please refer to [this page](docs%2Fresults.md).
145+
146+
147+
## Project structure
148+
---
149+
* `docs`: Documentation files.
150+
* `models`: Reference path where the downloaded model artifact should be placed.
151+
* `notebooks`: Examples of how to process images and videos.
152+
* `pavimentados/analyzers`: Modules for image/video processing and generation of the final output.
153+
* `pavimentados/configs`: General configuration and parameters of the models.
154+
* `pavimentados/models`: Modules for YoloV8 and Siamese models.
155+
* `pavimentados/processing`: Workflows for processing.
156+
157+
158+
## Changelog
159+
---
160+
For information regarding the latest changes/updates in the library please refer to the [changes document](docs/CHANGELOG.md).
161+
162+
163+
## Authors
136164
---
137165

138166
This package has been developed by:
139167

140168
<a href="https://github.com/J0s3M4rqu3z" target="blank">Jose Maria Marquez Blanco</a>
141169
<br/>
142170
<a href="https://www.linkedin.com/in/joancerretani/" target="blank">Joan Alberto Cerretani</a>
171+
<br/>
172+
<a href="https://www.linkedin.com/in/ingvictordurand/" target="blank">Victor Durand</a>

0 commit comments

Comments
 (0)