Clarifai - Clarifai library for Golang

Clarifai Golang Library

Library for our v1 API.

GoDoc

Disclaimer

This API client only supports Clarifai v1 API. Stay tuned for the v2 support.

Usage

go get github.com/clarifai/clarifai-go

package main

import (
	"fmt"

	"github.com/clarifai/clarifai-go"
)

func main() {
	client := clarifai.NewClient("<client_id>", "<client_secret>")
	// Get the current status of things
	info, err := client.Info()
	if err != nil {
		fmt.Println(err)
	} else {
		fmt.Printf("%+v\n", info)
	}
	// Let's get some context about these images
	urls := []string{"https://samples.clarifai.com/metro-north.jpg", "https://samples.clarifai.com/puppy.jpeg"}
	// Give it to Clarifai to run their magic
	tag_data, err := client.Tag(clarifai.TagRequest{URLs: urls})

	if err != nil {
		fmt.Println(err)
	} else {
		fmt.Printf("%+v\n", tag_data) // See what we got!
	}

	feedback_data, err := client.Feedback(clarifai.FeedbackForm{
		URLs:    urls,
		AddTags: []string{"cat", "animal"},
	})

	if err != nil {
		fmt.Println(err)
	} else {
		fmt.Printf("%+v\n", feedback_data)
	}
}

Testing

Run go test

##Special Thanks

Thanks so much to Sam Couch for his amazing contribution to the Clarifai client libraries by starting this one and graciously handing it off to us. Follow him on Twitter @SamuelCouch.

Comments
  • Add support for color endpoint and file uploads.

    Add support for color endpoint and file uploads.

    This PR does a few things.

    • Adds file upload support for tag/color endpoints.
    • Adds full support for the color endpoint via the Color() method.
    • Adds tests to verify color support.
    • Updates README.md to show examples of new functionality.
  • Use JSON for tag and feedback requests.

    Use JSON for tag and feedback requests.

    I switched tag and feedback requests to use JSON rather than form data. (The API supports both.) This simplifies request construction and makes it easier to add more request parameters later.

    This is a breaking change for the Tag function, but it should help avoid more breaking changes in the future.

  • Update README example code to use working image URLs

    Update README example code to use working image URLs

    I was trying out the library and was surprised to discover that the URLs in the README example are broken (I'm guessing you guys changed where you hosted them somewhat recently). When I tried running the code from the example I got a somewhat vague error, with no indication that the URLs just weren't pointing to images.

    In any case, I thought I'd update the docs to use working image URLs.

  • Failed to unmarshal response for image request

    Failed to unmarshal response for image request

    When trying to get metadata about the following image, the API throws errors.

    https://data.whicdn.com/images/25997864/large.gif

    cannot unmarshal array into Go value of type string
    
  • added color tagging support

    added color tagging support

    This is a pretty simple addition. Just added support for color tagging requests, surprised it was not in the client initially.

    Let me know if you need any changes made before merging this in.

  • Request language

    Request language

    I am trying to add possibility to specify language for each request.

    I tried just adding a Language string variable to the TagRequest struct, but that didn't seem to do it.

    Any suggestions?

  • Images and Videos tag response inconsistency

    Images and Videos tag response inconsistency

    This pull request adds ImageTag() and VideoTag() methods and parallel model structures for image and video tag response. The existing Tag() method will return the same structure (but now the struct is named ImageTag).

    The problem is explained here: https://github.com/Clarifai/clarifai-go/issues/10

  • Images and Videos tag response inconsistency

    Images and Videos tag response inconsistency

    I have some problems with this library when getting tags for videos. The problem is this:

    This is an example response from the tag endpoint for a .mp4 video:

    {
        "results": [
            {
                "result": {
                        "classes": [
                            [
                                "no person",
                                "indoors",
    

    And this is a response for an image:

    {
        "results": [
            {
                "result": {
                    "tag": {
                        "classes": [
                            "keyboard",
    

    The classes field is an array of strings for images, but an array of an array of strings for videos.

    This is the diff which fixes the video responses:

    diff --git a/requests.go b/requests.go
    index 22fdb06..96bb70b 100644
    --- a/requests.go
    +++ b/requests.go
    @@ -56,9 +56,9 @@ type TagResult struct {
            LocalID       string   `json:"local_id"`
            Result        struct {
                    Tag struct {
    -                       Classes []string  `json:"classes"`
    +                       Classes [][]string  `json:"classes"`
                            CatIDs  []string  `json:"catids"`
    -                       Probs   []float32 `json:"probs"`
    +                       Probs   [][]float32 `json:"probs"`
                    }
            }
            DocIDString string `json:"docid_str"`
    

    But this will break the image tag response.

  • Implement a tag function from local file system

    Implement a tag function from local file system

    according to the documentation here you are able to make requests to the tag parameter with a local file, but this functionallity is not availble in this client. it seems to be implemented in the python client here. i'll be willing to put in a pull request.

This is my first golang project. The main reason for its existence is the need for practice. I will be studying golang while writing this project

My first GoLang project Project Aim The goal of this project is to develop the most simple golang bot to learn how to work with this programming langu

Jan 7, 2022
An experimental generic functional utility library inspired by Lodash

go-godash An experimental generic functional utility library inspired by Lodash Implemented functions Map Reduce Sum Filter Take TakeWhile Drop DropWh

May 31, 2022
Goro: A High-level Machine Learning Library for Go
Goro: A High-level Machine Learning Library for Go

Overview Goro is a high-level machine learning library for Go built on Gorgonia. It aims to have the same feel as Keras. Usage import ( . "github.

Nov 20, 2022
A library providing useful functional programming helpers for Go 1.18

Underscore underscore is a Go library providing useful functional programming helpers without extending any built-in objects. It is mostly a port from

Dec 29, 2022
Go-openoffice - Go library for reading OpenOffice odf and ods files

go-openoffice A Go library for reading OpenOffice/LibreOffice .ods (and .odf) fi

Dec 16, 2022
`go-redash-query` is a simple library to get structed data from `redash query` sources

go-redash-query go-redash-query is a simple library to get structed data from redash query sources Example Source table id name email 1 Dannyhann rhrn

May 22, 2022
A go wrapper around the rwkv.cpp library

AI without python (1) go-rwkv.cpp gowrkv.go is a wrapper around rwkv-cpp, which is an adaption of ggml.cpp. (1) Python required for training and conve

May 10, 2023
Golang 设计模式
Golang 设计模式

Golang设计模式思想 前言 一切设计模式都是灵活应用struct的组合模式,以及go隐形继承接口的特性 go中的interface就是一些方法装饰, 而struct并不依赖于接口 设计模式类型 创建模式 建造者模式(Builder Pattern) 将一个复杂对象的构建与它的表示分离, 使得同样

Dec 29, 2022
7 days golang programs from scratch (web framework Gee, distributed cache GeeCache, object relational mapping ORM framework GeeORM, rpc framework GeeRPC etc) 7天用Go动手写/从零实现系列

7 days golang programs from scratch README 中文版本 7天用Go从零实现系列 7天能写什么呢?类似 gin 的 web 框架?类似 groupcache 的分布式缓存?或者一个简单的 Python 解释器?希望这个仓库能给你答案

Jan 5, 2023
Examples of Golang compared to Node.js for learning
Examples of Golang compared to Node.js for learning

This guide full of examples is intended for people learning Go that are coming from Node.js, although the vice versa can work too. This is not meant to be a complete guide and it is assumed that you've gone through the Tour of Go tutorial. This guide is meant to be barely good enough to help you at a high level understand how to do X in Y and doing further learning on your own is of course required.

Jan 9, 2023
Golang && Back-end Stack , Continually updated

Stack Here Golang OS Net Note Tool Delve Authentication Paper Paper ?? Link GO官方文档 GO Official Doc GO官方博客 GO Official Blog GO官方仓库

Nov 8, 2022
The Ultimate Workshop Track for #golang Developer
The Ultimate Workshop Track  for #golang Developer

layout title nav_order description permalink default An Ultimate GopherLabs Hands-on Labs 1 An Ultimate GopherLabs Hands-on Labs / Join GopherLabs Com

Dec 7, 2022
high performance coding with golang(Go 语言高性能编程,Go 语言陷阱,Gotchas,Traps)
high performance coding with golang(Go 语言高性能编程,Go 语言陷阱,Gotchas,Traps)

Go 语言高性能编程 订阅 最新动态可以关注:知乎 Go语言 或微博 极客兔兔 订阅方式:watch geektutu/blog ,每篇文章都能收到邮件通知,或通过 RSS 订阅。

Dec 28, 2022
Go-Notebook is inspired by Jupyter Project (link) in order to document Golang code.
Go-Notebook is inspired by Jupyter Project (link) in order to document Golang code.

Go-Notebook Go-Notebook is an app that was developed using go-echo-live-view framework, developed also by us. GitHub repository is here. For this proj

Jan 9, 2023
Crash Course about the programming language Go / Golang.
Crash Course about the programming language Go / Golang.

Crash Course about the programming language Go / Golang. In this course I have covered some important concepts and topics in programming.

Oct 10, 2022
Building a shoe store with golang to learn more about this language :)

shoestore-go Building a shoe store with golang to learn more about this language :) TODO Create a basic webpage with the pages: home : to show homepag

Jan 24, 2022
Golang Learning resources

golang Golang Learning resources Data type detection dataFields interface{} dtype := reflect.TypeOf(dataFields).Kind().String() var c Company fmt.Prin

Dec 14, 2022
A complete guide to undersatnd golang programming language, web requests, JSON and creating web APIs with mongodb

Golang series A complete guide to undersatnd golang programming language, web requests, JSON and creating web APIs with mongodb LearnCodeonline.in 01

Jan 1, 2023
Dec 7, 2021