Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert task removal in folder-based builders (#5051)
* Add AudioClassification task * Add classification task to folder based builders * Fix tests * Minor fix * Minor fix again
- Loading branch information
1 parent
a8893e6
commit 583bb7d
Showing
8 changed files
with
79 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import copy | ||
from dataclasses import dataclass | ||
from typing import ClassVar, Dict | ||
|
||
from ..features import Audio, ClassLabel, Features | ||
from .base import TaskTemplate | ||
|
||
|
||
@dataclass(frozen=True) | ||
class AudioClassification(TaskTemplate): | ||
task: str = "audio-classification" | ||
input_schema: ClassVar[Features] = Features({"audio": Audio()}) | ||
label_schema: ClassVar[Features] = Features({"labels": ClassLabel}) | ||
audio_column: str = "audio" | ||
label_column: str = "labels" | ||
|
||
def align_with_features(self, features): | ||
if self.label_column not in features: | ||
raise ValueError(f"Column {self.label_column} is not present in features.") | ||
if not isinstance(features[self.label_column], ClassLabel): | ||
raise ValueError(f"Column {self.label_column} is not a ClassLabel.") | ||
task_template = copy.deepcopy(self) | ||
label_schema = self.label_schema.copy() | ||
label_schema["labels"] = features[self.label_column] | ||
task_template.__dict__["label_schema"] = label_schema | ||
return task_template | ||
|
||
@property | ||
def column_mapping(self) -> Dict[str, str]: | ||
return { | ||
self.audio_column: "audio", | ||
self.label_column: "labels", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
583bb7d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Show benchmarks
PyArrow==6.0.0
Show updated benchmarks!
Benchmark: benchmark_array_xd.json
Benchmark: benchmark_getitem_100B.json
Benchmark: benchmark_indices_mapping.json
Benchmark: benchmark_iterating.json
Benchmark: benchmark_map_filter.json
Show updated benchmarks!
Benchmark: benchmark_array_xd.json
Benchmark: benchmark_getitem_100B.json
Benchmark: benchmark_indices_mapping.json
Benchmark: benchmark_iterating.json
Benchmark: benchmark_map_filter.json