Skip to content

Issue while obtaining labels #7

@lukaszraczylo

Description

@lukaszraczylo

Parts of code responsible for image analysis:

batch, _ := client.NewBatchAnnotateImageRequest([]string{imageURL}, pigeon.NewFeature(pigeon.LabelDetection), pigeon.NewFeature(pigeon.SafeSearchDetection))

Getting annotations for both labels and safe search at the same time.

res, err := client.ImagesService().Annotate(batch).Do()
b, _ := json.Marshal(res.Responses)
json.Unmarshal(b, &GoogleVision)

Parsing the output into struct created automagically from the sample json ( as follows )

JSON:

{"labelAnnotations":[{"description":"anime","mid":"/m/0jxy","score":0.81207085,"topicality":0.81207085},{"description":"art","mid":"/m/0jjw","score":0.59014136,"topicality":0.59014136},{"description":"action figure","mid":"/m/017h86","score":0.5556467,"topicality":0.5556467},{"description":"graphics","mid":"/m/021sdg","score":0.53742254,"topicality":0.53742254},{"description":"video game software","mid":"/m/0987_ns","score":0.52508384,"topicality":0.52508384},{"description":"fiction","mid":"/m/02xlf","score":0.51081264,"topicality":0.51081264},{"description":"screenshot","mid":"/m/01zbnw","score":0.50924677,"topicality":0.50924677},{"description":"recreation","mid":"/m/06bm2","score":0.50229543,"topicality":0.50229543}],"safeSearchAnnotation":{"adult":"VERY_UNLIKELY","medical":"VERY_UNLIKELY","racy":"POSSIBLE","spoof":"VERY_UNLIKELY","violence":"UNLIKELY"}}

STRUCT:


type AutoGenerated struct { 	LabelAnnotations []struct { 		Description string  `json:"description"` 		Mid         string  `json:"mid"` 		Score       float64 `json:"score"` 		Topicality  float64 `json:"topicality"` 	} `json:"labelAnnotations"` 	SafeSearchAnnotation struct { 		Adult    string `json:"adult"` 		Medical  string `json:"medical"` 		Racy     string `json:"racy"` 		Spoof    string `json:"spoof"` 		Violence string `json:"violence"` 	} `json:"safeSearchAnnotation"` }
--

Unfortunately:
GoogleVision.SafeSearchAnnotation.Adult contains correct value
but

for _, label := range GoogleVision.LabelAnnotations {
		Log.Info("Label detected", label) }

is always empty.
Any ideas what's missing?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions