{"html_url": "https://github.com/dogsheep/dogsheep-photos/issues/14#issuecomment-620769348", "issue_url": "https://api.github.com/repos/dogsheep/dogsheep-photos/issues/14", "id": 620769348, "node_id": "MDEyOklzc3VlQ29tbWVudDYyMDc2OTM0OA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-04-28T18:09:21Z", "updated_at": "2020-04-28T18:09:21Z", "author_association": "MEMBER", "body": "Pricing is pretty good: free for first 1,000 calls per month, then $1.50 per thousand after that.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 608512747, "label": "Annotate photos using the Google Cloud Vision API"}, "performed_via_github_app": null} {"html_url": "https://github.com/dogsheep/dogsheep-photos/issues/14#issuecomment-620771067", "issue_url": "https://api.github.com/repos/dogsheep/dogsheep-photos/issues/14", "id": 620771067, "node_id": "MDEyOklzc3VlQ29tbWVudDYyMDc3MTA2Nw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-04-28T18:12:34Z", "updated_at": "2020-04-28T18:15:38Z", "author_association": "MEMBER", "body": "Python library docs: https://googleapis.dev/python/vision/latest/index.html\r\n\r\nI'm creating a new project for this called simonwillison-photos: https://console.cloud.google.com/projectcreate\r\n\r\nhttps://console.cloud.google.com/home/dashboard?project=simonwillison-photos\r\n\r\nThen I enabled the Vision API. The direct link to https://console.cloud.google.com/flows/enableapi?apiid=vision-json.googleapis.com which they provided in the docs didn't work - it gave me a \"You don't have sufficient permissions to use the requested API\" error - but starting at the \"Enable APIs\" page and searching for it worked fine.\r\n\r\nI created a new service account as an \"owner\" of that project: https://console.cloud.google.com/apis/credentials/serviceaccountkey (and complained about it on Twitter and through their feedback form)\r\n\r\n`pip install google-cloud-vision`\r\n\r\n```python\r\nfrom google.cloud import vision\r\nclient = vision.ImageAnnotatorClient.from_service_account_file(\"simonwillison-photos-18c570b301fe.json\")\r\n# Photo of a lemur\r\nresponse = client.annotate_image(\r\n {\r\n \"image\": {\r\n \"source\": {\r\n \"image_uri\": \"https://photos.simonwillison.net/i/1b3414ee9ade67ce04ade9042e6d4b433d1e523c9a16af17f490e2c0a619755b.jpeg\"\r\n }\r\n },\r\n \"features\": [\r\n {\"type\": vision.enums.Feature.Type.IMAGE_PROPERTIES},\r\n {\"type\": vision.enums.Feature.Type.OBJECT_LOCALIZATION},\r\n {\"type\": vision.enums.Feature.Type.LABEL_DETECTION},\r\n ],\r\n }\r\n)\r\nresponse\r\n```\r\nOutput is:\r\n```\r\nlabel_annotations {\r\n mid: \"/m/09686\"\r\n description: \"Vertebrate\"\r\n score: 0.9851104021072388\r\n topicality: 0.9851104021072388\r\n}\r\nlabel_annotations {\r\n mid: \"/m/04rky\"\r\n description: \"Mammal\"\r\n score: 0.975814163684845\r\n topicality: 0.975814163684845\r\n}\r\nlabel_annotations {\r\n mid: \"/m/01280g\"\r\n description: \"Wildlife\"\r\n score: 0.8973650336265564\r\n topicality: 0.8973650336265564\r\n}\r\nlabel_annotations {\r\n mid: \"/m/02f9pk\"\r\n description: \"Lemur\"\r\n score: 0.8270352482795715\r\n topicality: 0.8270352482795715\r\n}\r\nlabel_annotations {\r\n mid: \"/m/0fbf1m\"\r\n description: \"Terrestrial animal\"\r\n score: 0.7443860769271851\r\n topicality: 0.7443860769271851\r\n}\r\nlabel_annotations {\r\n mid: \"/m/06z_nw\"\r\n description: \"Tail\"\r\n score: 0.6934166550636292\r\n topicality: 0.6934166550636292\r\n}\r\nlabel_annotations {\r\n mid: \"/m/0b5gs\"\r\n description: \"Branch\"\r\n score: 0.6203985214233398\r\n topicality: 0.6203985214233398\r\n}\r\nlabel_annotations {\r\n mid: \"/m/05s2s\"\r\n description: \"Plant\"\r\n score: 0.585474967956543\r\n topicality: 0.585474967956543\r\n}\r\nlabel_annotations {\r\n mid: \"/m/089v3\"\r\n description: \"Zoo\"\r\n score: 0.5488107800483704\r\n topicality: 0.5488107800483704\r\n}\r\nlabel_annotations {\r\n mid: \"/m/02tcwp\"\r\n description: \"Trunk\"\r\n score: 0.5200017690658569\r\n topicality: 0.5200017690658569\r\n}\r\nimage_properties_annotation {\r\n dominant_colors {\r\n colors {\r\n color {\r\n red: 172.0\r\n green: 146.0\r\n blue: 116.0\r\n }\r\n score: 0.24523821473121643\r\n pixel_fraction: 0.027533333748579025\r\n }\r\n colors {\r\n color {\r\n red: 54.0\r\n green: 50.0\r\n blue: 42.0\r\n }\r\n score: 0.10449723154306412\r\n pixel_fraction: 0.12893334031105042\r\n }\r\n colors {\r\n color {\r\n red: 141.0\r\n green: 121.0\r\n blue: 97.0\r\n }\r\n score: 0.1391485631465912\r\n pixel_fraction: 0.039133332669734955\r\n }\r\n colors {\r\n color {\r\n red: 28.0\r\n green: 25.0\r\n blue: 20.0\r\n }\r\n score: 0.08589499443769455\r\n pixel_fraction: 0.11506666988134384\r\n }\r\n colors {\r\n color {\r\n red: 87.0\r\n green: 82.0\r\n blue: 74.0\r\n }\r\n score: 0.0845794677734375\r\n pixel_fraction: 0.16113333404064178\r\n }\r\n colors {\r\n color {\r\n red: 121.0\r\n green: 117.0\r\n blue: 108.0\r\n }\r\n score: 0.05901569500565529\r\n pixel_fraction: 0.13379999995231628\r\n }\r\n colors {\r\n color {\r\n red: 94.0\r\n green: 83.0\r\n blue: 66.0\r\n }\r\n score: 0.049011144787073135\r\n pixel_fraction: 0.03946666792035103\r\n }\r\n colors {\r\n color {\r\n red: 155.0\r\n green: 117.0\r\n blue: 90.0\r\n }\r\n score: 0.04164913296699524\r\n pixel_fraction: 0.0023333332501351833\r\n }\r\n colors {\r\n color {\r\n red: 178.0\r\n green: 143.0\r\n blue: 102.0\r\n }\r\n score: 0.02993861958384514\r\n pixel_fraction: 0.0012666666880249977\r\n }\r\n colors {\r\n color {\r\n red: 61.0\r\n green: 51.0\r\n blue: 35.0\r\n }\r\n score: 0.027391711249947548\r\n pixel_fraction: 0.01953333243727684\r\n }\r\n }\r\n}\r\ncrop_hints_annotation {\r\n crop_hints {\r\n bounding_poly {\r\n vertices {\r\n x: 2073\r\n }\r\n vertices {\r\n x: 4008\r\n }\r\n vertices {\r\n x: 4008\r\n y: 3455\r\n }\r\n vertices {\r\n x: 2073\r\n y: 3455\r\n }\r\n }\r\n confidence: 0.65625\r\n importance_fraction: 0.746666669845581\r\n }\r\n}\r\nlocalized_object_annotations {\r\n mid: \"/m/0jbk\"\r\n name: \"Animal\"\r\n score: 0.7008256912231445\r\n bounding_poly {\r\n normalized_vertices {\r\n x: 0.0390297956764698\r\n y: 0.26235100626945496\r\n }\r\n normalized_vertices {\r\n x: 0.8466796875\r\n y: 0.26235100626945496\r\n }\r\n normalized_vertices {\r\n x: 0.8466796875\r\n y: 0.9386426210403442\r\n }\r\n normalized_vertices {\r\n x: 0.0390297956764698\r\n y: 0.9386426210403442\r\n }\r\n }\r\n}\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 608512747, "label": "Annotate photos using the Google Cloud Vision API"}, "performed_via_github_app": null} {"html_url": "https://github.com/dogsheep/dogsheep-photos/issues/14#issuecomment-620771698", "issue_url": "https://api.github.com/repos/dogsheep/dogsheep-photos/issues/14", "id": 620771698, "node_id": "MDEyOklzc3VlQ29tbWVudDYyMDc3MTY5OA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-04-28T18:13:48Z", "updated_at": "2020-04-28T18:13:48Z", "author_association": "MEMBER", "body": "For face detection:\r\n```\r\n {\"type\": vision.enums.Feature.Type.Type.FACE_DETECTION}\r\n```\r\nFor OCR:\r\n```\r\n {\"type\": vision.enums.Feature.Type.DOCUMENT_TEXT_DETECTION}\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 608512747, "label": "Annotate photos using the Google Cloud Vision API"}, "performed_via_github_app": null} {"html_url": "https://github.com/dogsheep/dogsheep-photos/issues/14#issuecomment-620772190", "issue_url": "https://api.github.com/repos/dogsheep/dogsheep-photos/issues/14", "id": 620772190, "node_id": "MDEyOklzc3VlQ29tbWVudDYyMDc3MjE5MA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-04-28T18:14:43Z", "updated_at": "2020-04-28T18:14:43Z", "author_association": "MEMBER", "body": "Database schema for this will require some thought. Just dumping the output into a JSON column isn't going to be flexible enough - I want to be able to FTS against labels and OCR text, and potentially query against other characteristics too.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 608512747, "label": "Annotate photos using the Google Cloud Vision API"}, "performed_via_github_app": null} {"html_url": "https://github.com/dogsheep/dogsheep-photos/issues/14#issuecomment-620774507", "issue_url": "https://api.github.com/repos/dogsheep/dogsheep-photos/issues/14", "id": 620774507, "node_id": "MDEyOklzc3VlQ29tbWVudDYyMDc3NDUwNw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-04-28T18:19:06Z", "updated_at": "2020-04-28T18:19:06Z", "author_association": "MEMBER", "body": "The default timeout is a bit aggressive and sometimes failed for me if my resizing proxy took too long to fetch and resize the image.\r\n\r\n`client.annotate_image(..., timeout=3.0)` may be worth trying.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 608512747, "label": "Annotate photos using the Google Cloud Vision API"}, "performed_via_github_app": null}