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

demandé il y a 5 ans240 vues
5 réponses
0
Réponse acceptée

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

répondu il y a 5 ans
0

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

répondu il y a 5 ans
0

You're welcome. Always happy to help.

Sam

répondu il y a 5 ans
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
répondu il y a 5 ans
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

répondu il y a 5 ans

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions