This project is a Flask-based web application for image classification using an ONNX model. Given an input image, the application predicts whether the image is classified as "Malignant" or "Benign".
To run this application locally, ensure the following are installed on your machine:
- Python 3.10
- pip
Follow these steps to set up the project locally:
-
Clone the Repository
Clone the repository to your machine:
git clone https://github.com/SoaresPT/Skin_Scanner_App-backend.git cd Skin_Scanner_App-backend -
Create a Virtual Environment
Set up a virtual environment to manage dependencies:
python -m venv venv
-
Activate the Virtual Environment
-
On Windows:
.\venv\Scripts\activate
-
On macOS and Linux:
source venv/bin/activate
-
-
Install Required Packages
With the virtual environment activated, install the necessary Python packages:
pip install -r requirements.txt
-
ONNX Model
ONNX models should be placed inside
model. Currently defaults to:./model/model_2.onnx.
To start the Flask application:
python server.pyThe server will be accessible at http://0.0.0.0:8000. ( or http://localhost:8000)
The live server is accessible at: https://skinscanner.420777.xyz/predict. This will be used to send requests directly to this endpoint for predictions when using the Skin Scanner App.
To perform an inference, send a POST request to the /predict endpoint with an image file:
- Endpoint:
/predict - Method:
POST - Form Data: Image file with the key as
image.
You can use Python's requests module to interact with the API. Run the test_api.py.
Change the url to 'https://skinscanner.420777.xyz/predict' for the live server.
curl -X POST -F "image=@path/to/your/image.jpg" https://skinscanner.420777.xyz/predict # or http://0.0.0.0:8000/predict for localThe application returns error messages for the following scenarios:
- No image file provided: 400 status code with an error message.
- No file uploaded: 400 status code with an error message.
- Unexpected errors: 500 status code with a detailed error message.
The repository includes a Dockerfile for containerization. You can build and run the application using Docker. However, this setup may need adjustments to suit your environment and can be ignored for initial testing. Refer to Docker documentation for building and running containers.