**README**
==========
# Run the server-side FastAPI app
## In development mode
Using the template files, you first need to create backend/.env and backend/cameras.py.
You can start a virtual environment with the following instructions.

```sh
$ cd backend
$ python3.9 -m venv env
$ source env/bin/activate
```

Then you need to install the dependencies by executing `pip install -r requirements.txt`  
Comment the app service in the docker-compose.yml then build and run the file.  
Start the development server running `python -m uvicorn main:app --reload --port=3001 --host 0.0.0.0`

Navigate to [http://localhost:3001](http://localhost:3001)

<br/>

### *Le linter*
So the new commits can be deployed, you'll need to use the linter from backend :  
`pycodestyle --config=./setup.cnf --exclude=./env ./`  
You can use autoformat with autopep8 running :  
`autopep8 --in-place --global-config=./setup.cnf --recursive --exclude=./env --aggressive ./`

<br/>  

## In production mode
Build the docker image : `docker-compose build`  
Run the server, `docker-compose up -d`

<br/>  

# Run the client-side React app in a different terminal window:

Using the template file, you first need to create frontend/.env.

```sh
$ cd frontend
$ npm install
$ npm run start
```

Navigate to [http://localhost:3000](http://localhost:3000)

<br/>  

# Documentation

## Algorithm

The crowd-counting AI model used is based on this repository:
https://github.com/ZhengPeng7/W-Net-Keras
The dataset used is ShanghaiTech Part B.
The model is given a 3-channel image and generates a density map of half the size of the input image.
The estimated number of people is obtained by summing on all pixels of the density map.

<br/>

# TODO
## Coté algo
- Accéder à d'autre infos telle que l'API des cours sur demande à la DISI pour intégrer ça aux prédictions (ex: cours en promo complète juste implique plus d'attente)

## Coté dev
- Protéger l'interface OpenAPI et mettre en place une interface admin pour les news et potentiellement modération (avec authentification)
- Permettre de définir les masques proprement et de manière à pouvoir généraliser à d'autre RU
- Accorder la charte graphique si le service est intégré à d'autres appli (bordeau/blanc service de CS, charte graphique de VR)
- Réfléchir au système d'authentification, pour juste des commentaires l'authentification ViaRézo suffit mais CAS plus général dans les universités ou Shibboleth avec Renater

## Coté camera et réseau
- Recherche d'un meilleur modèle de caméra par rapport aux contraintes réseau, d'angle de vue, de qualité d'image
- Démarches pour mettre en place les caméras et config réseau

## Coté com et récolte des données
- Préparer la com pour la mise en place : mail NL, affiches, panneaux numérique DPIET
- Exploitation des données après récupération : visualisation et stratégie d'adaptation du modèle
- Réfléchir à un nom pour le service
- Motiver des gens à reprendre le projet

## Documentation
- Documenter le projet au maximum
- Réfléchir à opensourcer (ça peut permettre d'étendre plus facilement à d'autre RU)

## Déploiement
- Monitorer la VM de prod avec Datadog
- Écrire un rôle Ansible de déploiement en prod
- Monitorer la VM de staging avec Datadog
- Écrire un rôle Ansible de déploiement en staging