Exemple #1
0
 def displayLabel(self, barplot, label):
     label_bool = labels_tools.labelStringToBoolean(label)
     ranges = [[x for x in l if x['ground_truth_label'] == label_bool]
               for l in self.ranges]
     dataset = PlotDataset(list(map(len, ranges)), label)
     dataset.set_color(colors_tools.get_label_color(label))
     barplot.add_dataset(dataset)
def getGroundTruth(session, dataset_id):
    query = session.query(GroundTruthAlchemy)
    query = query.filter(GroundTruthAlchemy.dataset_id == dataset_id)
    query = query.order_by(GroundTruthAlchemy.instance_id)
    res = query.all()
    labels = [labels_tools.labelStringToBoolean(r.label) for r in res]
    families = [r.family for r in res]
    return labels, families
Exemple #3
0
 def getFamiliesValues(self, label='all'):
     if label == 'all':
         indexes = range(self.ids.numInstances())
     else:
         l = labels_tools.labelStringToBoolean(label)
         indexes = [i for i in range(self.ids.numInstances()) if
                    self.labels[i] is not None and self.labels[i] == l]
     families = set([self.families[i]
                     for i in indexes if self.families[i] is not None])
     return families
def changeFamilyLabel(session, annotations_id, label, family):
    query = session.query(AnnotationsAlchemy)
    query = query.filter(AnnotationsAlchemy.label == label)
    query = query.filter(AnnotationsAlchemy.family == family)
    query = query.filter(AnnotationsAlchemy.annotations_id == annotations_id)
    instances = query.all()
    bool_label = labels_tools.labelStringToBoolean(label)
    new_label = labels_tools.labelBooleanToString(not bool_label)
    for instance in instances:
        instance.label = new_label
    session.flush()
Exemple #5
0
 def _getAnnotations(self):
     annotations_type = self.annotations_conf.annotations_type
     if annotations_type == AnnotationsTypes.none:
         labels = [None] * self.num_instances
         families = [None] * self.num_instances
         return labels, families
     if annotations_type == AnnotationsTypes.ground_truth:
         return self._getGroundTruth()
     if annotations_type == AnnotationsTypes.partial:
         labels = [None] * self.num_instances
         families = [None] * self.num_instances
         annotations = annotations_db_tools.getAnnotatedInstances(
             self.session, self.annotations_conf.annotations_id)
         for instance_id, label, family in annotations:
             index = self.indexes[instance_id]
             labels[index] = labels_tools.labelStringToBoolean(label)
             families[index] = family
         return labels, families