This project is a simple Spring Boot application that uses Hugging Face's Image Recognition model for describing an image and generating image by putting message on top of image.
Following features has been added in this project
a. application exposes a REST API (/imgRecognize) endpoint that
takes an image as input and returns the image description.
Example curl for postman -
curl -X 'POST'
'http://localhost:8080/imgRecognize'
-H 'accept: /'
-H 'Content-Type: multipart/form-data'
-F 'file=@dog_on_roof.jpg;type=image/jpeg'
if you want to use swagger ui, then open
'http://localhost:8080/swagger-ui.html' or
'http://localhost:8080/swagger-ui/index.html'
and then upload an image for '/imgRecognize', on submission of
this request, we will get following response
{ "generated_text": "a dog standing on top of a building with a blue
sky in the background" }
b. application exposes a REST API (/formImageWithText) endpoint
that takes an image as input and one message which is optional. so
this endpoint works in following way
-- If user upload an image and
does not provide any message in the message field then upon
submission we get an image with a description painted over the
image, description will be provided from the hugging face api
which is AI generated image description
Example curl for postman -
curl -X 'POST'
'http://localhost:8080/formImageWithText?
message=Many%20colorful%20fishes%20in%20sea'
-H 'accept: /'
-H 'Content-Type: multipart/form-data'
-F 'file=@fish_under_water.jpg;type=image/jpeg'
if you want to use swagger ui, then open
'http://localhost:8080/swagger-ui.html' or
'http://localhost:8080/swagger-ui/index.html'
and then upload an image without providing any message for
'/formImageWithText', on submission of this request, we will get
an image with a message generated by Hugging Face API
-- If user upload an image and provide any message in the message
field then upon submission we get an image with a user provided
message painted over the image
Example curl for postman -
curl -X 'POST'
'http://localhost:8080/formImageWithText?
message=Many%20colorful%20fishes%20in%20sea'
-H 'accept: /'
-H 'Content-Type: multipart/form-data'
-F 'file=@fish_under_water.jpg;type=image/jpeg'
if you want to use swagger ui, then open
'http://localhost:8080/swagger-ui.html' or
'http://localhost:8080/swagger-ui/index.html'
and then provide a message and upload an image for
'/formImageWithText', on submission of this request, we will get an
image with a message provided by user