ImageSegmentationAnnotation Class seems to not work while giving the path to the annotations BitMaps - google-cloud-vertex-ai

I am not able to figure out correct Key, Value names to pass out bitmap labels to a Image Segmentation problem in vertex AI. My error message is below:
Error: Could not parse the line, json is invalid or the format does not match the input schema: Cannot find field: ImageSegmentationAnnotation.MaskAnnotation in message google.cloud.aiplatform.master.schema.ImageSegmentationIoFormat. for: gs://starry-embassy-363916-image/Figaro1k_json.jsonl line 3
Error: Could not parse the line, json is invalid or the format does not match the input schema: Cannot find field: ImageSegmentationAnnotation.MaskAnnotation in message
And the format of the .jsonl file I am giving is :
{"imageGcsUri": "gs://starry-embassy-363916-image/Figaro1k/Original/Training/Frame00003-org.jpg", "ImageSegmentationAnnotation.MaskAnnotation" : [{"mask_gcs_uri": "gs://starry-embassy-363916-image/Figaro1k/GT/Training/Frame00003-gt.pbm"}], "dataItemResourceLabels": {"aiplatform.googleapis.com/ml_use": "training"}}
TIA
I tried various combination of the ImageSegmentationAnnotation class as documented here:
https://cloud.google.com/vertex-ai/docs/reference/rpc/google.cloud.aiplatform.v1/schema#google.cloud.aiplatform.v1.schema.ImageSegmentationAnnotation
And here:
https://cloud.google.com/vertex-ai/docs/image-data/classification/prepare-data#json-lines_1

Related

How to remove label prefix in errors

How do I remove the prefix that is added to errors?
For example, given this error:
activerecord:
errors:
models:
my_model:
my_custom_error: Incorrect value
I'd like the input to show the error as exactly "Incorrect value". But instead SimpleForm always adds the name of the attribute as a prefix. So it shows as "my_custom_error Incorrect value".
How can I remove the prefix for some inputs?
Seems like the prefix is added here: https://github.com/heartcombo/simple_form/blob/main/lib/simple_form/components/errors.rb#L30
The label + message format comes from this I18n:
errors:
format: "%{attribute} %{message}"
So you need to redefine it to:
errors:
format: "%{message}"

How to access / address nested fields on Logstash

I am currently trying to convert a nested sub field that contains hexadecimal string to an int type field using Logstash filter
ruby{
code => 'event.set("[transactions][gasprice_int]", event.get("[transactions][gasPrice]").to_i(16))'
}
but it's returning the error
[ERROR][logstash.filters.ruby ][main][2342d24206691f4db46a60285e910d102a6310e78cf8af43c9a2f1a1d66f58a8] Ruby exception occurred: wrong number of arguments calling `to_i` (given 1, expected 0)
I also tried looping through json objects in transactions field using
transactions_num = event.get("[transactions]").size
transactions_num.times do |index|
event.set("[transactions][#{index}][gasprice_int]", event.get("[transactions][#{index}][gasPrice].to_i(16)"))
end
but this also returned an error of
[ERROR][logstash.filters.ruby ][main][99b05fdb6022cc15b0f97ba10cabb3e7c1a8fabb8e0c47d6660861badffdb28e] Ruby exception occurred: Invalid FieldReference: `[transactions][0][gasPrice].to_i(16)`
This method of conversion of hex-string to int type using a ruby filter worked when I wasn't dealing with nested fields, so can anyone please help me how to correctly address nested fields in this case?
btw,
this is the code that still works
ruby {
code => 'event.set("difficulty_int", event.get("difficulty").to_i(16))'
}
I think you have answered this one yourself in your final example - the to_i should not be inside the double quotes. So
...event.get("[transactions][#{index}][gasPrice].to_i(16)"))
should be
...event.get("[transactions][#{index}][gasPrice]").to_i(16))

How to access field value in a JSR message with spring boot 2?

I would like to customize my error message in the following way:
Assume following declaration of a class Person:
#Size(min=10, max=250, message="{size.name}")
private String name;
Within the declared error message in ValidationMessages.properties I would like to output the field value as well, i.e. I would like to do something like this:
size.name = The name '${validatedvalue}' is invalid, its size must be between {min} and {max}
Assume the content of the field 'name' is “xyz”. Then the error message should look like this:
The name 'xyz' is invalid, its size must be between 10 and 250
The substitution for min and max works, but filed value i am getting as '' ,how can I do this for the field value?

Specific Values in Json Parse

I am having difficulty getting to specific values when I parse a JSON file in Ruby. My JSON is based off of this link https://www.mcdonalds.com/services/mcd/us/restaurantLocator?latitude=40.7217861&longitude=-74.00944709999999&radius=8045&maxResults=100&country=us&language=en-us
No matter what I try I cannot pull the values I want, which is the "addressLine1" field. I get the following error:
`[]': no implicit conversion of String into Integer (TypeError)
Code
require 'json'
file = File.read('MCD.json')
data_hash = JSON.parse(file)
print data_hash.keys
print "\n"
print data_hash['features']['addressLine1']
data_hash['features'] is an array. Depending on what do you actually need, you might either iterate over it, or call:
data_hash['features'].first['properties']['addressLine1']
Note 'properties' there, since addressLine1 is not a direct descendant of 'features' elements.

InvalidSelectorException while trying to identify web element in robot framework

ign-In | FAIL |
InvalidSelectorException: Message: The given selector xpath=//*[#id='user_email'] is either invalid or does not result in a WebElement. The following error occurred:
InvalidSelectorError: Unable to locate an element with the xpath expression xpath=//*[#id='user_email'] because of the following error:
TypeError: The expression cannot be converted to return the specified type.
Stacktrace:
at FirefoxDriver.annotateInvalidSelectorError_ (file:///var/folders/5f/6mvs5x1j37s5q3_38kjfwkgr0000gn/T/tmp1Nrpuj/webdriver-py-profilecopy/extensions/fxdriver#googlecode.com/components/driver-component.js:10633)
at FirefoxDriver.prototype.findElementsInternal_ (file:///var/folders/5f/6mvs5x1j37s5q3_38kjfwkgr0000gn/T/tmp1Nrpuj/webdriver-py-profilecopy/extensions/fxdriver#googlecode.com/components/driver-component.js:10691)
at FirefoxDriver.prototype.findElements (file:///var/folders/5f/6mvs5x1j37s5q3_38kjfwkgr0000gn/T/tmp1Nrpuj/webdriver-py-profilecopy/extensions/fxdriver#googlecode.com/components/driver-component.js:10695)
at DelayedCommand.prototype.executeInternal_/h (file:///var/folders/5f/6mvs5x1j37s5q3_38kjfwkgr0000gn/T/tmp1Nrpuj/webdriver-py-profilecopy/extensions/fxdriver#googlecode.com/components/command-processor.js:12534)
at DelayedCommand.prototype.executeInternal_ (file:///var/folders/5f/6mvs5x1j37s5q3_38kjfwkgr0000gn/T/tmp1Nrpuj/webdriver-py-profilecopy/extensions/fxdriver#googlecode.com/components/command-processor.js:12539)
at DelayedCommand.prototype.execute/< (file:///var/folders/5f/6mvs5x1j37s5q3_38kjfwkgr0000gn/T/tmp1Nrpuj/webdriver-py-profilecopy/extensions/fxdriver#googlecode.com/components/command-processor.js:12481)
This part of the error message explained why :
The given selector xpath=//*[#id='user_email'] is either invalid or does not result in a WebElement.
In this case, //*[#id='user_email'] is valid XPath expression, so it must be no element matched by that XPath. That's all I can tell from the information provided.

Resources