Skip to content

Commit

Permalink
Merge pull request #2 from siesto1elemento/my-feature-branch
Browse files Browse the repository at this point in the history
fix for adding multiple attributes
  • Loading branch information
siesto1elemento authored Sep 12, 2024
2 parents 91fa0df + f0ae2fd commit 613ccd3
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 49 deletions.
28 changes: 21 additions & 7 deletions cvat/apps/dataset_manager/formats/LibriVox.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,26 @@ def load_anno(file_object, annotations):
language_id_to_locale_mapping = {0: "en"}
language_id = int(record.get("language", 0))

spec_id = label_data._get_attribute_id(label_id, record.get("attribute_1_name"))
attributes = []

for i in range(1, len(headers)):
attribute_name_key = f"attribute_{i}_name"
attribute_value_key = f"attribute_{i}_value"

if attribute_name_key in record and attribute_value_key in record:
attribute_name = record.get(attribute_name_key)
attribute_value = record.get(attribute_value_key)

if attribute_name and attribute_value:

spec_id = label_data._get_attribute_id(label_id, attribute_name)

attributes.append(
{
"spec_id": spec_id,
"value": attribute_value,
}
)

shapes_data = [
{
Expand All @@ -62,12 +81,7 @@ def load_anno(file_object, annotations):
"emotion": record.get("emotion", ""),
"rotation": 0.0,
"label_id": label_id,
"attributes": [
{
"spec_id": spec_id,
"value": record.get("attribute_1_value", ""),
}
],
"attributes": attributes,
}
]

Expand Down
28 changes: 21 additions & 7 deletions cvat/apps/dataset_manager/formats/VCTK_Corpus.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,26 @@ def load_anno(file_object, annotations):
language_id_to_locale_mapping = {0: "en"}
language_id = int(record.get("language", 0))

spec_id = label_data._get_attribute_id(label_id, record.get("attribute_1_name"))
attributes = []

for i in range(1, len(headers)):
attribute_name_key = f"attribute_{i}_name"
attribute_value_key = f"attribute_{i}_value"

if attribute_name_key in record and attribute_value_key in record:
attribute_name = record.get(attribute_name_key)
attribute_value = record.get(attribute_value_key)

if attribute_name and attribute_value:

spec_id = label_data._get_attribute_id(label_id, attribute_name)

attributes.append(
{
"spec_id": spec_id,
"value": attribute_value,
}
)

shapes_data = [
{
Expand All @@ -62,12 +81,7 @@ def load_anno(file_object, annotations):
"emotion": record.get("emotion", ""),
"rotation": 0.0,
"label_id": label_id,
"attributes": [
{
"spec_id": spec_id,
"value": record.get("attribute_1_value", ""),
}
],
"attributes": attributes,
}
]

Expand Down
28 changes: 21 additions & 7 deletions cvat/apps/dataset_manager/formats/VoxCeleb.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,26 @@ def load_anno(file_object, annotations):
language_id_to_locale_mapping = {0: "en"}
language_id = int(record.get("language", 0))

spec_id = label_data._get_attribute_id(label_id, record.get("attribute_1_name"))
attributes = []

for i in range(1, len(headers)):
attribute_name_key = f"attribute_{i}_name"
attribute_value_key = f"attribute_{i}_value"

if attribute_name_key in record and attribute_value_key in record:
attribute_name = record.get(attribute_name_key)
attribute_value = record.get(attribute_value_key)

if attribute_name and attribute_value:

spec_id = label_data._get_attribute_id(label_id, attribute_name)

attributes.append(
{
"spec_id": spec_id,
"value": attribute_value,
}
)

shapes_data = [
{
Expand All @@ -62,12 +81,7 @@ def load_anno(file_object, annotations):
"emotion": record.get("emotion", ""),
"rotation": 0.0,
"label_id": label_id,
"attributes": [
{
"spec_id": spec_id,
"value": record.get("attribute_1_value", ""),
}
],
"attributes": attributes,
}
]

Expand Down
28 changes: 21 additions & 7 deletions cvat/apps/dataset_manager/formats/Voxpopuli.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,26 @@ def load_anno(file_object, annotations):
language_id_to_locale_mapping = {0: "en"}
language_id = int(record.get("language", 0))

spec_id = label_data._get_attribute_id(label_id, record.get("attribute_1_name"))
attributes = []

for i in range(1, len(headers)):
attribute_name_key = f"attribute_{i}_name"
attribute_value_key = f"attribute_{i}_value"

if attribute_name_key in record and attribute_value_key in record:
attribute_name = record.get(attribute_name_key)
attribute_value = record.get(attribute_value_key)

if attribute_name and attribute_value:

spec_id = label_data._get_attribute_id(label_id, attribute_name)

attributes.append(
{
"spec_id": spec_id,
"value": attribute_value,
}
)

shapes_data = [
{
Expand All @@ -62,12 +81,7 @@ def load_anno(file_object, annotations):
"emotion": record.get("emotion", ""),
"rotation": 0.0,
"label_id": label_id,
"attributes": [
{
"spec_id": spec_id,
"value": record.get("attribute_1_value", ""),
}
],
"attributes": attributes,
}
]

Expand Down
28 changes: 21 additions & 7 deletions cvat/apps/dataset_manager/formats/common_voice.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,26 @@ def load_anno(file_object, annotations):
language_id_to_locale_mapping = {0: "en"}
language_id = int(record.get("language", 0))

spec_id = label_data._get_attribute_id(label_id, record.get("attribute_1_name"))
attributes = []

for i in range(1, len(headers)):
attribute_name_key = f"attribute_{i}_name"
attribute_value_key = f"attribute_{i}_value"

if attribute_name_key in record and attribute_value_key in record:
attribute_name = record.get(attribute_name_key)
attribute_value = record.get(attribute_value_key)

if attribute_name and attribute_value:

spec_id = label_data._get_attribute_id(label_id, attribute_name)

attributes.append(
{
"spec_id": spec_id,
"value": attribute_value,
}
)

shapes_data = [
{
Expand All @@ -62,12 +81,7 @@ def load_anno(file_object, annotations):
"emotion": record.get("emotion", ""),
"rotation": 0.0,
"label_id": label_id,
"attributes": [
{
"spec_id": spec_id,
"value": record.get("attribute_1_value", ""),
}
],
"attributes": attributes,
}
]

Expand Down
28 changes: 21 additions & 7 deletions cvat/apps/dataset_manager/formats/librispeech.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,26 @@ def load_anno(file_object, annotations):
label_name = record.get("label")
label_id = label_data._get_label_id(label_name)

spec_id = label_data._get_attribute_id(label_id, record.get("attribute_1_name"))
attributes = []

for i in range(1, len(headers)):
attribute_name_key = f"attribute_{i}_name"
attribute_value_key = f"attribute_{i}_value"

if attribute_name_key in record and attribute_value_key in record:
attribute_name = record.get(attribute_name_key)
attribute_value = record.get(attribute_value_key)

if attribute_name and attribute_value:

spec_id = label_data._get_attribute_id(label_id, attribute_name)

attributes.append(
{
"spec_id": spec_id,
"value": attribute_value,
}
)

language_id_to_locale_mapping = {0: "en"}
language_id = int(record.get("language", 0))
Expand All @@ -62,12 +81,7 @@ def load_anno(file_object, annotations):
"emotion": record.get("emotion", ""),
"rotation": 0.0,
"label_id": label_id,
"attributes": [
{
"spec_id": spec_id,
"value": record.get("attribute_1_value", ""),
}
],
"attributes": attributes,
}
]

Expand Down
28 changes: 21 additions & 7 deletions cvat/apps/dataset_manager/formats/tedlium.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,26 @@ def load_anno(file_object, annotations):
language_id_to_locale_mapping = {0: "en"}
language_id = int(record.get("language", 0))

spec_id = label_data._get_attribute_id(label_id, record.get("attribute_1_name"))
attributes = []

for i in range(1, len(headers)):
attribute_name_key = f"attribute_{i}_name"
attribute_value_key = f"attribute_{i}_value"

if attribute_name_key in record and attribute_value_key in record:
attribute_name = record.get(attribute_name_key)
attribute_value = record.get(attribute_value_key)

if attribute_name and attribute_value:

spec_id = label_data._get_attribute_id(label_id, attribute_name)

attributes.append(
{
"spec_id": spec_id,
"value": attribute_value,
}
)

shapes_data = [
{
Expand All @@ -62,12 +81,7 @@ def load_anno(file_object, annotations):
"emotion": record.get("emotion", ""),
"rotation": 0.0,
"label_id": label_id,
"attributes": [
{
"spec_id": spec_id,
"value": record.get("attribute_1_value", ""),
}
],
"attributes": attributes,
}
]

Expand Down

0 comments on commit 613ccd3

Please sign in to comment.