Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 buildPythonPackage, 4 fetchPypi, 5 fetchpatch, 6 fetchurl, 7 librosa, 8 matplotlib, 9 mido, 10 setuptools, 11 torch, 12 torchlibrosa, 13}: 14 15buildPythonPackage rec { 16 pname = "piano-transcription-inference"; 17 version = "0.0.6"; 18 pyproject = true; 19 20 src = fetchPypi { 21 pname = "piano_transcription_inference"; 22 inherit version; 23 hash = "sha256-tt0A+bS8rLYUByXwO0E5peD0rNNaaeSSpdH3NOz70jE="; 24 }; 25 26 checkpoint = fetchurl { 27 name = "piano-transcription-inference.pth"; 28 # The download url can be found in 29 # https://github.com/qiuqiangkong/piano_transcription_inference/blob/master/piano_transcription_inference/inference.py 30 url = "https://zenodo.org/record/4034264/files/CRNN_note_F1%3D0.9677_pedal_F1%3D0.9186.pth?download=1"; 31 hash = "sha256-w/qXMHJb9Kdi8cFLyAzVmG6s2gGwJvWkolJc1geHYUE="; 32 }; 33 34 build-system = [ setuptools ]; 35 36 dependencies = [ 37 librosa 38 matplotlib 39 mido 40 torch 41 torchlibrosa 42 ]; 43 44 patches = [ 45 # Fix run against librosa 0.10.0 46 # https://github.com/qiuqiangkong/piano_transcription_inference/pull/14 47 (fetchpatch { 48 url = "https://github.com/qiuqiangkong/piano_transcription_inference/commit/b2d448916be771cd228f709c23c474942008e3e8.patch"; 49 hash = "sha256-8O4VtFij//k3fhcbMRz4J8Iz4AdOPLkuk3UTxuCSy8U="; 50 }) 51 (fetchpatch { 52 url = "https://github.com/qiuqiangkong/piano_transcription_inference/commit/61443632dc5ea69a072612b6fa3f7da62c96b72c.patch"; 53 hash = "sha256-I9+Civ95BnPUX0WQhTU/pGQruF5ctIgkIdxCK+xO3PE="; 54 }) 55 ]; 56 57 postPatch = '' 58 substituteInPlace piano_transcription_inference/inference.py --replace \ 59 "checkpoint_path='{}/piano_transcription_inference_data/note_F1=0.9677_pedal_F1=0.9186.pth'.format(str(Path.home()))" \ 60 "checkpoint_path='$out/share/checkpoint.pth'" 61 ''; 62 63 postInstall = '' 64 mkdir "$out/share" 65 ln -s "${checkpoint}" "$out/share/checkpoint.pth" 66 ''; 67 68 # Project has no tests. 69 # In order to make pythonImportsCheck work, NUMBA_CACHE_DIR env var need to 70 # be set to a writable dir (https://github.com/numba/numba/issues/4032#issuecomment-488102702). 71 # pythonImportsCheck has no pre* hook, use checkPhase to workaround that. 72 checkPhase = '' 73 export NUMBA_CACHE_DIR="$(mktemp -d)" 74 ''; 75 pythonImportsCheck = [ "piano_transcription_inference" ]; 76 77 meta = with lib; { 78 description = "Piano transcription inference package"; 79 homepage = "https://github.com/qiuqiangkong/piano_transcription_inference"; 80 license = licenses.mit; 81 maintainers = with maintainers; [ azuwis ]; 82 }; 83}