This project provides a REST API for image segmentation using a pre-trained neural network model. The API takes in an image and returns segmented images based on the model's predictions.
- Java 8 or later
- Spring Boot
- PyTorch (for the model inference)
- Gradle (for building the project)
- Docker (optional, for containerizing the application)
-
Clone this repository:
git clone https://github.com/yourusername/image-segmentation-classifier.git
-
Download Pytorch lib and export
https://pytorch.org/get-started/locally/)https://pytorch.org/get-started/locally/
- Open the project in your preferred IDE.
- Run the Spring Boot application with in terminal
./mvnw spring-boot:run -Dspring-boot.run.jvmArguments="-Djava.library.path=/export/pytorch/path/libtorch/lib"
Use an API client (e.g., cURL, Postman) to send POST requests to the API endpoint for image segmentation.
Endpoint: POST /api/classifier/predict
{
"modelName": "modelmobile256_256.ptl",
"image": "base64_encoded_image_data_here"
}
-
modelName: The name of the pre-trained model.
-
image: Base64-encoded image data.
The response will be a JSON object containing segmented images in base64-encoded format.
- Contributions are welcome! If you find a bug or want to add a new feature, feel free to open an issue or submit a pull request.
- Fork the repository.
- Create a new branch for your feature/bugfix: git checkout -b feature-name
- Commit your changes: git commit -am 'Add new feature'
- Push to the branch: git push origin feature-name
- Open a pull request.
- Please follow the existing code style and provide clear commit messages.