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

Allow custom features #139

Merged
merged 7 commits into from
Oct 9, 2023
Merged

Conversation

carlthome
Copy link
Contributor

Trying to implement a new feature by implementing Features but unable to use it with msaf.run.process because there's a hardcoded list of feature names in _preprocess in the SegmenterInterface that's not exposed to the user (as far as I can see).

Maybe I'm missing something in the docs but think this check could simply be removed, and the try/except covers any potential problems on its own.

Bit unsure of this though. Gladly take help!

@carlthome
Copy link
Contributor Author

carlthome commented Sep 4, 2023

Additionally, I was unable to create a subclass of msaf.features.Features (trying EnCodec embeddings) to register in collection mode due to how joblib results in cleared out msaf.features_registry dicts per worker (bit of a rabbit hole this: https://joblib.readthedocs.io/en/latest/parallel.html#serialization-processes).

Added a fix on this PR.

@carlthome carlthome force-pushed the allow-custom-features branch 3 times, most recently from f353778 to 27f3534 Compare September 4, 2023 14:42
@carlthome carlthome changed the title Allow custom features of any name Allow custom features Sep 4, 2023
@urinieto
Copy link
Owner

Looks good to me. Could you make sure that the documentation is up to date for this to work? Here's the part of the documentation we should make sure it still works: https://pythonhosted.org/msaf/features.html#adding-new-features-to-msaf

After this is checked, I'll merge the PR.

@carlthome carlthome force-pushed the allow-custom-features branch 2 times, most recently from 699fe56 to 2d443dd Compare September 26, 2023 13:23
@urinieto
Copy link
Owner

Seems like tests are not passing. Will merge after this is fixed. Thanks @carlthome

@carlthome
Copy link
Contributor Author

Fix for CI failures in #143

@carlthome
Copy link
Contributor Author

Will merge after this is fixed.

Would also like to demonstrate that this actually works first, perhaps by adding a simple example to examples/

@urinieto
Copy link
Owner

urinieto commented Oct 3, 2023

Thanks! Seems like tests are still not passing, will wait before merging.

@@ -8,6 +8,7 @@ Contributors
* Keunwoo Choi <https://github.com/keunwoochoi>
* Rustam S <https://github.com/fortunto2>
* Cheng-i Wang <https://github.com/wangsix>
* Carl Thomé <https://github.com/carlthome>
Copy link
Owner

Choose a reason for hiding this comment

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

Good call! :)

@carlthome
Copy link
Contributor Author

Ready to go in now. Manually tested to work in both single file mode and collection mode.

@carlthome
Copy link
Contributor Author

Although maybe #143 should go in first to get down the size of this diff.

Copy link
Owner

@urinieto urinieto left a comment

Choose a reason for hiding this comment

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

This is great, looks much cleaner now. Thanks for documenting it too. Could you add a link to the example you created under this section of the documentation? https://github.com/urinieto/msaf/blob/main/docs/features.rst#adding-new-features-to-msaf

Once this is done, I'll merge away. Thanks!

examples/custom_feature.py Outdated Show resolved Hide resolved
For collection mode, it's not possible to add a new feature to the
feature_registry dict from the outside of MSAF. This is because the
feature_registry is cleared out per joblib worker.

By allowing
```
class MyFeature(msaf.features.Features):
    ...

msaf.run.process(...feature=MyFeature)
```
it becomes possible to add new features and run with collection mode.
@urinieto urinieto merged commit bcd0497 into urinieto:main Oct 9, 2023
3 checks passed
@carlthome carlthome deleted the allow-custom-features branch October 9, 2023 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants