Google Vision: Run Multiple Types of Detection on a Single Image - google-vision

Google Vision Post requests usually look like this:
{
"requests":[
{
"image":{
"content": "image base64 string..."
},
"features":[
{
"type":"LABEL_DETECTION",
"maxResults":1
}
]
}
]
}
As far as I know, this only supports one 'type'.
However, I want Google to analyze for two types: LABEL_DETECTION and FACE_DETECTION.
Is it possible to ask for both in one request?
I'm currently sending two seperate requests, which is kind of inefficient.

try this one, features should be as array
{
"requests":[
{
"image":{
"content": "image base64 string..."
},
"features":[
{
"type":"LABEL_DETECTION",
"maxResults":1
},{
"type":"FACE_DETECTION",
"maxResults":1
}
]
}
]
}

Related

how to select a single item and get it's relations in faunadb?

I have two collections which have the data in the following format
{
"ref": Ref(Collection("Leads"), "267824207030650373"),
"ts": 1591675917565000,
"data": {
"notes": "voicemail ",
"source": "key-name",
"name": "Glenn"
}
}
{
"ref": Ref(Collection("Sources"), "266777079541924357"),
"ts": 1590677298970000,
"data": {
"key": "key-name",
"value": "Google Ads"
}
}
I want to be able to query the Leads collection and be able to retrieve the corresponding Sources document in a single query
I came up with the following query to try and use an index but I couldn't get it to run
Let(
{
data: Get(Ref(Collection('Leads'), '267824207030650373'))
},
{
data: Select(['data'],Var('data')),
source: q.Lambda('data',
Match(Index('LeadSourceByKey'), Get(Select(['source'], Var('data') )) )
)
}
)
Is there an easy way to retrieve the Sources document ?
What you are looking for is the following query which I broke down for you in multiple steps:
Let(
{
// Get the Lead document
lead: Get(Ref(Collection("Leads"), "269038063157510661")),
// Get the source key out of the lead document
sourceKey: Select(["data", "source"], Var("lead")),
// use the index to get the values via match
sourceValues: Paginate(Match(Index("LeadSourceValuesByKey"), Var("sourceKey")))
},
{
lead: Var("lead"),
sourceValues: Var("sourceValues")
}
)
The result is:
{
lead: {
ref: Ref(Collection("Leads"), "269038063157510661"),
ts: 1592833540970000,
data: {
notes: "voicemail ",
source: "key-name",
name: "Glenn"
}
},
sourceValues: {
data: [["key-name", "Google Ads"]]
}
}
sourceValues is an array since you specified in your index that there will be two items returned, the key and the value and an index always returns the array. Since your Match could have returned multiple values in case it wasn't a one-to-one, this becomes an array of an array.
This is only one approach, you could also make the index return a reference and Map/Get to get the actual document as explained on the forum.
However, I assume you asked the same question here. Although I applaud asking questions on stackoverflow vs slack or even our own forum, please do not just post the same question everywhere without linking to the others. This makes many people spend a lot of time while the question is already answered elsewhere.
You might probably change the Leads document and put the Ref to Sources document in source:
{
"ref": Ref(Collection("Leads"), "267824207030650373"),
"ts": 1591675917565000,
"data": {
"notes": "voicemail ",
"source": Ref(Collection("Sources"), "266777079541924357"),
"name": "Glenn"
}
}
{
"ref": Ref(Collection("Sources"), "266777079541924357"),
"ts": 1590677298970000,
"data": {
"key": "key-name",
"value": "Google Ads"
}
}
And then query this way:
Let(
{
lead: Select(['data'],Get(Ref(Collection('Leads'), '267824207030650373'))),
source:Select(['source'],Var('lead'))
},
{
data: Var('lead'),
source: Select(['data'],Get(Var('source')))
}
)

AutoML REST call with score_threshold returns 400 Bad Request

When I make a call to the Predictor and I add the score_threshold as shown below:
{
"payload": {
"image": {
"imageBytes": "YOUR_IMAGE_BYTES"
},
"params": { "score_threshold": "0.0" },
}
}
I get an error 400 Bad Request. The call works just fine (I get a prediction from AutoML) without the score_threshold clause. I'm using VB.Net for the call so wondering if there's a trick to formatting the call. I've also tried removing the quotes from the score as it is listed as a Float in the documentation with the same result.
as in the example from GCP website it should be
params.scoreThreshold
so your json will be
{
"payload": {
"image": {
"imageBytes": "YOUR_IMAGE_BYTES"
},
"params": { "scoreThreshold": 0.5 },
}
}

how to bind the response (data) getting from services call angular 5

component.ts file
public htmlData:any;
ngOnInit() {
this._htmlServices.getHtml()
.subscribe(data => {
this.htmlData = data;
});
}
Response from serivces callbelow
{
"html": {
"title": "HTML Questions",
"questions": [
{
"qno": 1,
"q": "What does a doctype do?",
"a": [
"It specifies which markup standard the page is using. With the information, the browser determines how to render the page according to the page's source code."
]
}
]
}
}
binding in html p tag below but it is not binding
<p>{{htmlData.html.title}}</p>
Without assuming anything here, it's likely that your htmlData is actually a string rather than json.
You might be able to see this by a:
console.log(typeof(this.htmlData))
just after assignment. So the solution is probably as simple as using
this.htmlData = JSON.parse(data)

Retrieve images in cells using Google Sheets API

I'm using the Google Sheets API to return the JSON of a Google Sheet,
e.g
var url = 'https://spreadsheets.google.com/feeds/list/' + id + '/od6/public/values?alt=json';
In one of the cells I have added an image, but this appears empty in the json.
How can I retrieve this image?
This is possible if you use Sheets API v4. If you make a spreadsheets.get request you get access to the =IMAGE(...) formula used in the cell.
GET https://sheets.googleapis.com/v4/spreadsheets/{SPREADSHEET_ID}?
includeGridData=true&ranges={RANGE_A1}&
fields=sheets%2Fdata%2FrowData%2Fvalues%2FuserEnteredValue
200 OK
{
"sheets": [
{
"data": [
{
"rowData": [
{
"values": [
{
"userEnteredValue": {
"formulaValue": "=image(\"https://www.google.com/images/srpr/logo3w.png\")"
}
}
]
}
]
}
]
}
]
}

protect certain phrases for search

I am currently trying to improve the corner cases of my elasticsearch-results. One particular is giving me a headache: "google+" which is simply reduced to "google". Omitting special chars is usually fine but for this one I would want an exception. Any ideas how to achieve this?
I tried the following setup:
{
"index": {
"analysis": {
"analyzer": {
"default": {
"tokenizer": "standard",
"filter": [
"synonym",
"word_delimiter"
]
}
},
"filter": {
"synonym": {
"type": "synonym",
"synonyms_path": "analysis/synonym.txt"
},
"word_delimiter": {
"type": "word_delimiter",
"protected_words_path": "analysis/protected.txt"
}
}
}
}
}
protected.txt contains one line with google+
I guess the Standard tokenizer is stripping out the + from google+. You can check it using the analyze api. I'd use the Whitespace tokenizer instead and properly configure the Word delimiter token filter that you're already using.
I think pattern replace would be a better idea - http://www.elasticsearch.org/guide/reference/index-modules/analysis/pattern_replace-tokenfilter.html