Face detection model returns empty dict (Google Cloud Video Intelligence) - video-intelligence-api

I'm having issues with the face detection model from the Google Video Intelligence API.
I'm using Python 3.6.5, and google-cloud-videointelligence==1.15.0.
Occasionally I will receive a mangled response from the face detection model. I am parsing the response from the API by converting it into a dictionary using google.protobuf.json_format.MessageToDict(). I expect one of two behaviours to occur:
A. If faces are present in the video, I expect the results to be under the key 'FaceDetectionAnnotations', and take the form of a dictionary of dictionaries; with the keys of the outer dictionary being the 'segment number' (an integer), and the inner dictionaries looking something like this:
{'coordinates': {'left': 0.3432,
'top': 0.075,
'right': 0.6667,
'bottom': 0.7435},
'labels': {'confidence': 1.0,
'attributes': [{'name': 'glasses', 'confidence': 0.041921083},
{'name': 'headwear', 'confidence': 0.10601594},
{'name': 'eyes_visible', 'confidence': 0.9976739},
{'name': 'mouth_open', 'confidence': 0.005100015},
{'name': 'looking_at_camera', 'confidence': 0.9647807},
{'name': 'smiling', 'confidence': 0.017670842}]}}
B. If faces are not present in the video, I expect there to be no such 'FaceDetectionAnnotations' key anywhere in the results.
However, occasionally I am seeing a third kind of response, where the 'FaceDetectionAnnotations' key is present in the results (suggesting that the face detection model did in fact detect faces), however each of the inner dictionaries is completely empty. There is still one inner dictionary for each segment, but they contain none of the usual information, such as the start- and end-times of the segments, or any coordinates or confidence values.
I am only seeing this problem for videos that have faces in them.
I can confirm that this problem is present in the raw response from Google VI (before it is parsed with the MessageToDict() function, and I'm not sure what is causing it. Below is a link to an example video that exhibits this problem.
https://drive.google.com/file/d/1gsbe20iWp6lD9dH0PNvxvvQFUeB5F_cz/view?usp=sharing
If anyone has seen anything like this before, or has any idea how to fix this, I would greatly appreciate it.

Currently, there is an open issue regarding your concern, here. There engineering team is looking into it, you can keep track of its progress by following the thread linked above.

Related

Quality of result set

I use the here PlacesServices to retrieve information what's around me. Often I get results that are quite ambiguous / duplicate because outdated data appears to be in the result set that reduces the quality quite significantly. How can we feed back changes to the community or how and when does here get updates for those categories, e.g. restaurants or petrol-stations?
Is there a way to dedup?
This is a good example for 3/6 duplicates (same petrol station) since the chain changed some time ago dependent of the direction on the highway.
https://places.ls.hereapi.com/places/v1/places/276u1jne-8c62ebd6159c441eba290df4efdcfd1d;context=Zmxvdy1pZD02ZWQ0YzViNS0wMzgxLTUxZDAtOTg2ZC00NjQ3YTVjNWJhYTJfMTU3NTY2NjU1MTYwM18wXzE1NCZyYW5rPTI
https://places.ls.hereapi.com/places/v1/places/276u1jne-3c240a265c6e48d698a400b7d8738202;context=Zmxvdy1pZD02ZWQ0YzViNS0wMzgxLTUxZDAtOTg2ZC00NjQ3YTVjNWJhYTJfMTU3NTY2NjU1MTYwM18wXzE1NCZyYW5rPTQ
3 chains for a single petrol station
Finally, is there a solution how I'd only obtain those in my travel direction?
var query = {"in": lat +"," + lng +";r="+distance*1000,"cat" : categories +",pretty"};
let entryPoint = H.service.PlacesService.EntryPoint;
await this.places.request(entryPoint.EXPLORE, query,
function(response) {
values = response.results.items;
}, function(resp) {
console.log('ERROR: '+resp);
});
Best regards and many thanks in advance
O.
In general the feedback related to HERE Map data can be reported by either the Map Feedback API , the details on the API are available on the documentation page , or The Online Tool HERE Map Creator could be used.
With respect to retrieving POIs, it is possible to request POIs along the route using the "browse/by-corridor" (documentation) end point where the route shape and a radius could be provided as a corridor. It should be noted however the API does not consider the heading direction of the route and may return POIs on the other side of a road. Example :
https://places.ls.hereapi.com/places/v1/browse/by-corridor?route=[52.5199356,13.3866272|52.5100899,13.2816896|52.4351807,13.1935196|52.4107285,13.1964502|52.38871,13.1557798|52.3727798,13.1491003|52.3737488,13.1154604|52.3875198,13.0872202|52.4029388,13.0706196|52.4105797,13.0755529]&apiKey=API_KEY

How to analyze weird Goal Flow results? Is it possible to view specific users' journeys?

To help analyzing a site's user flow, I wrote a test bed in JavaScript, creating a new fake tracker, sending a few fake pageviews in like 1-2 second intervals according to a pretty extensive, randomized graph of expected views. I then set up goals in GA, containing funnels through certain pages. Then I left it running for a few hours, accumulating a few hundreds fake users.
Raw goal conversion percentages look good, page content flows too, BUT... when I'm looking at Goal Flow, some of the connections in the funnels don't make sense. For example 80% of my fake users seem to go from step "about" directly to step "success", skipping "product" and "payment", while - according to my test setup - that can't ever happen. (Step names used are examples to match the code below.)
I'd like to see exactly what paths did these particular users take - did some pages just not register, or did they register out of order, or what? Is there any way I can view RAW user journeys in GA, page by page?
For those interested, the testing code is basically like this:
ga("create","UA-0000000-2", "auto", "testtracker", {
'cookieName':"_ga_test_"+Date.now(),
'cookieExpires':120,
'clientId': 'cid-'+Date.now(),
});
var spd=1500;
var delay=0;
function pageview(page) {
setTimeout(function() {
ga("testtracker.send","pageview",page);
console.log("Sending: "+page);
},delay+=spd);
}
pageview("start");
if (Math.random()<.60) pageview("about");
if (Math.random()<.30) {
pageview("product");
if (Math.random()<.20) {
pageview("payment");
if (Math.random()<.70) {
pageview("success");
}
}
}
Apparently, I still have a lot to learn about GA.
The solution is to use Audience -> User Explorer and defining a very specific Section based on the suspicious sequence of pages does show individual users matching that pattern. And indeed somehow GA logged a pretty large number of such odd users for me, perhaps failing to register pages visited in too narrow time intervals.
I'm leaving the question for posterity, and perhaps for those who can find my code snippet useful.

Use PUT or PATCH verb when request is updating and deleting: Real life design

I've been trying to get the HTTP verbs right lately, however I have a doubt regarding using PUT, PATCH or even POST for the following scenario.
The front end part is sending the following JSON data:
{
name: "Spanish-01",
code: "ESP01",
students: [{
IdStudent: 1,
name: "Peter Parker"
},
{
IdStudent: 2
name: "Ben Reilly",
dirtyRemove: true
}]
}
The back end code will update the Class record (e.g name and code). However, it will also delete the students with flag dirtyRemove, and those live in another table called Student.
So what's the rule here? Since PUT and PATCH according to w3.org here is for updating an existing resource. In this case the back end is both updating and deleting at the same time?
Should I use PUT or PATCH or neither?
NOTE: Don't mind about the FE part, I minimized the scope in order to get a more straightforward example
How your resources are implemented internally using tables is an implementation detail. It doesn't matter.
That said, your example payload doesn't fit PUT (to remove a student, you would omit it). It might fit PATCH, if you properly label the payload with a content type describing what semantics you expect.
Nit: the HTTP spec is not a W3 document, and the version you're looking at is outdated.

Errors When Calculating Distance Between Two Addresses

I have the following script which is being used in a spreadsheet to calculate the driving distance between two cities or a city and a zip code of another city. It is being run for approximately 25 locations simultaneously. To better explain, I have cell B3 in which I enter a new city every time. The script is then used in cells adjacent to my 25 plant locations to calculate the distance from each of my plants to the variable city.
It uses google sheets built in mapping api and works on 80% of the calculations but returns "TypeError: Can Not Read Property "legs" from undefined. (line 16). The plants that it fails on vary with every new city so its not like it is for certain locations. It is almost like the api times out before it completes some of them. I split it into two separate scripts with a varied name and that worked for a day but then 20% fail again.
To make things slightly more odd, I have another script that sorts the plants based on closest distance to the variable address. When you sort the plants, even the ones with errors go to their correct location based on distance. So it is like the distance script is obtaining the correct disance but displaying the error anyways.
Clear as mud? Would love any input I could get on how to correct the issue or an alternate mapping api that could solve my problems.
function distancecalcone(origin,destination) {
var directions = Maps.newDirectionFinder()
//Set the Method of Transporation. The available "modes" are WALKING, DRIVING, BICYCLING, TRANSIT.
.setMode(Maps.DirectionFinder.Mode.DRIVING)
//Set the Orgin
.setOrigin(origin)
//Set the Destination
.setDestination(destination)
//Retrieve the Distance
.getDirections();
return directions.routes[0].legs[0].distance.value/1609.34;
}
Have you tried using a try-catch block around directions.routes[0].legs[0].distance.value ?
try{
return directions.routes[0].legs[0].distance.value/1609.34;
}
catch (e){
console.log("error",e)
}
or you could try something like this
alert(directions);
alert(directions.routes[0]);
alert(directions.routes[0].legs[0]);
alert(directions.routes[0].legs[0].distance);
alert(directions.routes[0].legs[0].distance.value);
and so on...to find out which one comes up as undefined the first. That might help you to debug the issue.
Enable Direction Api
1)Go to "google cloud platform"
2)go to "Api and services"
3)search for "direction api" and enable it
The directions service is subject to a quota and a rate limit. Check the return status before parsing the result.
For lots of distances (or at least more than 10), look at the DistanceMatrix.
I'm able to run the script from the Script editor, but not from spreadsheet. The error is "unable to read property legs" when the function is called from spreadsheet. But the property is in place when called from Script editor and contain correct values.
You probably need to use WEB API and have API KEY:
Google Apps Script - How to get driving distance from Maps for two points in spreadsheet

Which optional parameters do improve the accuracy of a google geolocation request result?

I am using gsm cell data to get the current device position. To do this I use the Google Maps Geolocation API. All fields seem to be optional in the first part of the needed JSON parameters (URL: https://www.googleapis.com/geolocation/v1/geolocate?key=API_key):
{
"homeMobileCountryCode": 310,
"homeMobileNetworkCode": 410,
"radioType": "gsm",
"carrier": "Vodafone",
"cellTowers": [
// See the Cell Tower Objects section below.
],
"wifiAccessPoints": [
// See the WiFi Access Point Objects section below.
]
}
Do the first 4 parameters homeMCC, homeMNC, radio Type and carrier have any influences on the accuracy? or the response time? I could not make out any differences.
I can believe that the Google database of cell IDs is organised by carrier and network type, so there might in theory be a quicker response if you supply these parameters, but it would surely be negligible. Can't think of a technical reason why it would need to know your home operator details too. The only information these parameters would give them is (1) whether you're roaming or not and (2) any stored information that they might be holding about individual operators. Does Google have special agreements with any operators?

Resources