Requires: Apache Camel 4.8.0 or later
This example shows how Camel can consume images and route the messages based on the text output classified from the images.
Typical application scenarios include the use of image recognition from cameras in edge computing and the notification of the classification results to a central server.
What this example does is as follows:
-
Read image files (
.jpg
or.png
) from thedata/inbox
directory. -
Feed them to the
ssd
DJL PyTorch model for object detection. -
Convert the results from
DetectedObjects
toImage[]
. -
Split the images and feed each of them to the
resnet
DJL PyTorch model for image classification. -
Look up the hypernym of each classification result with the WordNet database.
-
Output the result to the log.
You can run this example from the project root using:
camel run image-to-text/image_to_text.java
Then put some image to the data/inbox
directory:
cp doge.jpg data/inbox
And see the output in the console:
2024-07-25 16:41:47.103 INFO 1909048 --- [le://data/inbox] image_to_text.java:22 : Processing: doge.jpg 2024-07-25 16:41:48.521 INFO 1909048 --- [le://data/inbox] image_to_text.java:39 : => [dingo, wild dog]
You can export this example to a project (for example Quarkus) using:
cd image-to-text
camel export --runtime quarkus --gav=org.apache.camel.example:image_to_text:1.0-SNAPSHOT image_to_text.java
If you hit any problem using Camel or have some feedback, then please let us know.
We also love contributors, so get involved :-)
The Camel riders!