diff --git a/README.MD b/README.MD
index 13576e3..259fd15 100644
--- a/README.MD
+++ b/README.MD
@@ -90,8 +90,7 @@ add dependency in your project
eu.europeana.metis.image.enhancement
metis-image-enhancer-client
- 0.0.1-SNAPSHOT
- compile
+ 1
````
### properties
@@ -102,6 +101,20 @@ api.url = http://localhost:5050
connect.timeout = 300
read.timeout = 300
```
+#### command line stand alone script
+If you only want to use the image processing without the API, you can invoke this
+from the command line, using the script directly.
+
+```
+python ./metis-image-enhancer-python-rest/src/main/mie.py -i image_input.jpg -o image_output.jpg
+```
+
+
+## General limitations
+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.
#### See demo project
run docker image previous to execute the demo app and then execute the following command in the cloned folder of
diff --git a/metis-image-enhancer-client/src/main/java/eu/europeana/metis/image/enhancement/domain/worker/ImageEnhancerWorker.java b/metis-image-enhancer-client/src/main/java/eu/europeana/metis/image/enhancement/domain/worker/ImageEnhancerWorker.java
index 836829f..a708036 100644
--- a/metis-image-enhancer-client/src/main/java/eu/europeana/metis/image/enhancement/domain/worker/ImageEnhancerWorker.java
+++ b/metis-image-enhancer-client/src/main/java/eu/europeana/metis/image/enhancement/domain/worker/ImageEnhancerWorker.java
@@ -22,6 +22,7 @@
*/
public class ImageEnhancerWorker {
private static final Logger LOGGER = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ private static final boolean IS_FILTER_ENABLED = false;
private final ImageEnhancer imageEnhancer;
/**
@@ -70,7 +71,9 @@ public byte[] enhance(byte[] input) {
final String format = getImageFormat(input);
-// ImageIO.write(sharpen(image), format, baos);
+ if (IS_FILTER_ENABLED) {
+ ImageIO.write(sharpen(image), format, baos);
+ }
ImageIO.write(image, format, baos);
} catch (IOException e) {
LOGGER.error("enhancing the image", e);
diff --git a/metis-image-enhancer-client/src/main/resources/application.properties b/metis-image-enhancer-client/src/main/resources/application.properties
deleted file mode 100644
index ea99a42..0000000
--- a/metis-image-enhancer-client/src/main/resources/application.properties
+++ /dev/null
@@ -1,5 +0,0 @@
-isr.api.url = http://localhost:5050
-isr.connect.timeout = 300
-isr.read.timeout = 300
-isr.script = ../metis-image-enhancer-python-script/src/main/mie.py
-
diff --git a/metis-image-enhancer-demo/.gitignore b/metis-image-enhancer-demo/.gitignore
index 75cba8d..29eee14 100644
--- a/metis-image-enhancer-demo/.gitignore
+++ b/metis-image-enhancer-demo/.gitignore
@@ -1,3 +1,4 @@
+/src/main/resources/application.properties
README.MD
target/
!.mvn/wrapper/maven-wrapper.jar
diff --git a/metis-image-enhancer-demo/src/main/resources/application.properties b/metis-image-enhancer-demo/src/main/resources/application.properties
index 306b393..ea72b57 100644
--- a/metis-image-enhancer-demo/src/main/resources/application.properties
+++ b/metis-image-enhancer-demo/src/main/resources/application.properties
@@ -2,5 +2,5 @@
isr.api.url = http://localhost:8080
isr.connect.timeout = 300
isr.read.timeout = 300
-isr.script = ../metis-image-enhancer-python-script/src/main/mie.py
+isr.script = ../metis-image-enhancer-python-rest/src/main/mie.py
worker.service.type = api
diff --git a/metis-image-enhancer-demo/src/main/resources/application.properties.example b/metis-image-enhancer-demo/src/main/resources/application.properties.example
index b7f6eef..0f8a84a 100644
--- a/metis-image-enhancer-demo/src/main/resources/application.properties.example
+++ b/metis-image-enhancer-demo/src/main/resources/application.properties.example
@@ -2,5 +2,5 @@
isr.api.url = http://localhost:8080
isr.connect.timeout = 300
isr.read.timeout = 300
-isr.script = ../metis-image-enhancer-python-script/src/main/mie.py
+isr.script = ../metis-image-enhancer-python-rest/src/main/mie.py
worker.service.type = script
diff --git a/metis-image-enhancer-python-rest/Dockerfile b/metis-image-enhancer-python-rest/Dockerfile
index 6f1391d..2b31927 100644
--- a/metis-image-enhancer-python-rest/Dockerfile
+++ b/metis-image-enhancer-python-rest/Dockerfile
@@ -1,21 +1,26 @@
-FROM ubuntu:22.04
+FROM ubuntu:24.10
RUN apt-get update && apt-get upgrade -y
RUN apt-get install git -y
-RUN apt-get install python3-pip -y
+RUN apt install python3 python3-pip python3-venv python3-setuptools python3-pil python3-filetype python3-flask python3-waitress -y
+RUN mkdir flask-app && cd flask-app
+RUN python3 -m venv flask-venv
+RUN . flask-venv/bin/activate
-RUN pip3 install --upgrade pip
-RUN pip3 install filetype
-RUN pip3 install Flask
-RUN pip3 install waitress
-RUN pip3 install uuid
-RUN pip3 install tensorflow==2.13.0
+RUN flask-venv/bin/pip3 install --upgrade pip
+RUN flask-venv/bin/pip3 install filetype
+RUN flask-venv/bin/pip3 install Flask
+RUN flask-venv/bin/pip3 install waitress
+RUN flask-venv/bin/pip3 install uuid
+RUN flask-venv/bin/pip3 install pillow
+RUN flask-venv/bin/pip3 install tensorflow==2.17.0 numpy==1.26.0
RUN git clone https://github.com/idealo/image-super-resolution.git \
&& cd image-super-resolution \
&& git checkout v2.2.0 \
- && sed -i 's/tensorflow==2.0.0/tensorflow==2.13.0/' setup.py \
- && sed -i 's/tensorflow-gpu==2.0.0/tensorflow-gpu==2.13.0/' setup.py \
+ && sed -i 's/numpy/numpy==1.26.0/' setup.py \
+ && sed -i 's/tensorflow==2.0.0/tensorflow==2.17.0/' setup.py \
+ && sed -i 's/tensorflow-gpu==2.0.0/tensorflow-gpu==2.17.0/' setup.py \
&& python3 setup.py install
COPY src/main/api.py .
diff --git a/metis-image-enhancer-python-rest/src/main/mie.py b/metis-image-enhancer-python-rest/src/main/mie.py
index 8b02815..280d2f7 100644
--- a/metis-image-enhancer-python-rest/src/main/mie.py
+++ b/metis-image-enhancer-python-rest/src/main/mie.py
@@ -16,10 +16,10 @@
# Arguments
def parameters(argv):
arg_help = "{0} -i -o