Backend server for Digital Police Application
NOTE How to Run steps assume that you are using python 3 and linux based OS
- Clone this repository.
- Create a new python virtual environment
python3 -m venv env
. - Enter that virtual environment
source env/bin/activate
. - Run this code to install all dependency
pip install -r requirements.txt
. - Make sure to create
.env
file. There's an example in the.env.example
. - Download the classifying weights link in the link provided below, and put it at the project root folder (same level with
manage.py
,requirements.txt
,Dockerfile
, etc). Make sure you name itclassify_weights_tf.h5
- Download the credentials and put it at the project root folder and name it
credentials.json
. You can follow this link to get the json file. - Run a database migration with
python manage.py migrate
- Run
python manage.py runserver
, and the webserver will run on port 8000 on your localhost. - All endpoint will be in backend documentation
- To test a video, open
http://localhost:8000
and choose video that you want to categorize, then click upload new video. If true returned, then the video contains crime activity, and will be uploaded to firebase storage, if false, then the video doesn't contain crime activity.
- Clone this repository.
- Create
.env
file. There's an example in the.env.example
. Set thePRODUCTION
variable toTRUE
- Download the classifying weights link in the link provided below, and put it at the project root folder (same level with
manage.py
,requirements.txt
,Dockerfile
, etc). Make sure you name itclassify_weights_tf.h5
- Download the credentials and put it at the project root folder and name it
credentials.json
. You can follow this link to get the json file. - run
docker-compose up -d
. - Run a database migration by entering bash with
docker exec -it {your_container_id} /bin/bash
and runpython manage.py migrate
. You shouldn't do this again if you already did this before.
NOTE
- To access built in django admin page, first you should create a superuser. Run
python manage.py createsuperuser
and write the desired username and password, email is optional. Note that if you are using docker, access the container bash withdocker exec -it {your_container_id} /bin/bash
.
Admin page purpose is to manage all entity on the database. To know all the table in the database, follow the database design documentation.
- Access
http://localhost:8000/admin/
to go to the admin page. - Login with superuse credential.
- To get a notification about crime happening, user must add FCM Devices. The required fields are
Name (unique)
,Registration Token
, andType
. To get device registration token, follow this guide. - Click Save to save the FCM Device. To test this, open
http://localhost:8000
and choose video that you want to categorize, then click upload new video. If true returned, then the notification will be send to your device.
- CCTV Object would be automatically created if you predict the video via
http://localhost:8000
. The name would be dummy, with latitude and longitude zero, with a city named dummy. - Predicting for the first time can take a long time because it needs to download the C3D weights and mean.