Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Annotation existing Classification(s) fields with Label studio #4779

Open
ehofesmann opened this issue Sep 9, 2024 · 0 comments
Open
Labels
annotation Issues related to FiftyOne's annotation API bug Bug fixes

Comments

@ehofesmann
Copy link
Member

Describe the problem

As mentioned here: #4725 (review)

There seem to be bugs when working with existing Classification and now Classifications fields that are uploaded to labelstudio.

Code to reproduce issue

import fiftyone as fo
import fiftyone.zoo as foz

dataset = foz.load_zoo_dataset("quickstart")[:10].clone()

sample = dataset.first()
sample["clss"] = fo.Classification(label="test")
sample.save()

dataset.annotate("test", label_field="clss", backend="labelstudio", launch_editor=True)
  1. After opening the labelstudio project, the first issue is that it seems that the predictions for samples with the classification label is set properly, but other samples have null predictions which may be causing some errors loading the samples in the labelstudio app.

Ex:
image
image
image

  1. Then when going to label all tasks, the existing classification is not selected as it should be (this seems to also occur with detections, so this part may be expected):
    image

  2. Then after labeling a subset of the samples and going to load annotations in FiftyOne, this error message is raised:

File ~/work/fiftyone/fiftyone/fiftyone/core/collections.py:9016, in SampleCollection.load_annotations(self, anno_key, dest_field, unexpected, cleanup, progress, **kwargs)                                                                                                                                                                 
   8971 def load_annotations(                                                                                                                                                                                                                                                                                                              
   8972     self,                                                                                                                                                                                                                                                                                                                          
   8973     anno_key,                                                                                                                                                                                                                                                                                                                      
   (...)                                                                                                                                                                                                                                                                                                                                   
   8978     **kwargs,                                                                                                                                                                                                                                                                                                                      
   8979 ):                                                                                                                                                                                                                                                                                                                                 
   8980     """Downloads the labels from the given annotation run from the                                                                                                                                                                                                                                                                 
   8981     annotation backend and merges them into this collection.                                                                                                                                                                                                                                                                       
   8982                                                                                                                                                                                                                                                                                                                                    
   (...)                                                                                                                                                                                                                                                                                                                                   
   9014         found, in which case a dict containing the extra labels is returned                                                                                                                                                                                                                                                        
   9015     """                                                                                                                                                                                                                                                                                                                            
-> 9016     return foua.load_annotations(                                                                                                                                                                                                                                                                                                  
   9017         self,                                                                                                                                                                                                                                                                                                                      
   9018         anno_key,                                                                                                                                                                                                                                                                                                                  
   9019         dest_field=dest_field,                                                                                                                                                                                                                                                                                                     
   9020         unexpected=unexpected,                                                                                                                                                                                                                                                                                                     
   9021         cleanup=cleanup,                                                                                                                                                                                                                                                                                                           
   9022         progress=progress,                                                                                                                                                                                                                                                                                                         
   9023         **kwargs,                                                                                                                                                                                                                                                                                                                  
   9024     )                                                                                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                                                                                                           
File ~/work/fiftyone/fiftyone/fiftyone/utils/annotations.py:1038, in load_annotations(samples, anno_key, dest_field, unexpected, cleanup, progress, **kwargs)                                                                                                                                                                              
   1036 dataset = samples._root_dataset                                                                                                                                                                                                                                                                                                    
   1037 results = dataset.load_annotation_results(anno_key, **kwargs)                                                                                                                                                                                                                                                                      
-> 1038 annotations = results.backend.download_annotations(results)                                                                                                                                                                                                                                                                        
   1039 label_schema = results.config.label_schema                                                                                                                                                                                                                                                                                         
   1040 is_clips_view = results._is_clips                                                                                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                                                                                                           
File ~/work/fiftyone/fiftyone/fiftyone/utils/labelstudio.py:158, in LabelStudioBackend.download_annotations(self, results)                                                                                                                                                                                                                 
    155 api = self.connect_to_api()                                                                                                                                                                                                                                                                                                        
    157 logger.info("Downloading labels from Label Studio...")                                                                                                                                                                                                                                                                             
--> 158 annotations = api.download_annotations(results)                                                                                                                                                                                                                                                                                    
    159 logger.info("Download complete")                                                                                                                                                                                                                                                                                                   
    161 return annotations                                                                                                                                                                                                                                                                                                                 
                                                                                                                                                                                                                                                                                                                                           
File ~/work/fiftyone/fiftyone/fiftyone/utils/labelstudio.py:486, in LabelStudioAnnotationAPI.download_annotations(self, results)                                                                                                                                                                                                           
    482 labeled_tasks = self._get_matched_labeled_tasks(                                                                                                                                                                                                                                                                                   
    483     project, list(results.uploaded_tasks.keys())                                                                                                                                                                                                                                                                                   
    484 )                                                                                                                                                                                                                                                                                                                                  
    485 annotations = {}                                                                                                                                                                                                                                                                                                                   
--> 486 all_labels = self._import_annotations(                                                                                                                                                                                                                                                                                             
    487     labeled_tasks, results.uploaded_tasks                                                                                                                                                                                                                                                                                          
    488 )                                                                                                                                                                                                                                                                                                                                  
    489 annotations = defaultdict(lambda: defaultdict(dict))                                                                                                                                                                                                                                                                               
    490 for task_id, task_labels in all_labels.items():                                                                                                                                                                                                                                                                                    
                                                                                                                                                                     
File ~/work/fiftyone/fiftyone/fiftyone/utils/labelstudio.py:407, in LabelStudioAnnotationAPI._import_annotations(self, tasks, task_map)                              
    401 result_kps = [                                                                                                                                               
    402     r for r in latest_result if _result_type(r) == "keypointlabels"                                                                                          
    403 ]                                                                                                                                                            
    404 result_not_kps = [                                                                                                                                           
    405     r for r in latest_result if _result_type(r) != "keypointlabels"                                                                                          
    406 ]                                                                                                                                                            
--> 407 labels = [                                                                                                                                                   
    408     import_label_studio_annotation(r) for r in result_not_kps                                                                                                
    409 ]                                                                                                                                                            
    410 if result_kps:                                                                                                                                               
    411     labels += [import_label_studio_annotation(result_kps)]                                                                                                   
                                                                                                                                                                     
File ~/work/fiftyone/fiftyone/fiftyone/utils/labelstudio.py:408, in <listcomp>(.0)                                                                                   
    401 result_kps = [                                                                                                                                               
    402     r for r in latest_result if _result_type(r) == "keypointlabels"                                                                                          
    403 ]                                                                                                                                                            
    404 result_not_kps = [                                                                                                                                           
    405     r for r in latest_result if _result_type(r) != "keypointlabels"                                                                                          
    406 ]                                                                                                                                                            
    407 labels = [                                                                                                                                                   
--> 408     import_label_studio_annotation(r) for r in result_not_kps                                                                                                
    409 ]                                                                                                                                                            
    410 if result_kps:                                                                                                                                               
    411     labels += [import_label_studio_annotation(result_kps)]                                                                                                   
                                                                                                                                                                     
File ~/work/fiftyone/fiftyone/fiftyone/utils/labelstudio.py:672, in import_label_studio_annotation(result)                                                           
    670     label = _from_number(result)                                                                                                                             
    671 else:                                                                                                                                                        
--> 672     raise ValueError("Unable to import %s from Label Studio" % ls_type)                                                                                      
    674 try:                                                                                                                                                         
    675     label_id = result["id"]                                                                                                                                  
                                                                                                                                                                     
ValueError: Unable to import None from Label Studio        

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 22.04): ubuntu 22.04
  • Python version (python --version): 3.10.13
  • FiftyOne version (fiftyone --version): 0.25.0
  • FiftyOne installed from (pip or source): source
@ehofesmann ehofesmann added bug Bug fixes annotation Issues related to FiftyOne's annotation API labels Sep 9, 2024
@ehofesmann ehofesmann changed the title [BUG] [BUG] Annotation existing Classification(s) fields with Label studio Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
annotation Issues related to FiftyOne's annotation API bug Bug fixes
Projects
None yet
Development

No branches or pull requests

1 participant