"Confidence" field missing in the paid version of the cloud vision API's JSON response for OCR - google-cloud-ml

The JSON response from the free version of Vision API (https://cloud.google.com/vision/docs/drag-and-drop) has the field named "Confidence" which shows the recognition confidence of the model on the word level and character level. While in the paid version this field is missing. The example JSON is as under.
Drag-and-Drop output JSON structure:
{
"boundingBox": {
"vertices": [
{
"x": 85,
"y": 7
},
{
"x": 92,
"y": 7
},
{
"x": 92,
"y": 26
},
{
"x": 85,
"y": 26
}
]
},
"text": "abc xyz",
"confidence": 0.99
}
Paid version output structure:
{
"description": "abc xyz",
"boundingPoly": {
"vertices": [
{"y": 437, "x": 2108},
{"y": 437, "x": 2194},
{"y": 453, "x": 2194},
{"y": 453, "x": 2108}]
}
}
Is this feature in the testing stage and not available to any paid user? I want to use the character level model confidence, how can I use?

For text_detection currently no character level confidence as it is using a different model comparing to document_text_detection.

Related

Facebook Graph API Album Endpoint is deprecated?

I am using the graph api (through android SDK and graph explorer) to get a page's posts, when I get to a post of a page that has multiple images in a post it becomes an album.
Example post response
"message": "Test Multi-Photos",
"full_picture": "",
"from": {
"name": "TestPage",
"id": ""
},
"attachments": {
"data": [
{
"media_type": "album",
"media": {
"image": {
"height": 405,
"src": "",
"width": 720
}
},
"type": "album",
"title": "Photos from TestPage's post",
"target": {
"id": "147710857059579",
"url": ""
}
}
]
},
"id": "_147710857059579"
}
When I try to use the target.id to get the album photos
I believe the url would look like this
https://graph.facebook.com/147710857059579
I get a response saying that the endpoint is deprecated
{
"error": {
"message": "(#12) singular statuses API is deprecated for versions v2.4 and higher",
"type": "OAuthException",
"code": 12,
"fbtrace_id": "AhhiY7ohbb5SoXdFNDZnHhU
"
}
}
Documentation does not say anything about it being deprecated so how do you get the album photos?
To get photos from an album post you have to add subattachments to the attachments fields in the query.
Example using the Android SDK
parameters.putString("fields", "message,full_picture,from,place,attachments{media_type,media,type,title,description,target,subattachments}")
parameters.putString("limit", "10")

Cloud Functions: How to upload a folder that contains images?

I want to deploy a bot using Cloud Functions from Google Cloud Platform. My code is write in python, but I want to add a folder with a lot of images that my bot will tweet on twitter. I want to do that to make sure my bot will run 24/7, and add to Cloud Scheduler to schedule my tweets.
Is possible to upload the image folder there somehow?
I tried to upload all of my file in a .zip file and upload there, but it will fail to build. Alone just code is working fine. I use Google Developer Platform for some time but I never tried this.
Here are the errors from google cloud platform:
{
"protoPayload": {
"#type": "type.googleapis.com/google.cloud.audit.AuditLog",
"status": {
"code": 3,
"message": "Function failed on loading user code. This is likely due to a bug in the user code. Error message: Error: please examine your function logs to see the error cause: https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs. Additional troubleshooting documentation can be found at https://cloud.google.com/functions/docs/troubleshooting#logging. Please visit https://cloud.google.com/functions/docs/troubleshooting for in-depth troubleshooting documentation."
},
"authenticationInfo": {
"principalEmail": "robertmaximus383#gmail.com"
},
"serviceName": "cloudfunctions.googleapis.com",
"methodName": "google.cloud.functions.v1.CloudFunctionsService.CreateFunction",
"resourceName": "projects/twitter-post-bot/locations/us-central1/functions/twitter-post"
},
"insertId": "-63htw4d2bfe",
"resource": {
"type": "cloud_function",
"labels": {
"project_id": "twitter-post-bot",
"region": "us-central1",
"function_name": "twitter-post"
}
},
"timestamp": "2022-01-31T08:06:24.986674Z",
"severity": "ERROR",
"logName": "projects/twitter-post-bot/logs/cloudaudit.googleapis.com%2Factivity",
"operation": {
"id": "operations/dHdpdHRlci1wb3N0LWJvdC91cy1jZW50cmFsMS90d2l0dGVyLXBvc3QvZEt5N24yX1NjTE0",
"producer": "cloudfunctions.googleapis.com",
"last": true
},
"receiveTimestamp": "2022-01-31T08:06:25.259596536Z"
}
2
{
"textPayload": "Function cannot be initialized. Error: function terminated. Recommended action: inspect logs for termination reason. Additional troubleshooting documentation can be found at https://cloud.google.com/functions/docs/troubleshooting#logging\n",
"insertId": "000000-5838e3b2-5d8d-4187-86ca-97327d016436",
"resource": {
"type": "cloud_function",
"labels": {
"region": "us-central1",
"function_name": "twitter-post",
"project_id": "twitter-post-bot"
}
},
"timestamp": "2022-01-31T08:06:24.930142467Z",
"severity": "ERROR",
"labels": {
"execution_id": ""
},
"logName": "projects/twitter-post-bot/logs/cloudfunctions.googleapis.com%2Fcloud-functions",
"receiveTimestamp": "2022-01-31T08:06:25.532983237Z"
}
3
{
"textPayload": "Traceback (most recent call last):\n File \"/layers/google.python.pip/pip/bin/functions-framework\", line 8, in <module>\n sys.exit(_cli())\n File \"/layers/google.python.pip/pip/lib/python3.9/site-packages/click/core.py\", line 829, in __call__\n return self.main(*args, **kwargs)\n File \"/layers/google.python.pip/pip/lib/python3.9/site-packages/click/core.py\", line 782, in main\n rv = self.invoke(ctx)\n File \"/layers/google.python.pip/pip/lib/python3.9/site-packages/click/core.py\", line 1066, in invoke\n return ctx.invoke(self.callback, **ctx.params)\n File \"/layers/google.python.pip/pip/lib/python3.9/site-packages/click/core.py\", line 610, in invoke\n return callback(*args, **kwargs)\n File \"/layers/google.python.pip/pip/lib/python3.9/site-packages/functions_framework/_cli.py\", line 37, in _cli\n app = create_app(target, source, signature_type)\n File \"/layers/google.python.pip/pip/lib/python3.9/site-packages/functions_framework/__init__.py\", line 288, in create_app\n spec.loader.exec_module(source_module)\n File \"<frozen importlib._bootstrap_external>\", line 850, in exec_module\n File \"<frozen importlib._bootstrap>\", line 228, in _call_with_frames_removed\n File \"/workspace/main.py\", line 2, in <module>\n from twitter import *\nModuleNotFoundError: No module named 'twitter'",
"insertId": "000000-438da477-ef7c-4c81-98a2-21bdccc7ca12",
"resource": {
"type": "cloud_function",
"labels": {
"project_id": "twitter-post-bot",
"function_name": "twitter-post",
"region": "us-central1"
}
},
"timestamp": "2022-01-31T08:06:24.238Z",
"severity": "ERROR",
"labels": {
"execution_id": ""
},
"logName": "projects/twitter-post-bot/logs/cloudfunctions.googleapis.com%2Fcloud-functions",
"receiveTimestamp": "2022-01-31T08:06:25.532983237Z"
}
When you deploy your code on Cloud Functions, the code is taken, compiled and packaged in a container (with Buildpack) and deployed on Cloud Functions.
In your case, the code is not compiled, only packaged.
Your source code is kept in the container, but in a specific directory. I wrote an article with a sample in Golang but you can find where the statics files are stored: /workspace/src/
That will fix your issue, but I think you have a design issue. The static and unstructured data should be in your Cloud Functions. Cloud Storage is the perfect place for that, and it's a better and more scalable solution.

CVAT coco annotation json - iscrowd option

when outputting coco annotation json from CVAT, it is found that there is an attribute call 'iscrowd', but I cant seem to figure out how it is adjusted or annotated on CVAT to change the value to 1, under the scenario where the object is literally crowded. Can any one shed some lights?
{
"annotations": [
{
"bbox": [
762.703125,
176.583984375,
425.27301025390625,
413.6938171386719
],
"id": 1,
"area": 175932.81493799202,
"iscrowd": 0,
"segmentation": [
[
762.703125,
176.583984375,
1187.9761352539062,
176.583984375,
1187.9761352539062,
590.2778015136719,
762.703125,
590.2778015136719
]
],
"category_id": 1,
"image_id": 0
}
],
"licenses": [
{
"name": "",
"id": 0,
"url": ""
}
],
"info": {
"version": "",
"description": "",
"date_created": "",
"contributor": "",
"year": "",
"url": ""
},
"images": [
{
"file_name": "10.jpg",
"id": 0,
"license": 0,
"flickr_url": "",
"height": 864,
"coco_url": "",
"date_captured": 0,
"width": 1536
}
],
"categories": [
{
"name": "test",
"supercategory": "",
"id": 1
}
]
}
On the other hand when adding an attribute to a label (Simple Check Box Attribute), it doesn't seem to be properly outputted in COCO json. Am I doing something Wrong?
It might be worth taking a look at the integration between FiftyOne, an open source dataset exploration tool, and CVAT which provides a flexible API to upload and define how to annotate new and existing labels. This post pretty much walks through the workflow you are looking for.
You can load COCO formatted datasets into FiftyOne:
import fiftyone as fo
dataset = fo.Dataset.from_dir(
dataset_dir="/path/to/dataset",
dataset_type=fo.types.COCODetectionDataset,
label_field="ground_truth",
)
Send the dataset (or a subset of it) to CVAT for annotation:
dataset.annotate("annot_run_1", label_field="ground_truth", backend="cvat")
It will automatically upload the annotations to CVAT, including formatting all attributes on your labels (like iscrowd) for you to edit in CVAT. The API for this integration also lets you specify new attributes and how they are to be annotated.
When you're done annotating, you can load it back into FiftyOne and write it back to disk in the COCO format.
# Load from CVAT
dataset.load_annotations("annot_run_1")
# Write back to disk
dataset.export(
export_dir="/path/to/label.json",
dataset_type=fo.types.COCODetectionDataset,
label_field="ground_truth",
)

Dynamically add ordered number to each object in Paginated response from Django Rest

I'm currently getting a standard paginated response using Django REST framework, however I need to add a number to each object response in the order it is retrieved. 1,2,3,4,5 etc. It must be calculated each time dynamically if new results are added and retrieved by the user. It would go from this:
{
"next": "http://localhost:8000/api/home/?page=2",
"previous": null,
"count": 105,
"results": [
{
"title": "example1",
"description": "foobar1",
},
{
"title": "example2",
"description": "",
},
...
]
to looking like this:
{
"next": "http://localhost:8000/api/home/?page=2",
"previous": null,
"count": 105,
"results": [
{
"key": 1,
"title": "example1",
"description": "foobar1",
},
{
"key": 2,
"title": "example2",
"description": "",
},
...
]
This would also include the next page in the paginated response, e.g. 21, 22, 23, 24. If a user then refreshes the page and new data is found and retrieved it would recalculate and add key numbers again. How would one go about this?
Thanks!

View CloudFront metrics in CloudWatch dashboard

Is there a way to display CloudFront metrics inside an existing CloudWatch dashboard ?
I can view CloudFront distributions metrics in the CloudFront console (Total requests, hit ratio ...) but i cant find theses metrics in CloudWatch dashboards.
On the Cloudfront documentation (https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cf-metricscollected.html) they talk about the "AWS/CloudFront" namespace, but there is no metric attached to this namespace in CloudWatch.
Also, I suspected there is an option to enable metrics(like the one to have detailed statistics from S3) , but I did not find such option.
I prefere having all metrics inside a single dashboard, it is easier to cross data (EC2 cpu utilization vs database connection vs cloudwatch req/s for example).
Try to look in region us-east-1. You can find them there only because all CloudFront distributions are placed in us-east-1.
From there you can add them to your dashboard ;)
You can write cloudwatch dashboard template and give the region in that resource available.
Below is a sample template, In which regions are given different as per resources.
You can set x,y, width and height as you want.
``
{
"widgets": [
{
"type": "text",
"x": 0,
"y": 0,
"width": 24,
"height": 2,
"properties": {
"markdown": "\n# Resource Monitoring\n"
}
},
{
"type": "metric",
"x": 16,
"y": 2,
"width": 8,
"height": 5,
"properties": {
"metrics": [
[ "AWS/ApiGateway", "Count", "ApiName", "ApiGateway_name", { "stat": "SampleCount", "id": "m0r0" } ]
],
"region": "ap-southeast-1",
"title": "Count",
"legend": {
"position": "right"
},
"copilot": true
}
},
{
"type": "metric",
"x": 0,
"y": 31,
"width": 12,
"height": 5,
"properties": {
"metrics": [
[ "AWS/CloudFront", "Requests", "DistributionId", "gfajshgjk", "Region", "Global", { "stat": "Sum", "id": "m0r0", "label": "cf_name" } ]
],
"region": "us-east-1",
"title": "Requests",
"copilot": true
}
}
]
}
``