forked from rai-project/mlmodelscope
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add audio classification support (#28)
* feat: Add audio classification support * chore: Update icon for TextToVideo task, updated inputTexts. inputPreview and sampleImages
- Loading branch information
1 parent
6bc9617
commit 7fbfde1
Showing
14 changed files
with
383 additions
and
140 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
49 changes: 49 additions & 0 deletions
49
...omponents/Experiment/QuickOutput/Outputs/AudioClassification/AudioClassificationOutput.js
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,49 @@ | ||
import React from 'react'; | ||
import TopPrediction from "../Classification/TopPrediction"; | ||
import "../Classification/ClassificationOutput.scss"; | ||
import PredictionExpander from "../../../../Common/PredictionExpander"; | ||
import NoPredictions from "../_Common/components/NoPredictions"; | ||
import Task from "../../../../../helpers/Task"; | ||
import OutputDuration from "../_Common/components/OutputDuration"; | ||
import DurationConverter from "../_Common/utils/DurationConverter"; | ||
import useBEMNaming from "../../../../../common/useBEMNaming"; | ||
|
||
const defaultProps = { | ||
className: "audio-classification-output", | ||
features: [] | ||
}; | ||
|
||
export default function AudioClassificationOutput(givenProps) { | ||
const props = { ...defaultProps, ...givenProps }; | ||
const { getBlock, getElement } = useBEMNaming(props.className); | ||
const task = Task.audio_classification; | ||
if (props?.trial?.results?.responses[0]?.features) { | ||
props.features = props?.trial.results.responses[0].features; | ||
} | ||
|
||
const getPredictionBody = () => { | ||
if (props.features.length > 0) | ||
return <div className={getElement('predictions')}> | ||
<TopPrediction hideRating={props.hideRating} feature={props.features[0]} /> | ||
<PredictionExpander predictions={props.features} /> | ||
</div>; | ||
|
||
return <NoPredictions modelId={props.modelId} />; | ||
}; | ||
return ( | ||
<> | ||
|
||
<div className={getBlock()}> | ||
<div className={getElement("title-row")}> | ||
<h3 className={getElement('title')}>Output</h3> | ||
{!props.hideDuration && | ||
<OutputDuration duration={DurationConverter(props.trial.results.duration)} /> | ||
} | ||
</div> | ||
<div className={getElement('subtitle')}>{task.outputText} | ||
</div> | ||
{getPredictionBody()} | ||
</div> | ||
</> | ||
); | ||
} |
14 changes: 14 additions & 0 deletions
14
...s/Experiment/QuickOutput/Outputs/AudioClassification/AudioClassificationOutput.stories.js
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,14 @@ | ||
import React from "react"; | ||
import AudioClassificationOutput from "./AudioClassificationOutput"; | ||
import { TestAudioClassificationOutput } from "./testData/testAudioClassification"; | ||
import QuickOutput from "../../QuickOutput"; | ||
|
||
export default { | ||
title: "Experiments/Quick Output/Audio Classification", | ||
component: AudioClassificationOutput, | ||
}; | ||
|
||
const template = (args) => <QuickOutput {...args} />; | ||
|
||
export const Default = template.bind({}); | ||
Default.args = { trialOutput: TestAudioClassificationOutput, hideHeader: true }; |
51 changes: 51 additions & 0 deletions
51
...ts/Experiment/QuickOutput/Outputs/AudioClassification/testData/testAudioClassification.js
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,51 @@ | ||
import { DefaultAudioClassificationModel } from "../../../../../../helpers/DefaultModels"; | ||
|
||
export const TestAudioClassificationOutputGeneratedToken = { | ||
id: "sampleidhere" | ||
}; | ||
|
||
export const TestAudioClassificationOutput = { | ||
id: "sampletestaudioclassificationoutputidhere", | ||
inputs: [ | ||
{ | ||
title: "audio1.flac", | ||
src: "https://xlab1.netlify.app/audio-to-audio-input.flac" | ||
}, | ||
], | ||
completed_at: "2023-06-03T18:17:14.513854Z", | ||
results: { | ||
'duration': "9.216154124s", | ||
'duration_for_inference': "9.193807904s", | ||
'responses': [ | ||
{ | ||
|
||
'features': | ||
[ | ||
{ | ||
classification: { | ||
label: 'eng' | ||
}, | ||
"probability": 0.9846002459526062 | ||
}, | ||
{ | ||
classification: { | ||
"label": "lat" | ||
}, | ||
"probability": 0.012036120519042015 | ||
|
||
}, | ||
{ | ||
classification: { | ||
"label": "frn" | ||
}, | ||
"probability": 0.0033636766020208597 | ||
} | ||
|
||
], | ||
'id': "sampletestaudioclassificationoutputresponseidhere" | ||
} | ||
] | ||
}, | ||
model: DefaultAudioClassificationModel, | ||
}; | ||
|
2 changes: 1 addition & 1 deletion
2
src/components/Experiment/QuickOutput/Outputs/Classification/ClassificationOutput.scss
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
Oops, something went wrong.