FertiScan helps inspectors analyze and process fertilizer labels by extracting text and generating structured forms.
This repository contains the backend for FertiScan, a Flask-based server designed to work with the frontend. It handles image uploads, document analysis using OCR, and form generation using an LLM.
Clone the repository:
git clone https://github.com/ai-cfia/fertiscan-backend.git
cd fertiscan-backend
Install dependencies:
pip install -r requirements.txt
Start the server:
python ./app.py
Build the Docker image:
docker build -t fertiscan-backend \
--build-arg ARG_AZURE_API_ENDPOINT=your_azure_form_recognizer_endpoint \
--build-arg ARG_AZURE_API_KEY=your_azure_form_recognizer_key \
--build-arg ARG_AZURE_OPENAI_API_ENDPOINT=your_azure_openai_endpoint \
--build-arg ARG_AZURE_OPENAI_API_KEY=your_azure_openai_key \
--build-arg ARG_PROMPT_PATH=path/to/prompt_file \
--build-arg ARG_UPLOAD_PATH=path/to/upload_file \
--build-arg ARG_FRONTEND_URL=http://url.to_frontend/ \
.
Run the Docker container:
docker run -p 5000:5000 fertiscan-backend
Create a .env
file from .env.template.
AZURE_API_ENDPOINT=your_azure_form_recognizer_endpoint
AZURE_API_KEY=your_azure_form_recognizer_key
AZURE_OPENAI_API_ENDPOINT=your_azure_openai_endpoint
AZURE_OPENAI_API_KEY=your_azure_openai_key
AZURE_OPENAI_DEPLOYMENT=your_azure_openai_deployment
PROMPT_PATH=path/to/file
UPLOAD_PATH=path/to/file
FRONTEND_URL=http://url.to_frontend/
POST /analyze
: Upload images for analysis and get the results as a JSON form.