diff --git a/.gitignore b/.gitignore index 68bc17f..c33de5c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# Manually added +migrations + # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] diff --git a/README.md b/README.md index f42c75f..9b47df3 100644 --- a/README.md +++ b/README.md @@ -1 +1,76 @@ -# ProjectIOT \ No newline at end of file + +# Installation Guide + +## Setting Up Your Virtual Environment + +### 1. Create a Virtual Environment +To begin, create a virtual environment using the following command IN A NEW TERMINAL: +```bash +python -m venv .venv +``` + +### 2. Activate the Virtual Environment +For Windows, activate the virtual environment with IN A NEW TERMINAL: +```bash +.\.venv\Scripts\activate.bat +``` + +### 3. Install Required Packages +Once the environment is activated, install the necessary packages by running: +```bash +pip install -r requirements.txt +``` + +### 4. Update outdated Packaged +To avoid errors the ultralytics packages needs to be manually updated: +```bash +pip install -U ultralytics +--- + +## Setting Up the Database + +### 1. Initialize the Database +To initialize the database, run the following command: +```bash +flask --app app.py db init +``` + +### 2. Migrate the Database +Migrate the database schema to the latest version with: +```bash +flask --app app.py db migrate +``` + +### 3. Upgrade the Database +Apply the migration to update the database with: +```bash +flask --app app.py db upgrade +``` + +--- + +## Seeding the Database +To populate the database with a few sample users and services, run: +```bash +python seed.py +``` + +--- + +## Starting the Application +To start the application, run: +```bash +python app.py +``` + +--- + +# Development Commands + +### Updating `requirements.txt` +To update the `requirements.txt` with the currently installed packages, use the following command: +```bash +pip freeze > requirements.txt +``` + +--- diff --git a/server.py b/app.py similarity index 59% rename from server.py rename to app.py index 775912f..2017d01 100644 --- a/server.py +++ b/app.py @@ -1,13 +1,6 @@ -from ultralytics.nn.tasks import DetectionModel # type: ignore -import torch from application import app from application.api.views import api_blueprint - -torch.serialization.add_safe_globals( # type: ignore - {"DetectionModel": DetectionModel} # type: ignore -) - app.register_blueprint(api_blueprint) diff --git a/requirements.txt b/requirements.txt index ddbdc71..de23462 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,18 +5,17 @@ certifi==2025.1.31 charset-normalizer==3.4.1 click==8.1.8 colorama==0.4.6 -contourpy==1.3.1 +contourpy==1.3.2 cv2filters==0.2.6 cycler==0.12.1 defusedxml==0.7.1 filelock==3.18.0 Flask==3.1.0 -Flask-Login==0.6.3 Flask-Migrate==4.1.0 Flask-SQLAlchemy==3.1.1 fonttools==4.57.0 fsspec==2025.3.2 -greenlet==3.1.1 +greenlet==3.2.1 h5py==3.13.0 huggingface-hub==0.30.2 idna==3.10 @@ -32,9 +31,9 @@ mpmath==1.3.0 networkx==3.4.2 numpy==1.26.4 opencv-python==4.11.0.86 -packaging==24.2 +packaging==25.0 pandas==2.2.3 -pillow==11.1.0 +pillow==11.2.1 psutil==7.0.0 py-cpuinfo==9.0.0 pyclipper==1.3.0.post6 @@ -49,18 +48,19 @@ RapidFuzz==3.13.0 requests==2.32.3 scipy==1.15.2 seaborn==0.13.2 -setuptools==78.1.0 +setuptools==79.0.1 shapely==2.1.0 six==1.17.0 +sql-migrate==0.1.0 SQLAlchemy==2.0.40 -sympy==1.13.1 -torch==2.6.0 -torchvision==0.21.0 +sympy==1.13.3 +torch==2.7.0 +torchvision==0.22.0 tqdm==4.67.1 typing_extensions==4.13.2 tzdata==2025.2 -ultralytics==8.3.106 +ultralytics==8.2.55 ultralytics-thop==2.0.14 -urllib3==2.3.0 +urllib3==2.4.0 Werkzeug==3.1.3 win32_setctime==1.2.0 diff --git a/seed.py b/seed.py index effaa52..7a25f1d 100644 --- a/seed.py +++ b/seed.py @@ -2,5 +2,6 @@ from application import db, app from application.models import AllowedPlate with app.app_context(): + AllowedPlate.query.delete() db.session.add(AllowedPlate("MUN389")) db.session.commit()