Customizing the Keypoint Template

0

I've gone through the whole process and have successfully created and received results for an image landmarking task using the crowd-keypoint element and template. However, looking at my results, there are things I'd like to restrict to guarantee cleaner data:

  1. I'd like to make every keypoint label required (i.e. task cannot be submitted if a label is missing)

  2. I'd like to make every keypoint restricted to one instance (right now, task can be submitted with multiple instances of the same label and I only need one very specific point landmarked for each label); ideally a new placement of a point removes the old instance or gives an error message

Does anyone know if it is possible and how to do these types of restrictions with the Keypoint Template?

Edited by: MaimoOKF on Jul 30, 2019 2:46 PM

Edited by: MaimoOKF on Jul 30, 2019 2:47 PM

已提问 5 年前240 查看次数
5 回答
0
已接受的回答

Hello,

This should suit your use case. On submit, it validates that each label was used once and only once.

Here's a working JSFiddle for you to demo it https://jsfiddle.net/01jpzs2n/

<script src="https://assets.crowd.aws/crowd-html-elements.js"></script>

<crowd-form>
  <div id="errorBox"></div>
   
  <crowd-keypoint
    src="https://s3.amazonaws.com/cv-demo-images/ken-griffey-jr.jpg"
    labels="['Item A', 'Item B', 'Item C']"        
    header="Please locate the centers of each item."
    name="annotatedResult">
    <short-instructions>
      Describe your task briefly here and give examples
    </short-instructions>
    <full-instructions>
      Give additional instructions and good/bad examples here
    </full-instructions>   
  </crowd-keypoint>
</crowd-form>

<script>
  var num_obj = 1;
  document.querySelector('crowd-form').onsubmit = function(e) {
    const keypoints = document.querySelector('crowd-keypoint').value.keypoints || document.querySelector('crowd-keypoint')._submittableValue.keypoints;
    const labels = keypoints.map(function(p) {
      return p.label;
    });
    // 1. Make sure total number of keypoints is correct.
    var original_num_labels = document.getElementsByTagName("crowd-keypoint")[0].getAttribute("labels");
    original_num_labels = original_num_labels.substring(2, original_num_labels.length - 2).split("\",\"");
    var goalNumKeypoints = num_obj*original_num_labels.length;
    if (keypoints.length != goalNumKeypoints) {
      e.preventDefault();
      errorBox.innerHTML = '<crowd-alert type="error" dismissible>You must add all keypoint annotations and use each label only once.</crowd-alert>';
      errorBox.scrollIntoView();
      return;
    }
    // 2. Make sure all labels are unique.
    labelCounts = {};
    for (var i = 0; i < labels.length; i++) {
      if (!labelCounts[labels[i]]) {
        labelCounts[labels[i]] = 0;
      }
      labelCounts[labels[i]]++;
    }
    const goalNumSingleLabel = num_obj;
    const numLabels = Object.keys(labelCounts).length;
    Object.entries(labelCounts).forEach(entry => {
      if (entry[1] != goalNumSingleLabel) {
        e.preventDefault();
        errorBox.innerHTML = '<crowd-alert type="error" dismissible>You must use each label only once.</crowd-alert>';
        errorBox.scrollIntoView();
      }
    })
  };
</script>

Please let us know if you have any additional questions.

Thank you,
Sam

已回答 5 年前
0

Tried this out in the sandbox, and it looks great.
Thanks, Sam. You are always posting awesome replies.

已回答 5 年前
0

You're welcome. Always happy to help.

Sam

已回答 5 年前
0

Hello,

I have a similar question. I have been trying to combine the Keypoint Crowd HTML Element with the bouding box one.  
My goal is to have a keypoint that has an additional resource: a bounding box.  
(I guess a more general question here would be: how to merge or combine Crowd HTML Elements?)  
 Thank you and have a wonderful day!
feliott
已回答 5 年前
0

Hello,

Unfortunately there currently is not a way to have the worker draw keypoints and bounding boxes at the same time on the same image.

You could post two separate tasks for this.

Or, you could use our polygon template (select Polygon on https://requester.mturk.com/create/projects/new). In this use case the worker draws connected keypoints, which form a closed polygon.

Would this help?

Additional documentation:

https://docs.aws.amazon.com/sagemaker/latest/dg/sms-ui-template-crowd-polygon.html

Thank you
Sam

已回答 5 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则