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

recipes for ICASSP #120

Merged
merged 12 commits into from
Nov 29, 2022
Merged

recipes for ICASSP #120

merged 12 commits into from
Nov 29, 2022

Conversation

jwillbailey
Copy link
Contributor

recipes for ICASSP

@jwillbailey jwillbailey linked an issue Nov 22, 2022 that may be closed by this pull request
@codecov
Copy link

codecov bot commented Nov 22, 2022

Codecov Report

Merging #120 (09209ab) into main (00d29ca) will decrease coverage by 0.00%.
The diff coverage is 88.63%.

@@            Coverage Diff             @@
##             main     #120      +/-   ##
==========================================
- Coverage   85.19%   85.19%   -0.01%     
==========================================
  Files          32       37       +5     
  Lines        3782     3802      +20     
==========================================
+ Hits         3222     3239      +17     
- Misses        560      563       +3     
Impacted Files Coverage Δ
clarity/evaluator/hasqi/hasqi.py 84.21% <84.21%> (ø)
clarity/evaluator/haspi/eb.py 88.39% <91.66%> (+0.03%) ⬆️
clarity/evaluator/hasqi/__init__.py 100.00% <100.00%> (ø)
clarity/enhancer/dsp/filter.py 98.30% <0.00%> (-1.70%) ⬇️
clarity/enhancer/dnn/mc_conv_tasnet.py 89.65% <0.00%> (-0.41%) ⬇️
clarity/predictor/torch_msbg.py 79.83% <0.00%> (-0.17%) ⬇️
clarity/evaluator/msbg/msbg_utils.py 83.06% <0.00%> (ø)
clarity/__init__.py 100.00% <0.00%> (ø)
clarity/evaluator/haaqi/__init__.py 100.00% <0.00%> (ø)
... and 2 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@jonbarker68 jonbarker68 changed the title Added combined haspi/hasqi evaluator recipes for ICASSP Nov 22, 2022
Copy link
Contributor

@ns-rse ns-rse left a comment

Choose a reason for hiding this comment

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

The README.md (or a copy of the text) could be placed as a document under docs/icassp2023.md and then in docs/index.rst it could be referenced with...

Welcome to pyClarity's documentation!
=====================================

.. toctree::
    :maxdepth: 1
    :caption: Getting Started

    introduction
    installation
    usage
    icassp2023

with the last line being the addition, any name can be used for the Markdown just need to match the relative path and filename in the index.rst and omit the .md.

These pages are then built automatically by a GitHub action (which I'm about to revise to only run on tagged releases) and are visible at https://claritychallenge.org/clarity/

Copy link
Contributor

@ns-rse ns-rse left a comment

Choose a reason for hiding this comment

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

Can't comment much on what is being done but may want to consider using the pathlib library over os (I find it much more intuitive and easier to use).

A few suggestions on some variable names and places where f-strings could perhaps be used in the logging.

@@ -0,0 +1,65 @@
import json
import logging
import os
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps just preference based on experience but I find pathlib to be more intuitive and readable and generally easier to use than os.

Suggested change
import os
import pathlib

Copy link
Contributor

Choose a reason for hiding this comment

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

I also prefer pathlib over os.
Is an object-oriented library for working with paths.
Pathlib has nice things like mkdir that make the parents and validate if exist

Path('test_dir').mkdir(exist_ok=True, parents=True)


@hydra.main(config_path=".", config_name="config")
def enhance(cfg: DictConfig) -> None:
enhanced_folder = os.path.join(cfg.path.exp_folder, "enhanced_signals")
Copy link
Contributor

Choose a reason for hiding this comment

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

With pathlib this would I think become.

enhanced_folder = Path(cfg.path.exp_folder) / "enhanced_signals"
enchanced_folder.mkdir(parents=True, exist_ok=True)

The parents=True is of course optional but it will then create any parent directories defined in cfg.path.exp_folder that don't exist.

logger.warning(f"Writing {filename}: {n_clipped} samples clipped")
np.clip(enhanced, -1.0, 1.0, out=enhanced)
signal_16 = (32768.0 * enhanced).astype(np.int16)
wavfile.write(os.path.join(enhanced_folder, filename), fs, signal_16)
Copy link
Contributor

Choose a reason for hiding this comment

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

If switching to using pathlib this would become...

Suggested change
wavfile.write(os.path.join(enhanced_folder, filename), fs, signal_16)
wavfile.write(enhanced_folder / filename, fs, signal_16)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, a much cleaner code

import hashlib
import json
import logging
import os
Copy link
Contributor

Choose a reason for hiding this comment

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

As with enhance.py the pathlib module could be used.

score_dict = read_csv_scores(unproc_si_file)
ave_score = np.mean(list(score_dict.values()))
logger.info(
"si_unproc.csv exists, and the average HASPI scores for unprocessed scenes is {:.4f}".format(
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be an f-string as in other logging statements, would take the form...

Suggested change
"si_unproc.csv exists, and the average HASPI scores for unprocessed scenes is {:.4f}".format(
f"si_unproc.csv exists, and the average HASPI scores for unprocessed scenes is {mean_score:.4f}"

(accounting for above suggestion(s) on variable name.

Copy link
Contributor

Choose a reason for hiding this comment

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

f-strings are more clear than .format(), especially when you have several variables in the same string.

for line in csv_lines:
csv_writer.writerow(line)
score_dict = read_csv_scores(si_file)
ave_score = np.mean(list(score_dict.values()))
Copy link
Contributor

Choose a reason for hiding this comment

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

There are three types of averages (mean, median and mode) as this is the mean we can be explicit...

Suggested change
ave_score = np.mean(list(score_dict.values()))
mean_score = np.mean(list(score_dict.values()))

(Sorry I used to be a statistician).

for line in unproc_csv_lines:
csv_writer.writerow(line)
score_dict = read_csv_scores(unproc_si_file)
ave_score = np.mean(list(score_dict.values()))
Copy link
Contributor

Choose a reason for hiding this comment

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

As above could use mean_score to be explicit about what the value is.

score_dict = read_csv_scores(si_file)
ave_score = np.mean(list(score_dict.values()))
logger.info(
"si.csv exists, and the average combined score is {:.4f}".format(ave_score)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can be an f-string...

Suggested change
"si.csv exists, and the average combined score is {:.4f}".format(ave_score)
f"si.csv exists, and the average combined score is {mean_score:.4f}"

...takes into account suggestion about mean.

@jonbarker68
Copy link
Contributor

@ns-rse re the README.md: the README.md files have a special purpose in GitHub, i.e. they are displayed as you browse the source code. I think this is particularly important for the 'recipes' because i) we can then provide links to the GitHub recipe directories as landing pages for the challenges and ii) people can very easy see what is what as they navigate through the recipes sources on github.

Note, the other recipes, i.e. CEC1, CPC1, CEC2 have these README's and it is similar to other toolkits, e.g. asteroid, where the recipes appear in the egs/ dir, https://github.com/asteroid-team/asteroid/tree/master/egs

Is it possible to get the best of both by having the documentation build from the README.md files rather than from docs/ subdirectories?

@jwillbailey
Copy link
Contributor Author

jwillbailey commented Nov 22, 2022 via email

@jonbarker68
Copy link
Contributor

@jwillbailey - please just fix the issues in the ICASSP recipe and commit this. We can then raise a separate issue if we want to go back and change old recipes and make them consistent. I'm not saying that isn't worth doing, but it's not good if the PR for the ICASSP recipe touches all recipes. This will cause confusion later. The PRs should be linked to well-defined issues and be small where possible. Thx!

@ns-rse
Copy link
Contributor

ns-rse commented Nov 23, 2022

@jonbarker68 I'll look into including the README.md from the recipes and adding them to the GitHub Pages.

@jwillbailey I agree with @jonbarker68 about keeping the PR focused. Switching other recipes to use pathlib should indeed be a separate issue.

For ICASSP2023 the hearing aid amplification needs to
be done as part of evaluate.py. Also no need to have
a switch for evaluating the unprocessed signals as this
is what the baseline enhance.py does in anycase.

This code still needs tidying up.
@jonbarker68
Copy link
Contributor

@TuZehai - could you have a quick look at the recipes/icassp_2023 please? We need to release it Tuesday for the ICASSP challenge. The evaluate.py now has a fixed hearing aid amplifier and HASPI/HASQI scorer. It seems to be producing sensible scores but it would be good if you could check that it looks correct. The HA amplifier should be the same as we used as the baseline in CEC2. The enhance.py is just dummy code that takes the front mic pair and is the bit that entrants will need to replace. I've tried to make it reasonably clear how they would hook in. I've also defined a standard smaller dev set for more convenient rapid scoring; plus I've separated out the score reporting. Please check that the README looks clear. Thanks!

@TuZehai
Copy link
Contributor

TuZehai commented Nov 28, 2022

Hi @jonbarker68, I just had a quick look at this and it looks nice and clear except for two issues:

  • I suppose the development set of ICASSP should be the same as CEC2? However, the baseline (i.e. NALR) HASPI is 0.332 according to the README, while the CEC2 is 0.249.
  • In the README file, it might be better to use python xxx.py instead of python3 xxx.py to be consistent..

@jonbarker68
Copy link
Contributor

jonbarker68 commented Nov 28, 2022 via email

TuZehai and others added 5 commits November 29, 2022 15:27
(1) normalise reference signals in evaluate.py
(2) adjust Level1 for hasqi: if Level1=65dB, many signals will be "too quiet" after the processing of hearing loss ear, and the hasqi score will be just 0; thus adjust Level1 to 100dB
(3) improve two functions in eb.py just in case some signals can be "too quiet" that no correlation is computed and return error (should return 0 after fixing)
Make eq=0 as default setting and move it to the last position so that hasqi_v2_be can correctly pass level to hasqi_v2
@jonbarker68 jonbarker68 merged commit 69349f1 into main Nov 29, 2022
@jwillbailey jwillbailey deleted the 113-icassp_recipes branch December 5, 2022 11:38
@jwillbailey jwillbailey restored the 113-icassp_recipes branch December 5, 2022 11:38
@jwillbailey jwillbailey deleted the 113-icassp_recipes branch December 5, 2022 11:39
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.

ICASSP_recipes
5 participants