Skip to content

nhatbui/captionbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

Repository files navigation

captionbot

Captionbot is a simple API wrapper for https://www.captionbot.ai/

Installation

go get github.com/nhatbui/captionbot

Usage

package main 
 
import ( 
        "fmt" 
        "os" 
 
        "github.com/nhatbui/captionbot" 
) 
 
func main() { 
 
        bot, err := captionbot.New() 
        if err != nil { 
                fmt.Printf("error instantiating bot %s\n", err) 
                os.Exit(1) 
        } 
 
        // caption a remote image by provideing a URL 
        imgURL := "http://www.nhatqbui.com/assets/me.jpg" 
 
        caption, err := bot.URLCaption(imgURL) 
        if err != nil { 
                fmt.Printf("error uploading caption %s\n", err) 
                os.Exit(1) 
        } 
        fmt.Println(caption) 
 
        // caption a local image by uploading it 
        imgFile := "./sample.jpg" 
 
        caption, err = bot.UploadCaption(imgFile) 
        if err != nil { 
                fmt.Printf("error uploading caption %s\n", err) 
                os.Exit(1) 
        } 
        fmt.Println(caption) 
}

Thanks

Thanks to @krikunts for their work on captionbot in Python that inspired this package.