clarifai-go icon indicating copy to clipboard operation
clarifai-go copied to clipboard

Images and Videos tag response inconsistency

Open tkrajina opened this issue 8 years ago • 0 comments

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.

tkrajina avatar Aug 17 '16 12:08 tkrajina