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

Setup_audio #322

Merged
merged 65 commits into from
Feb 8, 2024
Merged

Setup_audio #322

merged 65 commits into from
Feb 8, 2024

Conversation

monke6942021
Copy link
Contributor

Croissant can now recognize sc:AudioObject types, but can't pull any relevant data.

@monke6942021 monke6942021 requested a review from a team as a code owner November 8, 2023 17:28
Copy link

github-actions bot commented Nov 8, 2023

MLCommons CLA bot All contributors have signed the MLCommons CLA ✍️ ✅

Copy link
Contributor

@marcenacp marcenacp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Do you have a dataset to test this?

requirements.txt Outdated
@@ -0,0 +1,27 @@
absl-py==1.4.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use requirements.txt, but pyproject.toml to manage dependencies.

@@ -28,6 +28,9 @@ def check_expected_type(issues: Issues, jsonld: Json, expected_type: str):
constants.SCHEMA_ORG_DATA_TYPE_IMAGE_OBJECT: (
constants.SCHEMA_ORG_DATA_TYPE_IMAGE_OBJECT
),
constants.SCHEMA_ORG_DATA_TYPE_AUDIO_OBJECT: (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this has changed. Can you rebase to have a freshest version of the code?

git pull --rebase origin main

@monke6942021
Copy link
Contributor Author

Thanks! Do you have a dataset to test this?

I just added the one that I've been using for testing. It's a mini-version of what I finally want to do with croissant, but maybe the 0-hz-immersion-into-wallbient directory can be used as another test if we want it to operate without looking into multiple directories.

Copy link
Contributor

@marcenacp marcenacp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the dataset. My remarks:

  • The dataset should probably be added to the non-hermetic unit tests. Like this, we'll make sure we won't have any regression on audio.
  • Is it possible to not commit the *.mp3 and rather host them somewhere? Otherwise, it could make the repo heavier.
  • Could you address the previous reviews? (E.g., rebase your code and do not commit the requirements.txt file).

Thanks!

@monke6942021
Copy link
Contributor Author

monke6942021 commented Nov 16, 2023

Hi! I added the dataset to the non-hermetic tests, and I'm also hosting the dataset from a Google Drive, which I shared with you and Tim. Also, sorry about the problem with the rebase. I thought I rebased it when I added the dataset, but I did not complete the process. I have now rebased the branch and synced the changes. I hope it works properly now. I also removed the requirements.txt file.

Also, would it be possible to get some Documentation on how different datatypes get pulled. I ask because one thing I've noticed is that ImageObjects get pulled in a different manner than something like a text file. I've been trial and erroring my way through the process, but I could use some clarification on how different datatypes get pulled.

Thanks!

@monke6942021 monke6942021 self-assigned this Jan 11, 2024
@monke6942021
Copy link
Contributor Author

I passed the tests. Is there anything else I should do?

"audio_test/metadata.json",
"records",
-1,
], # Switch the number to 10 if nessacary
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

necessary

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just removed it.

@@ -86,5 +86,10 @@ def PIL_Image(cls) -> types.ModuleType: # pylint: disable=invalid-name
"""Cached git module."""
return _try_import("PIL.Image", package_name="Pillow")

@cached_class_property
def LIB_Audio(cls) -> types.ModuleType: # pylint: disable=invalid-name
"""Cached git module."""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cached librosa module

@@ -31,6 +31,9 @@ def _cast_value(value: Any, data_type: type | term.URIRef | None):
return deps.PIL_Image.open(io.BytesIO(value))
else:
raise ValueError(f"Type {type(value)} is not accepted for an image.")
elif data_type == DataType.AUDIO_OBJECT:
output = deps.LIB_Audio.load(io.BytesIO(value))
return str([output[0].tolist(), output[1]])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why a str? How will you use this in an ML pipeline? What would be the most useful signal to return here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did it like that because the output needs to have double quotes. I'm about to push a version that just outputs the regular librosa output, but I don't know if it will pass the test.

@@ -18,6 +19,7 @@ authors = [
# pip dependencies of the project
# Installed locally with `pip install -e .`
dependencies = [
"black[jupyter]",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove jupyter?

@marcenacp marcenacp mentioned this pull request Jan 15, 2024
@@ -86,5 +86,10 @@ def PIL_Image(cls) -> types.ModuleType: # pylint: disable=invalid-name
"""Cached git module."""
return _try_import("PIL.Image", package_name="Pillow")

@cached_class_property
def LIB_Audio(cls) -> types.ModuleType: # pylint: disable=invalid-name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

def librosa (PIL.Image above is a library, so the name here should probably be librosa)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just changed the name, and the usage in field.py

@monke6942021 monke6942021 merged commit 4f2e86f into main Feb 8, 2024
14 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Feb 8, 2024
@monke6942021 monke6942021 deleted the setup_audio branch February 8, 2024 08:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants