- Table of Contents
- About the Project
- Description
- Built With
- Getting Started
- Prerequisites
- Installation
- Usage
- Example
- Architecture
- Roadmap
- Contributing
- Acknowledgements
Library that calls python api from java. The library uses image enhancement (super resolution) on small thumbnails, and performs a simple sharpen filter.
git clone https://github.com/europeana/metis-image-enhancer.git
go to the cloned folder of the library /metis-image-enhancer/metis-image-enhancer-python-rest/src/main, and run the following command to build the image enhancer application
docker compose build --no-cache
go to the cloned folder of the library /metis-image-enhancer/metis-image-enhancer-python-rest/src/main, and run the following commands to get the service up and running this command will run with 1 node
docker compose up
the application uses a python api to enhance the image
curl --request POST http://localhost:8080/enhance/image --form image=@./metis-image-enhancer-client/src/test/resources/img/thumbnail.jpg \
--output ./metis-image-enhancer-client/src/test/resources/img/thumbnail_enhanced.jpg
Response:
HTTP code: 200
Content-Type: image/jpeg
Response Body: Enhanced image to download
Note: Java and Maven are prerequisites, the client adds sharpen filter extra to the python api result to improve the end result.
mvn clean install
add dependency in your project
<dependency>
<groupId>eu.europeana.metis.image.enhancement</groupId>
<artifactId>metis-image-enhancer-client</artifactId>
<version>1</version>
</dependency>
By default, the following properties are set in the library if you want to change the address or port,
and the timeout are in seconds. the property worker.service.type
can have the values api
or script
this indicates which approach will use to process the images.
api.url = http://localhost:8080
connect.timeout = 300
read.timeout = 300
worker.service.type = api
If you only want to use the image processing without the API, you can invoke this from the command line, using the script directly. Your python environment need to comply with the following dependencies (filetype, flask, waitress, uuid, pillow, tensorflow, and numpy)
python ./metis-image-enhancer-python-rest/src/main/mie.py --input image_input.jpg --output image_output.jpg
Why this AI python model runs as a script? in this iteration the python model cannot be held in memory otherwise you will get an Out of Memory. The model in python of image processing doesn't free the resources every time. Steps of usage: load, process, get results, discard, repeat again.
run docker image previous to execute the demo app and then execute the following command in the cloned folder of the /metis-image-enhancer/metis-image-enhancer-demo
mvn clean package
execute the app e.g.
java -jar ./target/metis-image-enhancer-demo-1-SNAPSHOT.jar
example of demo code can be found in the metis-image-enhancer-demo module.
The following image shows the outcome:
The motivation behind the design summarizes in the following concept: "Communication goes from outer layers to the inner layers."
- The client layer contains interactions details between the configuration and the domain.
- The configuration layer provides the properties needed to connect with the isr app.
- The domain layer uses the adapter pattern implementation to plug in any client adapter implementation to do the image enhancement. It contains the model and worker core business logic, so this remains untouched by external changes of the outer layers as much as possible.
- library initial release.
- restructure to metis style projects.
- use stream of bytes instead of file.
- ...
Any contributions you make are appreciated.
- Fork the Project
- Create your Feature Branch (git checkout -b feature/AmazingFeature)
- Commit your Changes (git commit -m 'Add some AmazingFeature')
- Push to the Branch (git push origin feature/AmazingFeature)
- Open a Pull Request
This project is powered by Image Super Resolution v2.2.0