Captionbot is a simple API wrapper for https://www.captionbot.ai/
go get github.com/nhatbui/captionbot
package main
import (
"fmt"
"github.com/nhatbui/captionbot"
"os"
)
var (
bot *captionbot.CaptionBot
caption string
err error
)
func main() {
bot, err = captionbot.New()
if err != nil {
fmt.Errorf("error instantiating bot %s", err)
os.Exit(-1)
}
imgURL := "http://www.nhatqbui.com/assets/me.jpg"
caption, err = bot.URLCaption(imgURL)
if err != nil {
fmt.Errorf("error uploading caption %s", err)
os.Exit(-1)
}
fmt.Println(caption)
// Or upload it
imgFile := "/path/to/image.jpg"
caption, err = bot.UploadCaption(imgFile)
if err != nil {
fmt.Errorf("error uploading caption %s", err)
os.Exit(-1)
}
fmt.Println(caption)
}
Thanks to @krikunts for their work on captionbot in Python that inspired this package.