Skip to content

Commit

Permalink
Refactor engine v2 (#206)
Browse files Browse the repository at this point in the history
* add try catch

* update test

* update default speed

* add delete method

* stop saving random

* fix local backup

* stop processing alert inside predict

* style

* update core

* update engine

* adpat run

* update readme

* add cam control script

* flake8

* style

* mypy

* python version

* fix dockerfile

* fix import

* missing header

* fix engine

* missing loop

* missing import

* try fixing flake8 mypy conflict

* drop usless fonction

* move day_time test

* update test

* fix test engine

* style

* fix engine test

* ignore verify false

* ignore verify false

* test only if queue not empty

* fix name & check not None

* flake8

* reduce complexity

* wrong argument
  • Loading branch information
MateoLostanlen authored Jun 17, 2024
1 parent 97ec80c commit 16fa010
Show file tree
Hide file tree
Showing 12 changed files with 887 additions and 276 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ RUN pip install -e /tmp/. \
&& rm -rf /root/.cache/pip

COPY ./src/run.py /usr/src/app/run.py
COPY ./src/capture.py /usr/src/app/capture.py
COPY ./src/control_reolink_cam.py /usr/src/app/control_reolink_cam.py
95 changes: 57 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
![PyroNear Logo](docs/source/_static/img/pyronear-logo-dark.png)

<p align="center">
<a href="https://github.com/pyronear/pyro-engine/actions?query=workflow%3Abuilds">
<img alt="CI Status" src="https://img.shields.io/github/workflow/status/pyronear/pyro-engine/builds?label=CI&logo=github&style=flat-square">
<a href="https://github.com/pyronear/pyro-engine/actions?query=workflow%3Atests">
<img alt="CI Status" src="https://img.shields.io/github/actions/workflow/status/pyronear/pyro-engine/tests.yml?branch=develop&label=CI&logo=github&style=flat-square">
</a>
<a href="https://pyronear.org/pyro-engine">
<img src="https://img.shields.io/github/workflow/status/pyronear/pyro-engine/docs?label=docs&logo=read-the-docs&style=flat-square" alt="Documentation Status">
<a href="https://github.com/pyronear/pyro-engine/actions?query=workflow%3Adocs">
<img src="https://img.shields.io/github/actions/workflow/status/pyronear/pyro-engine/docs.yml?branch=main&label=docs&logo=read-the-docs&style=flat-square" alt="Documentation Status">
</a>
<a href="https://codecov.io/gh/pyronear/pyro-engine">
<img src="https://img.shields.io/codecov/c/github/pyronear/pyro-engine.svg?logo=codecov&style=flat-square" alt="Test coverage percentage">
Expand All @@ -22,14 +22,13 @@
<a href="https://anaconda.org/pyronear/pyroengine">
<img src="https://img.shields.io/conda/vn/pyronear/pyroengine?label=Anaconda&logo=Anaconda&logoColor=white" alt="Anaconda Version">
</a>
<a href="https://hub.docker.com/repository/docker/pyronear/pyro-engine">
<img alt="DockerHub version" src="https://img.shields.io/docker/v/pyronear/pyro-engine?arch=arm64&label=Docker&logo=Docker&logoColor=white">
<a href="https://hub.docker.com/r/pyronear/pyro-engine">
<img alt="DockerHub version" src="https://img.shields.io/docker/v/pyronear/pyro-engine/latest?label=Docker&logo=Docker&logoColor=white">
</a>
<img src="https://img.shields.io/pypi/pyversions/pyroengine.svg?style=flat-square" alt="pyversions">
<img src="https://img.shields.io/pypi/l/pyroengine.svg?style=flat-square" alt="license">
</p>


# PyroEngine: Wildfire detection on edge devices

PyroEngine provides a high-level interface to use Deep learning models in production while being connected to the alert API.
Expand All @@ -48,24 +47,16 @@ engine = Engine()

im = Image.open("path/to/your/image.jpg").convert('RGB')

prediction = engine.predict(image)
prediction = engine.predict(im)
```

## Setup

Python 3.6 (or higher) and [pip](https://pip.pypa.io/en/stable/)/[conda](https://docs.conda.io/en/latest/miniconda.html) are required to install PyroVision.

### Stable release

You can install the last stable release of the package using [pypi](https://pypi.org/project/pyroengine/) as follows:

```shell
pip install pyroengine
```
Python 3.8 (or higher) and [pip](https://pip.pypa.io/en/stable/)/[conda](https://docs.conda.io/en/latest/miniconda.html) are required to install PyroEngine.

### Developer installation

Alternatively, if you wish to use the latest features of the project that haven't made their way to a release yet, you can install the package from source:
If you wish to use the latest features of the project that haven't made their way to a release yet, you can install the package from source:

```shell
git clone https://github.com/pyronear/pyro-engine.git
Expand All @@ -74,35 +65,66 @@ pip install -e pyro-engine/.

### Full docker orchestration

In order to run the projet, you will need to specific some information, which can be done using a .env file.
In order to run the project, you will need to specify some information, which can be done using a `.env` file.
This file will have to hold the following information:
- `API_URL`: the URL of the api where to send alerts
- `API_URL`: the URL of the API where to send alerts
- `LAT`: the latitude of the device
- `LON`: the longitude of the device
- `CAM_USER`: the user name to access camera
- `CAM_PWD`: the password name to access camera
- `LOKI_URL`: the loki URL where to export logs
- `PROMTAIL_DEVICE_SCOPE`: the scope of the device (in order to filter devices logs with ease)
- `PROMTAIL_DEVICE_NAME`: the name of the device (in order to filter devices logs with ease)
- `LON`: the longitude of the device
- `CAM_USER`: the username to access the camera
- `CAM_PWD`: the password to access the camera

So your `.env` file should look like something similar to:
So your `.env` file should look something like this:

```
API_URL=http://my-api.myhost.com
API_URL=https://api.pyronear.org
LAT=48.88
LON=2.38
CAM_USER=my_dummy_login
CAM_PWD=my_dummy_pwd
LOKI_URL=http://my-loki-service.com
PROMTAIL_DEVICE_SCOPE=tower_scope
PROMTAIL_DEVICE_NAME=tower_name
```

Additionally, you'll need a `./data` folder which contains:
- `credentials.json`: a dictionary with the IP address of your cameras as key, and dictionary with entries `login` & `password` for their Alert API credentials
- `model.onnx`: optional, will overrides the model weights download from HuggingFace Hub
- `config.json`: optional, will overrides the model config download from HuggingFace Hub
- `model.onnx`: optional, will override the model weights download from HuggingFace Hub
- `config.json`: optional, will override the model config download from HuggingFace Hub

### Example of `credentials.json`:

```json
{
"169.254.40.1": {
"brand": "reolink",
"type": "ptz",
"credentials": [
{
"login": "dummy_login_1",
"password": "dummy_password_1",
"posid": 1
},
{
"login": "dummy_login_2",
"password": "dummy_password_2",
"posid": 2
},
{
"login": "dummy_login_3",
"password": "dummy_password_3",
"posid": 3
}
]
},
"169.254.40.3": {
"brand": "reolink",
"type": "static",
"credentials": [
{
"login": "dummy_login_4",
"password": "dummy_password_4"
}
]
}
}
```

## Documentation

Expand All @@ -112,14 +134,11 @@ The full package documentation is available [here](https://pyronear.org/pyro-eng

Please refer to [`CONTRIBUTING`](CONTRIBUTING.md) if you wish to contribute to this project.



## Credits

This project is developed and maintained by the repo owner and volunteers from [Pyronear](https://pyronear.org/).



## License

Distributed under the Apache 2 License. See [`LICENSE`](LICENSE) for more information.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ classifiers = [
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Mathematics",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
Expand Down
Loading

0 comments on commit 16fa010

Please sign in to comment.