In this article, we will go over a project on image recognition using Go. We will also create a Telegram bot, through which we can send images for recognition.

The first thing we need is an already trained model. Yes, in this article we will not train our model. For this exercise, let’s take a ready-made module from the docker image of ctava/tfcgo.

To launch our project, we will need 4 terminals at the same time.

In the first case, we will launch an image recognition server. In the second case, we will launch the bot. In the third case, we will launch a public tunnel for sending our bot “out”. In the fourth - we will execute the command to register our bot.

To start the recognition server, create a Dockerfile:

FROM ctava/tfcgo

RUN mkdir -p /model && \
  curl -o /model/inception5h.zip -s "http://download.tensorflow.org/models/inception5h.zip" && \
  unzip /model/inception5h.zip -d /model

WORKDIR /go/src/imgrecognize
COPY src/ .
RUN go build
ENTRYPOINT [ "/go/src/imgrecognize/imgrecognize" ]
EXPOSE 8080

This way we will run our server in the image. Inside this image, we will have our server: src/imgrecognize. In addition, we will unpack the model in the directory: /model.

#golang #telegram-bot

Creating an Image Recognizer on Golang Telegram Bot
1.65 GEEK