Cogniac / cogniac-sdk-py

Python SDK for Cogniac Public API
Apache License 2.0
5 stars 6 forks source link

subject.disassociate_media doesn't work for media with consensus #130

Closed CogniacViSean closed 2 years ago

CogniacViSean commented 2 years ago

Trying to remove some consensus media associations via the SDK, but the subject.disassociate_media call does not remove consensus associations. For example, after running this code:

cc = cogniac.CogniacConnection(tenant_id='3qn5hdqo9760')
subject = cc.get_subject('ocr_text_2uryw')
subject.disassociate_media('K7IBJSKUQUEEITUJBS3V5YN1PWA4')

The following still returns True, indicating this media is still in the subject's consensus associations:

'K7IBJSKUQUEEITUJBS3V5YN1PWA4' in {assoc['media']['media_id'] for assoc in subject.media_associations(consensus='True')}
ymtsang commented 2 years ago

Because it has focus in the association, to disassociate the media via SDK, you need to also specify the focus. For example, for the same media,

Screen Shot 2022-10-07 at 11 27 12 AM
subject.disassociate_media('K7IBJSKUQUEEITUJBS3V5YN1PWA4', focus={'box': {'x0':0, 'y0': 742, 'x1': 46, 'y1': 742+66}})

Then, the association is gone.

Screen Shot 2022-10-07 at 11 30 00 AM
CogniacViSean commented 2 years ago

This worked, hadn't tried this for consensus with focus before, thanks Ming!