- Python 3.11.6
Follow these steps to set up and use the DMimageDetection project:
- Clone the repository:
git clone https://github.com/GetHypercube/aidetector-backend.git
- Create a Python virtual environment:
python -m venv .venv
- Activate the Python environment:
- For Windows:
.venv\Scripts\activate
- For OSX:
source .venv/bin/activate
- Upgrade pip:
python -m pip install --upgrade pip
- Install the necessary requirements:
pip install -r requirements.txt
- If you have a GPU, make sure Pytorch is compiled with GPU support. Here is the example installation command for Windows:
pip install torch --index-url https://download.pytorch.org/whl/cu124
Please go to the following link to find the detailed instructions.
-
Download the weights from this link and place them under
/weights
directory in your project folder. -
You need to create a
.env
file with the following variables:
AWS_ACCESS_KEY=XXX
AWS_SECRET_KEY=XXX
OPENAI_API_KEY=XXX
MONGODB_URL=XXX
DEV_ENV=true
- If you are going to use the API, please make sure to have the AWS CLI installed and properly configured.
To run the detector on an image:
python main.py --image_path test.jpg
To run the detector on a folder:
python main.py --image_folder test.jpg
To run the detector on a folder and a specific models:
python main.py --image_folder image.jpg --model dMDetectorResults
If you want to use the API, first run the server:
python api.py
To create the CSV file neccesary to calculate evaluations of the models:
python main.py --image_folder tests --true_label True
And to calculate evaluations, open evaluations.ipynb
notebook.
In Windows, run the CURL command:
curl -X POST -F "file=@real_biggan.png" http://localhost:80/detect
Please see main.py
for additional options
To build and run the container for development (CPU):
docker build -t aidetector-backend .
docker run --rm -p 8080:8080 aidetector-backend
To build and run the container for development (GPU):
docker build -t aidetector-backend-gpu -f Dockerfile.gpu .
docker run --rm --gpus all -p 8080:8080 aidetector-backend-gpu