├── .gitignore ├── effnet-discogs ├── deploy.sh ├── README.md ├── cog.yaml ├── predict.py └── labels.py ├── essentia-bpm ├── deploy.sh ├── README.md ├── cog.yaml └── predict.py ├── transfer-learning-music ├── deploy.sh ├── README.md ├── models.py ├── predict.py └── cog.yaml ├── music-arousal-valence ├── deploy.sh ├── README.md ├── cog.yaml └── predict.py ├── transfer-learning-moods ├── deploy.sh ├── cog.yaml └── predict.py ├── transfer-learning-genres ├── deploy.sh ├── predict.py └── cog.yaml ├── music-approachability-engagement ├── deploy.sh ├── README.md ├── models.py ├── cog.yaml └── predict.py ├── README.md ├── maest ├── cog.yaml ├── predict.py └── labels.py └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | */__pycache__/ 3 | venv/ 4 | */.cog/ 5 | output.* 6 | -------------------------------------------------------------------------------- /effnet-discogs/deploy.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | # Push the effnet-discogs demo 6 | cog push r8.im/mtg/effnet-discogs 7 | -------------------------------------------------------------------------------- /essentia-bpm/deploy.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | # Push the music-approachability-engagement demo 6 | cog push r8.im/mtg/essentia-bpm 7 | -------------------------------------------------------------------------------- /transfer-learning-music/deploy.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | # Push the music-classifiers demo 6 | cog push r8.im/mtg/music-classifiers 7 | -------------------------------------------------------------------------------- /music-arousal-valence/deploy.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | # Push the music-arousal-valence demo 6 | cog push r8.im/mtg/music-arousal-valence 7 | -------------------------------------------------------------------------------- /transfer-learning-moods/deploy.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | # Push the essentia-transfer-learning-moods demo 6 | cog push r8.im/mtg/essentia-transfer-learning-moods 7 | -------------------------------------------------------------------------------- /transfer-learning-genres/deploy.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | # Push the essentia-transfer-learning-genres demo 6 | cog push r8.im/mtg/essentia-transfer-learning-genres 7 | -------------------------------------------------------------------------------- /music-approachability-engagement/deploy.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | # Push the music-approachability-engagement demo 6 | cog push r8.im/mtg/music-approachability-engagement 7 | -------------------------------------------------------------------------------- /essentia-bpm/README.md: -------------------------------------------------------------------------------- 1 | # Tempo BPM estimation with Essentia 2 | 3 | This demo showcases tempo estimation algorithms available in Essentia: 4 | * **degara**: https://essentia.upf.edu/reference/std_RhythmExtractor2013.html 5 | * **multifeature**: https://essentia.upf.edu/reference/std_RhythmExtractor2013.html 6 | * **percival**: https://essentia.upf.edu/reference/std_PercivalBpmEstimator.html 7 | * **deepsquare-k16**: https://essentia.upf.edu/models.html#tempocnn 8 | 9 | 10 | ## License 11 | These algorithms are part of [Essentia](https://essentia.upf.edu) made by [MTG-UPF](https://www.upf.edu/web/mtg/) and are available under [Affero GPLv3 license](https://www.tldrlegal.com/license/gnu-affero-general-public-license-v3-agpl-3-0) and commercial license. 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # essentia-replicate-demos 2 | Demos of Essentia models hosted on replicate.ai's [MTG site](https://replicate.ai/mtg). 3 | 4 | ## The models 5 | Check our [website](https://essentia.upf.edu/models/) for a complete list of the models available within Essentia. 6 | 7 | ## License 8 | The [LICENSE](LICENSE) file included in this repository covers the source code of the demos. 9 | The demos rely on Essentia models distributed under their own [LICENSE](https://essentia.upf.edu/models/LICENSE). 10 | 11 | ## Adding new Essentia demos 12 | - Use the existing demos as examples. 13 | - The demos are organized by folders in this code repository. 14 | - Add a `deploy.sh` script within your demo folder. 15 | - Add your Github account to the MTG organization on Replicate (ask @palonso or @dbogdanov). 16 | - Add a README for the demo on Replicate, including a short description and license ([example](https://replicate.com/mtg/music-classifiers)). 17 | -------------------------------------------------------------------------------- /transfer-learning-music/README.md: -------------------------------------------------------------------------------- 1 | # Transfer learning models for music classification by genres, moods, and instrumentation 2 | 3 | This demo runs transfer learning classifiers trained on various public and in-house MTG datasets using different audio embeddings. 4 | 5 | ## Source models used for embeddings 6 | - [MusiCNN](https://arxiv.org/abs/1909.06654). A musically motivated CNN with two variants trained on the Million Song Dataset and the MagnaTagATune. 7 | - [VGGish](https://ieeexplore.ieee.org/abstract/document/7952132). A large VGG variant trained on a preliminary version of the AudioSet Dataset. 8 | 9 | ## Transfer learning classifiers 10 | Our models consist of single-hidden-layer MLPs trained on the considered embeddings. 11 | 12 | ## License 13 | These models are part of [Essentia Models](https://essentia.upf.edu/models.html) made by [MTG-UPF](https://www.upf.edu/web/mtg/) and are publicly available under [CC by-nc-sa](https://creativecommons.org/licenses/by-nc-sa/4.0/) and commercial license. 14 | -------------------------------------------------------------------------------- /music-arousal-valence/README.md: -------------------------------------------------------------------------------- 1 | # Regression of musical arousal and valence values 2 | 3 | This demo runs a series of transfer learning regression models trained to predict musical arousal and valence values. 4 | These classifiers were trained on a mixture of public and in-house MTG datasets. 5 | 6 | ## Source models 7 | - [MusiCNN](https://arxiv.org/abs/1909.06654). A musically motivated CNN with two variants trained on the Million Song Dataset and the MagnaTagATune. 8 | - [VGGish](https://ieeexplore.ieee.org/abstract/document/7952132). A large VGG variant trained on a preliminary version of the AudioSet Dataset. 9 | 10 | ## Transfer learning classifiers 11 | Our models consist of single-hidden-layer MLPs trained on the considered embeddings. 12 | 13 | ## License 14 | These models are part of [Essentia Models](https://essentia.upf.edu/models.html) made by [MTG-UPF](https://www.upf.edu/web/mtg/) and are publicly available under [CC by-nc-sa](https://creativecommons.org/licenses/by-nc-sa/4.0/) and commercial license. 15 | -------------------------------------------------------------------------------- /effnet-discogs/README.md: -------------------------------------------------------------------------------- 1 | # effnet-discogs: An EfficientNet for music style classification by 400 styles from the Discogs taxonomy 2 | 3 | effnet-discogs is an [EfficientNet](https://arxiv.org/abs/1905.11946) architecture trained to predict music styles for 400 of the most popular [Discogs music styles](https://blog.discogs.com/en/genres-and-styles/). The output plot also shows the Discogs [genre](https://blog.discogs.com/en/genres-and-styles/) the predicted style belongs to. 4 | 5 | This model was trained in more than two million music recordings from an in-house dataset annotated by Discogs metadata and is part of an ongoing research. 6 | 7 | The architecture consists of an EfficientNet on its B0 configuration with an additional penultimate dense layer plus batch normalization to facilitate using the model as an embedding extractor. 8 | 9 | This demo outputs the `top_n` music style activations, summarized as their mean and standard deviation through time. 10 | 11 | ## License 12 | 13 | This model is part of [Essentia Models](https://essentia.upf.edu/models.html) made by [MTG-UPF](https://www.upf.edu/web/mtg/). 14 | -------------------------------------------------------------------------------- /music-approachability-engagement/README.md: -------------------------------------------------------------------------------- 1 | # Classification of music approachability and engagement 2 | 3 | This demo runs transfer learning models to estimate music approachability and engagement using *effnet-discogs* embeddings. We include three model types, providing different outcome formats: `two classes`, `three classes` and `regression` with continuous values: 4 | 5 | * **two classes**: low, and high approachability and engagement. 6 | * **three classes**: low, mid, and high approachability and engagement. 7 | * **regression**: continuous values of approachability and engagement from 0 (low) to 1 (high). 8 | 9 | 10 | These classifiers were trained on in-house MTG datasets. 11 | 12 | ## Source models 13 | *effnet-discogs* is an EfficientNet architecture trained to predict music styles for 400 of the most popular Discogs music styles. 14 | 15 | ## Transfer learning models 16 | Our models consist of single-hidden-layer MLPs trained on the considered embeddings. 17 | 18 | ## License 19 | These models are part of [Essentia Models](https://essentia.upf.edu/models.html) made by [MTG-UPF](https://www.upf.edu/web/mtg/) and are publicly available under [CC by-nc-sa](https://creativecommons.org/licenses/by-nc-sa/4.0/) and commercial license. 20 | -------------------------------------------------------------------------------- /effnet-discogs/cog.yaml: -------------------------------------------------------------------------------- 1 | # Configuration for Cog ⚙️ 2 | # Reference: https://github.com/replicate/cog/blob/main/docs/yaml.md 3 | 4 | build: 5 | # set to true if your model requires a GPU 6 | gpu: false 7 | 8 | # a list of ubuntu apt packages to install 9 | system_packages: 10 | - "ffmpeg" 11 | 12 | # python version in the form '3.8' or '3.8.12' 13 | python_version: "3.10" 14 | 15 | # a list of packages in the format == 16 | python_packages: 17 | - "essentia-tensorflow==2.1b6.dev1034" 18 | - "seaborn==0.11" 19 | 20 | # commands run after the environment is setup 21 | run: 22 | - apt-get update && apt-get install -y git 23 | - pip install --upgrade --force-reinstall git+https://github.com/ytdl-org/youtube-dl.git 24 | - mkdir models 25 | - curl -L -o models/discogs-effnet-bs64-1.pb "https://essentia.upf.edu/models/feature-extractors/discogs-effnet/discogs-effnet-bs64-1.pb" 26 | - curl -L -o models/genre_discogs400-discogs-effnet-1.pb "https://essentia.upf.edu/models/classification-heads/genre_discogs400/genre_discogs400-discogs-effnet-1.pb" 27 | - "echo env is ready!" 28 | # - "echo another command if needed" 29 | 30 | # predict.py defines how predictions are run on your model 31 | predict: "predict.py:Predictor" 32 | -------------------------------------------------------------------------------- /essentia-bpm/cog.yaml: -------------------------------------------------------------------------------- 1 | # Configuration for Cog ⚙️ 2 | # Reference: https://github.com/replicate/cog/blob/main/docs/yaml.md 3 | image: "r8.im/mtg/essentia-bpm" 4 | 5 | build: 6 | # set to true if your model requires a GPU 7 | gpu: false 8 | 9 | # a list of ubuntu apt packages to install 10 | system_packages: 11 | - "ffmpeg" 12 | 13 | # python version in the form '3.8' or '3.8.12' 14 | python_version: "3.10" 15 | 16 | # a list of packages in the format == 17 | python_packages: 18 | - "essentia-tensorflow==2.1b6.dev1110 " 19 | - "numpy==1.21.3" 20 | 21 | run: 22 | - apt-get update && apt-get install -y git 23 | - pip install --upgrade --force-reinstall git+https://github.com/ytdl-org/youtube-dl.git 24 | - mkdir models 25 | # download TempoCNN model (deepsquare-k16 is the best performing model) 26 | - curl -L -o models/deepsquare-k16-3.pb "https://essentia.upf.edu/models/tempo/tempocnn/deepsquare-k16-3.pb" 27 | #- curl -L -o models/deeptemp-k4-3.pb "https://essentia.upf.edu/models/tempo/tempocnn/deeptemp-k4-3.pb" 28 | #- curl -L -o models/deeptemp-k16-3.pb "https://essentia.upf.edu/models/tempo/tempocnn/deeptemp-k16-3.pb" 29 | 30 | # predict.py defines how predictions are run on your model 31 | predict: "predict.py:Predictor" 32 | -------------------------------------------------------------------------------- /maest/cog.yaml: -------------------------------------------------------------------------------- 1 | # Configuration for Cog ⚙️ 2 | # Reference: https://github.com/replicate/cog/blob/main/docs/yaml.md 3 | 4 | build: 5 | # set to true if your model requires a GPU 6 | gpu: true 7 | cuda: "11.2" 8 | 9 | # a list of ubuntu apt packages to install 10 | system_packages: 11 | - "ffmpeg" 12 | - "git" 13 | 14 | # python version in the form '3.8' or '3.8.12' 15 | python_version: "3.10" 16 | 17 | # a list of packages in the format == 18 | python_packages: 19 | - "essentia-tensorflow==2.1b6.dev1110" 20 | - "seaborn==0.11" 21 | 22 | # commands run after the environment is setup 23 | run: 24 | - apt-get update && apt-get install -y git 25 | - pip install --upgrade --force-reinstall git+https://github.com/ytdl-org/youtube-dl.git 26 | - mkdir models 27 | - curl -L -o models/discogs-maest-30s-pw-1.pb "https://essentia.upf.edu/models/feature-extractors/maest/discogs-maest-30s-pw-1.pb" 28 | #- curl -L -o models/discogs-maest-5s-pw-1.pb "https://essentia.upf.edu/models/feature-extractors/maest/discogs-maest-5s-pw-1.pb" 29 | #- curl -L -o models/genre_discogs400-discogs-effnet-1.pb "https://essentia.upf.edu/models/classification-heads/genre_discogs400/genre_discogs400-discogs-effnet-1.pb" 30 | - "echo env is ready!" 31 | # - "echo another command if needed" 32 | 33 | # predict.py defines how predictions are run on your model 34 | predict: "predict.py:Predictor" 35 | -------------------------------------------------------------------------------- /music-approachability-engagement/models.py: -------------------------------------------------------------------------------- 1 | # define the model labels for approachability and engagement per model_type 2 | models = { 3 | "2 classes":{ 4 | "approachability": { 5 | "name": "approachability-2class", 6 | "labels": [ 7 | "not approachable", 8 | "approachable", 9 | ], 10 | }, 11 | "engagement": { 12 | "name": "engagement-2class", 13 | "labels": [ 14 | "not engaging", 15 | "engaging", 16 | ], 17 | }, 18 | }, 19 | "3 classes":{ 20 | "approachability": { 21 | "name": "approachability-3class", 22 | "labels": [ 23 | "low", 24 | "mid", 25 | "high", 26 | ], 27 | }, 28 | "engagement": { 29 | "name": "engagement-3class", 30 | "labels": [ 31 | "low", 32 | "mid", 33 | "high", 34 | ], 35 | }, 36 | }, 37 | "regression":{ 38 | "approachability": { 39 | "name": "approachability-regression", 40 | "labels": [ 41 | "mean", 42 | "std", 43 | ], 44 | }, 45 | "engagement": { 46 | "name": "engagement-regression", 47 | "labels": [ 48 | "mean", 49 | "std", 50 | ], 51 | }, 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /music-arousal-valence/cog.yaml: -------------------------------------------------------------------------------- 1 | # Configuration for Cog ⚙️ 2 | # Reference: https://github.com/replicate/cog/blob/main/docs/yaml.md 3 | image: "r8.im/mtg/music-arousal-valence" 4 | 5 | build: 6 | # set to true if your model requires a GPU 7 | gpu: false 8 | 9 | # a list of ubuntu apt packages to install 10 | system_packages: 11 | - "ffmpeg" 12 | 13 | # python version in the form '3.8' or '3.8.12' 14 | python_version: "3.10" 15 | 16 | # a list of packages in the format == 17 | python_packages: 18 | - "essentia-tensorflow==2.1b6.dev1034" 19 | - "numpy==1.21.3" 20 | - "seaborn==0.11" 21 | 22 | run: 23 | - apt-get update && apt-get install -y git 24 | - pip install --upgrade --force-reinstall git+https://github.com/ytdl-org/youtube-dl.git 25 | - mkdir models 26 | # download embedding models 27 | - curl -L -o models/msd-musicnn-1.pb "https://essentia.upf.edu/models/feature-extractors/musicnn/msd-musicnn-1.pb" 28 | - curl -L -o models/audioset-vggish-3.pb "https://essentia.upf.edu/models/feature-extractors/vggish/audioset-vggish-3.pb" 29 | # download downstream classification models 30 | - curl -L -o models/deam-audioset-vggish-1.pb "https://essentia.upf.edu/models/classification-heads/deam/deam-audioset-vggish-1.pb" 31 | - curl -L -o models/deam-msd-musicnn-1.pb "https://essentia.upf.edu/models/classification-heads/deam/deam-msd-musicnn-1.pb" 32 | - curl -L -o models/emomusic-audioset-vggish-1.pb "https://essentia.upf.edu/models/classification-heads/emomusic/emomusic-audioset-vggish-1.pb" 33 | - curl -L -o models/emomusic-msd-musicnn-1.pb "https://essentia.upf.edu/models/classification-heads/emomusic/emomusic-msd-musicnn-1.pb" 34 | - curl -L -o models/muse-audioset-vggish-1.pb "https://essentia.upf.edu/models/classification-heads/muse/muse-audioset-vggish-1.pb" 35 | - curl -L -o models/muse-msd-musicnn-1.pb "https://essentia.upf.edu/models/classification-heads/muse/muse-msd-musicnn-1.pb" 36 | 37 | # predict.py defines how predictions are run on your model 38 | predict: "predict.py:Predictor" 39 | -------------------------------------------------------------------------------- /music-approachability-engagement/cog.yaml: -------------------------------------------------------------------------------- 1 | # Configuration for Cog ⚙️ 2 | # Reference: https://github.com/replicate/cog/blob/main/docs/yaml.md 3 | image: "r8.im/mtg/essentia-transfer-learning-music" 4 | 5 | build: 6 | # set to true if your model requires a GPU 7 | gpu: false 8 | 9 | # a list of ubuntu apt packages to install 10 | system_packages: 11 | - "ffmpeg" 12 | 13 | # python version in the form '3.8' or '3.8.12' 14 | python_version: "3.10" 15 | 16 | # a list of packages in the format == 17 | python_packages: 18 | - "essentia-tensorflow==2.1b6.dev1034" 19 | - "numpy==1.21.3" 20 | - "seaborn==0.11" 21 | 22 | run: 23 | - apt-get update && apt-get install -y git 24 | - pip install --upgrade --force-reinstall git+https://github.com/ytdl-org/youtube-dl.git 25 | - mkdir models 26 | # download discogs effnet model and TL-based models 27 | - curl -L -o models/discogs-effnet-bs64-1.pb "https://essentia.upf.edu/models/feature-extractors/discogs-effnet/discogs-effnet-bs64-1.pb" 28 | - curl -L -o models/approachability-2class.pb "https://essentia.upf.edu/models/classification-heads/approachability/approachability_2c-discogs-effnet-1.pb" 29 | - curl -L -o models/engagement-2class.pb "https://essentia.upf.edu/models/classification-heads/engagement/engagement_2c-discogs-effnet-1.pb" 30 | - curl -L -o models/approachability-3class.pb "https://essentia.upf.edu/models/classification-heads/approachability/approachability_3c-discogs-effnet-1.pb" 31 | - curl -L -o models/engagement-3class.pb "https://essentia.upf.edu/models/classification-heads/engagement/engagement_3c-discogs-effnet-1.pb" 32 | - curl -L -o models/approachability-regression.pb "https://essentia.upf.edu/models/classification-heads/approachability/approachability_regression-discogs-effnet-1.pb" 33 | - curl -L -o models/engagement-regression.pb "https://essentia.upf.edu/models/classification-heads/engagement/engagement_regression-discogs-effnet-1.pb" 34 | 35 | # predict.py defines how predictions are run on your model 36 | predict: "predict.py:Predictor" 37 | -------------------------------------------------------------------------------- /transfer-learning-music/models.py: -------------------------------------------------------------------------------- 1 | models_effnet = { 2 | "genre_discogs400": "genre_discogs400-discogs-effnet-1.pb", 3 | "mtg_jamendo_genre": "mtg_jamendo_genre-discogs-effnet-1.pb", 4 | "mood_acoustic": "mood_acoustic-discogs-effnet-1.pb", 5 | "mood_aggressive": "mood_aggressive-discogs-effnet-1.pb", 6 | "mood_electronic": "mood_electronic-discogs-effnet-1.pb", 7 | "mood_happy": "mood_happy-discogs-effnet-1.pb", 8 | "mood_party": "mood_party-discogs-effnet-1.pb", 9 | "mood_relaxed": "mood_relaxed-discogs-effnet-1.pb", 10 | "mood_sad": "mood_sad-discogs-effnet-1.pb", 11 | "mtg_jamendo_moodtheme": "mtg_jamendo_moodtheme-discogs-effnet-1.pb", 12 | "approachability_regression": "approachability_regression-discogs-effnet-1.pb", 13 | "danceability": "danceability-discogs-effnet-1.pb", 14 | "engagement_regression": "engagement_regression-discogs-effnet-1.pb", 15 | "gender": "gender-discogs-effnet-1.pb", 16 | "mtt_autotagging": "mtt-discogs-effnet-1.pb", 17 | "mtg_jamendo_instrument": "mtg_jamendo_instrument-discogs-effnet-1.pb", 18 | "timbre": "timbre-discogs-effnet-1.pb", 19 | "tonal_atonal": "tonal_atonal-discogs-effnet-1.pb", 20 | "voice_instrumental": "voice_instrumental-discogs-effnet-1.pb", 21 | } 22 | 23 | 24 | models_musicnn = { 25 | "gender": "gender-msd-musicnn-1.pb", 26 | "mood_sad": "mood_sad-msd-musicnn-1.pb", 27 | "voice_instrumental": "voice_instrumental-msd-musicnn-1.pb", 28 | "msd": "msd-msd-musicnn-1.pb", 29 | "tonal_atonal": "tonal_atonal-msd-musicnn-1.pb", 30 | "mood_relaxed": "mood_relaxed-msd-musicnn-1.pb", 31 | "emomusic": "emomusic-msd-musicnn-1.pb", 32 | "moods_mirex": "moods_mirex-msd-musicnn-1.pb", 33 | "fs_loop_ds": "fs_loop_ds-msd-musicnn-1.pb", 34 | "mood_acoustic": "mood_acoustic-msd-musicnn-1.pb", 35 | "mood_party": "mood_party-msd-musicnn-1.pb", 36 | "danceability": "danceability-msd-musicnn-1.pb", 37 | "mood_happy": "mood_happy-msd-musicnn-1.pb", 38 | "deam": "deam-msd-musicnn-1.pb", 39 | "muse": "muse-msd-musicnn-1.pb", 40 | "mood_electronic": "mood_electronic-msd-musicnn-1.pb", 41 | "mood_aggressive": "mood_aggressive-msd-musicnn-1.pb", 42 | } 43 | 44 | models_vggish = { 45 | "gender": "gender-audioset-vggish-1.pb", 46 | "mood_sad": "mood_sad-audioset-vggish-1.pb", 47 | "voice_instrumental": "voice_instrumental-audioset-vggish-1.pb", 48 | "tonal_atonal": "tonal_atonal-audioset-vggish-1.pb", 49 | "mood_relaxed": "mood_relaxed-audioset-vggish-1.pb", 50 | "emomusic": "emomusic-audioset-vggish-1.pb", 51 | "moods_mirex": "moods_mirex-audioset-vggish-1.pb", 52 | "mood_acoustic": "mood_acoustic-audioset-vggish-1.pb", 53 | "mood_party": "mood_party-audioset-vggish-1.pb", 54 | "danceability": "danceability-audioset-vggish-1.pb", 55 | "mood_happy": "mood_happy-audioset-vggish-1.pb", 56 | "deam": "deam-audioset-vggish-1.pb", 57 | "muse": "muse-audioset-vggish-1.pb", 58 | "mood_electronic": "mood_electronic-audioset-vggish-1.pb", 59 | "mood_aggressive": "mood_aggressive-audioset-vggish-1.pb", 60 | } 61 | 62 | 63 | models = { 64 | "effnet-discogs": { 65 | "name": "discogs-effnet-bs64-1.pb", 66 | "downstream_models": models_effnet, 67 | "embedding_layer": "PartitionedCall:1", 68 | }, 69 | "musicnn-msd": { 70 | "name": "msd-musicnn-1.pb", 71 | "downstream_models": models_musicnn, 72 | "embedding_layer": "model/dense/BiasAdd", 73 | }, 74 | "vggish-audioset": { 75 | "name": "audioset-vggish-3.pb", 76 | "downstream_models": models_vggish, 77 | "embedding_layer": "model/vggish/embeddings", 78 | }, 79 | } 80 | -------------------------------------------------------------------------------- /transfer-learning-moods/cog.yaml: -------------------------------------------------------------------------------- 1 | # Configuration for Cog ⚙️ 2 | # Reference: https://github.com/replicate/cog/blob/main/docs/yaml.md 3 | image: "r8.im/mtg/essentia-transfer-learning-moods" 4 | 5 | build: 6 | # set to true if your model requires a GPU 7 | gpu: false 8 | 9 | # python version in the form '3.8' or '3.8.12' 10 | python_version: "3.8" 11 | 12 | # a list of packages in the format == 13 | python_packages: 14 | - "essentia-tensorflow==2.1b6.dev609" 15 | - "numpy==1.21.3" 16 | 17 | run: 18 | - mkdir models 19 | - curl -s -o models/mood_acoustic-musicnn-msd-2.pb https://essentia.upf.edu/models/classifiers/mood_acoustic/mood_acoustic-musicnn-msd-2.pb 20 | - curl -s -o models/mood_acoustic-musicnn-mtt-2.pb https://essentia.upf.edu/models/classifiers/mood_acoustic/mood_acoustic-musicnn-mtt-2.pb 21 | - curl -s -o models/mood_acoustic-vggish-audioset-1.pb https://essentia.upf.edu/models/classifiers/mood_acoustic/mood_acoustic-vggish-audioset-1.pb 22 | 23 | - curl -s -o models/mood_aggressive-musicnn-msd-2.pb https://essentia.upf.edu/models/classifiers/mood_aggressive/mood_aggressive-musicnn-msd-2.pb 24 | - curl -s -o models/mood_aggressive-musicnn-mtt-2.pb https://essentia.upf.edu/models/classifiers/mood_aggressive/mood_aggressive-musicnn-mtt-2.pb 25 | - curl -s -o models/mood_aggressive-vggish-audioset-1.pb https://essentia.upf.edu/models/classifiers/mood_aggressive/mood_aggressive-vggish-audioset-1.pb 26 | 27 | - curl -s -o models/mood_electronic-musicnn-msd-2.pb https://essentia.upf.edu/models/classifiers/mood_electronic/mood_electronic-musicnn-msd-2.pb 28 | - curl -s -o models/mood_electronic-musicnn-mtt-2.pb https://essentia.upf.edu/models/classifiers/mood_electronic/mood_electronic-musicnn-mtt-2.pb 29 | - curl -s -o models/mood_electronic-vggish-audioset-1.pb https://essentia.upf.edu/models/classifiers/mood_electronic/mood_electronic-vggish-audioset-1.pb 30 | 31 | - curl -s -o models/mood_happy-musicnn-msd-2.pb https://essentia.upf.edu/models/classifiers/mood_happy/mood_happy-musicnn-msd-2.pb 32 | - curl -s -o models/mood_happy-musicnn-mtt-2.pb https://essentia.upf.edu/models/classifiers/mood_happy/mood_happy-musicnn-mtt-2.pb 33 | - curl -s -o models/mood_happy-vggish-audioset-1.pb https://essentia.upf.edu/models/classifiers/mood_happy/mood_happy-vggish-audioset-1.pb 34 | 35 | - curl -s -o models/mood_party-musicnn-msd-2.pb https://essentia.upf.edu/models/classifiers/mood_party/mood_party-musicnn-msd-2.pb 36 | - curl -s -o models/mood_party-musicnn-mtt-2.pb https://essentia.upf.edu/models/classifiers/mood_party/mood_party-musicnn-mtt-2.pb 37 | - curl -s -o models/mood_party-vggish-audioset-1.pb https://essentia.upf.edu/models/classifiers/mood_party/mood_party-vggish-audioset-1.pb 38 | 39 | - curl -s -o models/mood_relaxed-musicnn-msd-2.pb https://essentia.upf.edu/models/classifiers/mood_relaxed/mood_relaxed-musicnn-msd-2.pb 40 | - curl -s -o models/mood_relaxed-musicnn-mtt-2.pb https://essentia.upf.edu/models/classifiers/mood_relaxed/mood_relaxed-musicnn-mtt-2.pb 41 | - curl -s -o models/mood_relaxed-vggish-audioset-1.pb https://essentia.upf.edu/models/classifiers/mood_relaxed/mood_relaxed-vggish-audioset-1.pb 42 | 43 | - curl -s -o models/mood_sad-musicnn-msd-2.pb https://essentia.upf.edu/models/classifiers/mood_sad/mood_sad-musicnn-msd-2.pb 44 | - curl -s -o models/mood_sad-musicnn-mtt-2.pb https://essentia.upf.edu/models/classifiers/mood_sad/mood_sad-musicnn-mtt-2.pb 45 | - curl -s -o models/mood_sad-vggish-audioset-1.pb https://essentia.upf.edu/models/classifiers/mood_sad/mood_sad-vggish-audioset-1.pb 46 | 47 | # predict.py defines how predictions are run on your model 48 | predict: "predict.py:Predictor" 49 | -------------------------------------------------------------------------------- /transfer-learning-genres/predict.py: -------------------------------------------------------------------------------- 1 | # Prediction interface for Cog ⚙️ 2 | # Reference: https://github.com/replicate/cog/blob/main/docs/python.md 3 | 4 | import os 5 | from dataclasses import dataclass 6 | from typing import Dict, List 7 | import tempfile 8 | from pathlib import Path 9 | 10 | import cog 11 | 12 | from essentia.standard import MonoLoader, TensorflowPredictMusiCNN, TensorflowPredictVGGish 13 | import numpy as np 14 | 15 | 16 | MODELS_HOME = "/models" 17 | 18 | 19 | @dataclass 20 | class Model: 21 | name: str 22 | labels: List[str] 23 | model_files: Dict[str, str] 24 | 25 | 26 | 27 | class Predictor(cog.Predictor): 28 | def setup(self): 29 | """Load the model into memory to make running multiple predictions efficient""" 30 | 31 | def predict_single_model(self, audio: str, model: Model): 32 | sr = 16000 33 | audio = MonoLoader(filename=str(audio), sampleRate=sr)() 34 | 35 | all_results = {} 36 | for name, file in model.model_files.items(): 37 | if 'musicnn' in name.lower(): 38 | classifier = TensorflowPredictMusiCNN(graphFilename=os.path.join(MODELS_HOME, file)) 39 | elif 'vggish' in name.lower(): 40 | classifier = TensorflowPredictVGGish(graphFilename=os.path.join(MODELS_HOME, file)) 41 | else: 42 | classifier = None 43 | if not classifier: 44 | raise Exception("Unknown classifier") 45 | 46 | results = classifier(audio) 47 | averaged_predictions = np.mean(results, axis=0) 48 | all_results[name] = averaged_predictions 49 | 50 | result_order = list(all_results.keys()) 51 | header = "| | " + " | ".join(result_order) 52 | bar = "|---|" + "|".join(["---"] * len(all_results.keys())) 53 | table = header + "\n" + bar + "\n" 54 | for i, label in enumerate(model.labels): 55 | line = f"{label} | " 56 | for classifier in result_order: 57 | line += f" {all_results[classifier][i]:.2f} | " 58 | table += line + "\n" 59 | 60 | return table 61 | 62 | @cog.input("audio", type=cog.Path, help="Audio file to process") 63 | def predict(self, audio): 64 | 65 | models = [ 66 | Model(name="Genre Dortmund", labels=["alternative", "blues", "electronic", "folkcountry", "funksoulrnb", "jazz", "pop", "raphiphop", "rock"], 67 | model_files={'MusiCNN MSD': 'genre_dortmund-musicnn-msd-2.pb', 68 | 'MusiCNN MTT': 'genre_dortmund-musicnn-mtt-2.pb', 69 | 'VGGish': 'genre_dortmund-vggish-audioset-1.pb'}), 70 | Model(name="Genre Rosamerica", labels=["classic", "dance", "hip hop", "jazz", "pop", "rhythm and blues", "rock", "speech"], 71 | model_files={'MusiCNN MSD': 'genre_rosamerica-musicnn-msd-2.pb', 72 | 'MusiCNN MTT': 'genre_rosamerica-musicnn-mtt-2.pb', 73 | 'VGGish': 'genre_rosamerica-vggish-audioset-1.pb'}), 74 | Model(name="Genre Tzanetakis", labels=["blues", "classic", "country", "disco", "hip hop", "jazz", "metal", "pop", "reggae", "rock"], 75 | model_files={'MusiCNN MSD': 'genre_tzanetakis-musicnn-msd-2.pb', 76 | 'MusiCNN MTT': 'genre_tzanetakis-musicnn-mtt-2.pb', 77 | 'VGGish': 'genre_tzanetakis-vggish-audioset-1.pb'}), 78 | Model(name="Genre Electronic", labels=["ambient", "dnb", "house", "techno", "trance"], 79 | model_files={'MusiCNN MSD': 'genre_electronic-musicnn-msd-2.pb', 80 | 'MusiCNN MTT': 'genre_electronic-musicnn-mtt-2.pb', 81 | 'VGGish': 'genre_electronic-vggish-audioset-1.pb'}) 82 | ] 83 | 84 | results = "" 85 | for model in models: 86 | results += f"# {model.name}\n\n" 87 | model_table = self.predict_single_model(audio, model) 88 | results += model_table + "\n\n" 89 | 90 | out_path = Path(tempfile.mkdtemp()) / "out.md" 91 | with open(out_path, "w") as f: 92 | f.write(results) 93 | return out_path 94 | -------------------------------------------------------------------------------- /transfer-learning-moods/predict.py: -------------------------------------------------------------------------------- 1 | # Prediction interface for Cog ⚙️ 2 | # Reference: https://github.com/replicate/cog/blob/main/docs/python.md 3 | 4 | import os 5 | from dataclasses import dataclass 6 | from typing import Dict, List 7 | import tempfile 8 | from pathlib import Path 9 | 10 | import cog 11 | 12 | from essentia.standard import MonoLoader, TensorflowPredictMusiCNN, TensorflowPredictVGGish 13 | import numpy as np 14 | 15 | 16 | MODELS_HOME = "/models" 17 | 18 | 19 | @dataclass 20 | class Model: 21 | name: str 22 | labels: List[str] 23 | model_files: Dict[str, str] 24 | 25 | 26 | 27 | class Predictor(cog.Predictor): 28 | def setup(self): 29 | """Load the model into memory to make running multiple predictions efficient""" 30 | 31 | def predict_single_model(self, audio: str, model: Model): 32 | sr = 16000 33 | audio = MonoLoader(filename=str(audio), sampleRate=sr)() 34 | 35 | all_results = {} 36 | for name, file in model.model_files.items(): 37 | if 'musicnn' in name.lower(): 38 | classifier = TensorflowPredictMusiCNN(graphFilename=os.path.join(MODELS_HOME, file)) 39 | elif 'vggish' in name.lower(): 40 | classifier = TensorflowPredictVGGish(graphFilename=os.path.join(MODELS_HOME, file)) 41 | else: 42 | classifier = None 43 | if not classifier: 44 | raise Exception("Unknown classifier") 45 | 46 | results = classifier(audio) 47 | averaged_predictions = np.mean(results, axis=0) 48 | all_results[name] = averaged_predictions 49 | 50 | result_order = list(all_results.keys()) 51 | header = "| | " + " | ".join(result_order) 52 | bar = "|---|" + "|".join(["---"] * len(all_results.keys())) 53 | table = header + "\n" + bar + "\n" 54 | for i, label in enumerate(model.labels): 55 | line = f"{label} | " 56 | for classifier in result_order: 57 | line += f" {all_results[classifier][i]:.2f} | " 58 | table += line + "\n" 59 | 60 | return table 61 | 62 | @cog.input("audio", type=cog.Path, help="Audio file to process") 63 | def predict(self, audio): 64 | 65 | models = [ 66 | Model(name="Mood Acoustic", labels=["Acoustic", "Not acoustic"], 67 | model_files={'MusiCNN MSD': 'mood_acoustic-musicnn-msd-2.pb', 68 | 'MusiCNN MTT': 'mood_acoustic-musicnn-mtt-2.pb', 69 | 'VGGish': 'mood_acoustic-vggish-audioset-1.pb'}), 70 | Model(name="Mood Electronic", labels=["Electronic", "Not electronic"], 71 | model_files={'MusiCNN MSD': 'mood_electronic-musicnn-msd-2.pb', 72 | 'MusiCNN MTT': 'mood_electronic-musicnn-mtt-2.pb', 73 | 'VGGish': 'mood_electronic-vggish-audioset-1.pb'}), 74 | Model(name="Mood Aggressive", labels=["Aggressive", "Not aggressive"], 75 | model_files={'MusiCNN MSD': 'mood_aggressive-musicnn-msd-2.pb', 76 | 'MusiCNN MTT': 'mood_aggressive-musicnn-mtt-2.pb', 77 | 'VGGish': 'mood_aggressive-vggish-audioset-1.pb'}), 78 | Model(name="Mood Relaxed", labels=["Not relaxed", "Relaxed"], 79 | model_files={'MusiCNN MSD': 'mood_relaxed-musicnn-msd-2.pb', 80 | 'MusiCNN MTT': 'mood_relaxed-musicnn-mtt-2.pb', 81 | 'VGGish': 'mood_relaxed-vggish-audioset-1.pb'}), 82 | Model(name="Mood Happy", labels=["Happy", "Not happy"], 83 | model_files={'MusiCNN MSD': 'mood_happy-musicnn-msd-2.pb', 84 | 'MusiCNN MTT': 'mood_happy-musicnn-mtt-2.pb', 85 | 'VGGish': 'mood_happy-vggish-audioset-1.pb'}), 86 | Model(name="Mood Sad", labels=["Not sad", "Sad"], 87 | model_files={'MusiCNN MSD': 'mood_sad-musicnn-msd-2.pb', 88 | 'MusiCNN MTT': 'mood_sad-musicnn-mtt-2.pb', 89 | 'VGGish': 'mood_sad-vggish-audioset-1.pb'}), 90 | Model(name="Mood Party", labels=["Not party", "Party"], 91 | model_files={'MusiCNN MSD': 'mood_party-musicnn-msd-2.pb', 92 | 'MusiCNN MTT': 'mood_party-musicnn-mtt-2.pb', 93 | 'VGGish': 'mood_party-vggish-audioset-1.pb'}) 94 | ] 95 | 96 | results = "" 97 | for model in models: 98 | results += f"# {model.name}\n\n" 99 | model_table = self.predict_single_model(audio, model) 100 | results += model_table + "\n\n" 101 | 102 | out_path = Path(tempfile.mkdtemp()) / "out.md" 103 | with open(out_path, "w") as f: 104 | f.write(results) 105 | return out_path 106 | -------------------------------------------------------------------------------- /transfer-learning-genres/cog.yaml: -------------------------------------------------------------------------------- 1 | # Configuration for Cog ⚙️ 2 | # Reference: https://github.com/replicate/cog/blob/main/docs/yaml.md 3 | image: "r8.im/mtg/essentia-transfer-learning-genres" 4 | 5 | build: 6 | # set to true if your model requires a GPU 7 | gpu: false 8 | 9 | # python version in the form '3.8' or '3.8.12' 10 | python_version: "3.8" 11 | 12 | # a list of packages in the format == 13 | python_packages: 14 | - "essentia-tensorflow==2.1b6.dev609" 15 | - "numpy==1.21.3" 16 | 17 | run: 18 | - mkdir models 19 | - curl -s -o models/genre_dortmund-musicnn-msd-2.pb https://essentia.upf.edu/models/classifiers/genre_dortmund/genre_dortmund-musicnn-msd-2.pb 20 | - curl -s -o models/genre_dortmund-musicnn-mtt-2.pb https://essentia.upf.edu/models/classifiers/genre_dortmund/genre_dortmund-musicnn-msd-2.pb 21 | - curl -s -o models/genre_dortmund-vggish-audioset-1.pb https://essentia.upf.edu/models/classifiers/genre_dortmund/genre_dortmund-vggish-audioset-1.pb 22 | 23 | - curl -s -o models/genre_electronic-musicnn-msd-2.pb https://essentia.upf.edu/models/classifiers/genre_electronic/genre_electronic-musicnn-msd-2.pb 24 | - curl -s -o models/genre_electronic-musicnn-mtt-2.pb https://essentia.upf.edu/models/classifiers/genre_electronic/genre_electronic-musicnn-msd-2.pb 25 | - curl -s -o models/genre_electronic-vggish-audioset-1.pb https://essentia.upf.edu/models/classifiers/genre_electronic/genre_electronic-vggish-audioset-1.pb 26 | 27 | - curl -s -o models/genre_rosamerica-musicnn-msd-2.pb https://essentia.upf.edu/models/classifiers/genre_rosamerica/genre_rosamerica-musicnn-msd-2.pb 28 | - curl -s -o models/genre_rosamerica-musicnn-mtt-2.pb https://essentia.upf.edu/models/classifiers/genre_rosamerica/genre_rosamerica-musicnn-msd-2.pb 29 | - curl -s -o models/genre_rosamerica-vggish-audioset-1.pb https://essentia.upf.edu/models/classifiers/genre_rosamerica/genre_rosamerica-vggish-audioset-1.pb 30 | 31 | - curl -s -o models/genre_tzanetakis-musicnn-msd-2.pb https://essentia.upf.edu/models/classifiers/genre_tzanetakis/genre_tzanetakis-musicnn-msd-2.pb 32 | - curl -s -o models/genre_tzanetakis-musicnn-mtt-2.pb https://essentia.upf.edu/models/classifiers/genre_tzanetakis/genre_tzanetakis-musicnn-msd-2.pb 33 | - curl -s -o models/genre_tzanetakis-vggish-audioset-1.pb https://essentia.upf.edu/models/classifiers/genre_tzanetakis/genre_tzanetakis-vggish-audioset-1.pb 34 | 35 | # predict.py defines how predictions are run on your model 36 | predict: "predict.py:Predictor" 37 | # Configuration for Cog ⚙️ 38 | # Reference: https://github.com/replicate/cog/blob/main/docs/yaml.md 39 | image: "r8.im/mtg/essentia-transfer-learning-genres" 40 | 41 | build: 42 | # set to true if your model requires a GPU 43 | gpu: false 44 | 45 | # python version in the form '3.8' or '3.8.12' 46 | python_version: "3.8" 47 | 48 | # a list of packages in the format == 49 | python_packages: 50 | - "essentia-tensorflow==2.1b6.dev609" 51 | - "numpy==1.21.3" 52 | 53 | run: 54 | - mkdir models 55 | - curl -s -o models/genre_dortmund-musicnn-msd-2.pb https://essentia.upf.edu/models/classifiers/genre_dortmund/genre_dortmund-musicnn-msd-2.pb 56 | - curl -s -o models/genre_dortmund-musicnn-mtt-2.pb https://essentia.upf.edu/models/classifiers/genre_dortmund/genre_dortmund-musicnn-msd-2.pb 57 | - curl -s -o models/genre_dortmund-vggish-audioset-1.pb https://essentia.upf.edu/models/classifiers/genre_dortmund/genre_dortmund-vggish-audioset-1.pb 58 | 59 | - curl -s -o models/genre_electronic-musicnn-msd-2.pb https://essentia.upf.edu/models/classifiers/genre_electronic/genre_electronic-musicnn-msd-2.pb 60 | - curl -s -o models/genre_electronic-musicnn-mtt-2.pb https://essentia.upf.edu/models/classifiers/genre_electronic/genre_electronic-musicnn-msd-2.pb 61 | - curl -s -o models/genre_electronic-vggish-audioset-1.pb https://essentia.upf.edu/models/classifiers/genre_electronic/genre_electronic-vggish-audioset-1.pb 62 | 63 | - curl -s -o models/genre_rosamerica-musicnn-msd-2.pb https://essentia.upf.edu/models/classifiers/genre_rosamerica/genre_rosamerica-musicnn-msd-2.pb 64 | - curl -s -o models/genre_rosamerica-musicnn-mtt-2.pb https://essentia.upf.edu/models/classifiers/genre_rosamerica/genre_rosamerica-musicnn-msd-2.pb 65 | - curl -s -o models/genre_rosamerica-vggish-audioset-1.pb https://essentia.upf.edu/models/classifiers/genre_rosamerica/genre_rosamerica-vggish-audioset-1.pb 66 | 67 | - curl -s -o models/genre_tzanetakis-musicnn-msd-2.pb https://essentia.upf.edu/models/classifiers/genre_tzanetakis/genre_tzanetakis-musicnn-msd-2.pb 68 | - curl -s -o models/genre_tzanetakis-musicnn-mtt-2.pb https://essentia.upf.edu/models/classifiers/genre_tzanetakis/genre_tzanetakis-musicnn-msd-2.pb 69 | - curl -s -o models/genre_tzanetakis-vggish-audioset-1.pb https://essentia.upf.edu/models/classifiers/genre_tzanetakis/genre_tzanetakis-vggish-audioset-1.pb 70 | 71 | # predict.py defines how predictions are run on your model 72 | predict: "predict.py:Predictor" 73 | -------------------------------------------------------------------------------- /essentia-bpm/predict.py: -------------------------------------------------------------------------------- 1 | # Prediction interface for Cog ⚙️ 2 | # Reference: https://github.com/replicate/cog/blob/main/docs/python.md 3 | 4 | import tempfile 5 | 6 | from cog import BasePredictor, Input, Path 7 | from essentia.standard import ( 8 | MonoLoader, 9 | RhythmExtractor2013, 10 | PercivalBpmEstimator, 11 | Resample, 12 | TempoCNN, 13 | ) 14 | import numpy as np 15 | import youtube_dl 16 | 17 | 18 | class Predictor(BasePredictor): 19 | def setup(self): 20 | """Instantiate Essentia algorithms for predictions""" 21 | 22 | self.sample_rate = 44100 23 | 24 | # Instantiate algorithms. 25 | self.loader = MonoLoader(sampleRate=44100) 26 | self.resample = Resample(outputSampleRate=11025, quality=4) 27 | self.algos = { 28 | "degara": RhythmExtractor2013(method="degara"), 29 | "multifeature": RhythmExtractor2013(method="multifeature"), 30 | "percival": PercivalBpmEstimator(), 31 | "deepsquare-k16": TempoCNN(graphFilename="/models/deepsquare-k16-3.pb"), 32 | } 33 | 34 | def predict( 35 | self, 36 | audio: Path = Input( 37 | description="Audio file to process", 38 | default=None, 39 | ), 40 | url: str = Input( 41 | description="YouTube URL to process (overrides audio input)", 42 | default=None, 43 | ), 44 | algo_type: str = Input( 45 | description="Analysis algorithm: degara, multifeature, percival, deepsquare-k16", 46 | default="degara", 47 | choices=["degara", "multifeature", "percival", "deepsquare-k16"], 48 | ), 49 | ) -> Path: 50 | """Run analysis.""" 51 | 52 | assert audio or url, "Specify either an audio filename or a YouTube URL" 53 | 54 | # If there is a YouTube url use that. 55 | if url: 56 | if audio: 57 | print( 58 | "Warning: Both `url` and `audio` inputs were specified. " 59 | "The `url` will be process. To process the `audio` input clear the `url` input field." 60 | ) 61 | audio, title = self._download(url) 62 | else: 63 | title = audio.name 64 | 65 | print("loading audio...") 66 | self.loader.configure(sampleRate=self.sample_rate, filename=str(audio)) 67 | waveform = self.loader() 68 | 69 | result = self._run_algos(waveform, algo_type, title) 70 | 71 | out_path = Path(tempfile.mkdtemp()) / "out.md" 72 | with open(out_path, "w") as f: 73 | f.write(result) 74 | 75 | print("done!") 76 | return out_path 77 | 78 | def _download(self, url, ext="wav"): 79 | """Download a YouTube URL in the specified format to a temporal directory""" 80 | 81 | tmp_dir = Path(tempfile.mktemp()) 82 | ydl_opts = { 83 | # The download is quite slow, use the most compressed format that doesn't affect 84 | # the sense of the prediction (too much): 85 | # 86 | # Code Container Audio Codec Audio Bitrate Channels Still offered? 87 | # 250 WebM Opus (VBR) ~70 Kbps Stereo (2) Yes 88 | # 251 WebM Opus (VBR) <=160 Kbps Stereo (2) Yes 89 | # 40 MP4 AAC (LC) 128 Kbps Stereo (2) Yes, YT Music 90 | # 91 | # Download speeds: 92 | # 250 -> ~19s, 251 -> 30s, 40 -> ~35s 93 | # but 250 changes the predictions too munch. Using 251 as a compromise. 94 | # 95 | # From https://gist.github.com/AgentOak/34d47c65b1d28829bb17c24c04a0096f 96 | "format": "251", 97 | "postprocessors": [ 98 | { 99 | "key": "FFmpegExtractAudio", 100 | "preferredcodec": ext, 101 | } 102 | ], 103 | # render audio @16kHz to prevent resampling latter on 104 | "postprocessor_args": ["-ar", f"{self.sample_rate}"], 105 | "outtmpl": str(tmp_dir / "audio.%(ext)s"), 106 | } 107 | 108 | with youtube_dl.YoutubeDL(ydl_opts) as ydl: 109 | info = ydl.extract_info(url) 110 | 111 | if "title" in info: 112 | title = info["title"] 113 | else: 114 | title = "" # is it possible that the title metadata is unavailable? Continue anyway 115 | 116 | paths = [p for p in tmp_dir.glob(f"audio.{ext}")] 117 | assert ( 118 | len(paths) == 1 119 | ), "Something unexpected happened. Should be only one match!" 120 | 121 | return paths[0], title 122 | 123 | def _run_algos(self, waveform: np.ndarray, algo_type: str, title: str): 124 | print("running analysis algorithm...") 125 | 126 | if algo_type in ["degara", "multifeature"]: 127 | bpm = self.algos[algo_type](waveform)[0] 128 | elif algo_type == "percival": 129 | bpm = self.algos[algo_type](waveform) 130 | elif algo_type == "deepsquare-k16": 131 | waveform = self.resample(waveform) 132 | bpm = self.algos[algo_type](waveform)[0] 133 | 134 | return f"Estimated BPM: {bpm}" 135 | -------------------------------------------------------------------------------- /transfer-learning-music/predict.py: -------------------------------------------------------------------------------- 1 | # Prediction interface for Cog ⚙️ 2 | # Reference: https://github.com/replicate/cog/blob/main/docs/python.md 3 | 4 | import tempfile 5 | import json 6 | 7 | from cog import BasePredictor, Input, Path 8 | import youtube_dl 9 | from essentia.standard import ( 10 | MonoLoader, 11 | TensorflowPredict2D, 12 | TensorflowPredictMusiCNN, 13 | TensorflowPredictVGGish, 14 | TensorflowPredictEffnetDiscogs, 15 | ) 16 | import numpy as np 17 | 18 | from models import models 19 | 20 | MODELS_HOME = "/models" 21 | 22 | embedding_models = { 23 | "effnet-discogs": TensorflowPredictEffnetDiscogs, 24 | "musicnn-msd": TensorflowPredictMusiCNN, 25 | "vggish-audioset": TensorflowPredictVGGish, 26 | } 27 | 28 | 29 | class Predictor(BasePredictor): 30 | def setup(self): 31 | """Load the model into memory to make running multiple predictions efficient""" 32 | self.sample_rate = 16000 33 | 34 | def predict( 35 | self, 36 | audio: Path = Input( 37 | description="Audio file to process", 38 | default=None, 39 | ), 40 | url: str = Input( 41 | description="YouTube URL to process (overrides audio input)", 42 | default="", 43 | ), 44 | model_type: str = Input( 45 | description="Model type (embeddings)", 46 | default="effnet-discogs", 47 | choices=[ 48 | "effnet-discogs", 49 | "musicnn-msd", 50 | "vggish-audioset", 51 | ], 52 | ), 53 | ) -> Path: 54 | """Run a single prediction by all models of the selected type""" 55 | 56 | assert audio or url, "Specify either an audio filename or a YouTube url" 57 | 58 | # If there is a YouTube url use that. 59 | if url: 60 | if audio: 61 | print( 62 | "Warning: Both `url` and `audio` inputs were specified. " 63 | "The `url` will be process. To process the `audio` input clear the `url` input field." 64 | ) 65 | audio, title = self._download(url) 66 | else: 67 | title = audio.name 68 | 69 | # Configure a processing chain based on the selected model type. 70 | audio = MonoLoader(filename=str(audio), sampleRate=self.sample_rate)() 71 | 72 | model_name = "/models/" + models[model_type]["name"] 73 | downstream_models = models[model_type]["downstream_models"] 74 | embedding_layer = models[model_type]["embedding_layer"] 75 | 76 | print(model_name) 77 | 78 | model = embedding_models[model_type]( 79 | graphFilename=model_name, 80 | output=embedding_layer, 81 | ) 82 | embeddings = model(audio) 83 | 84 | results = {} 85 | for downstream_model_name, downstream_model_path in downstream_models.items(): 86 | metadata_file = "/models/" + downstream_model_path.replace(".pb", ".json") 87 | with open(metadata_file, "r") as f: 88 | metadata = json.load(f) 89 | 90 | classes = metadata["classes"] 91 | input_name = metadata["schema"]["inputs"][0]["name"] 92 | 93 | for output in metadata["schema"]["outputs"]: 94 | if output["output_purpose"] == "predictions": 95 | output_name = output["name"] 96 | 97 | activations = TensorflowPredict2D( 98 | graphFilename="/models/" + downstream_model_path, 99 | input=input_name, 100 | output=output_name, 101 | )(embeddings) 102 | activations_mean = np.mean(activations, axis=0) 103 | 104 | top_class = np.argmax(activations_mean) 105 | prob = activations_mean[top_class] 106 | label = classes[top_class] 107 | 108 | results[downstream_model_name] = { 109 | "prob": prob, 110 | "label": label, 111 | } 112 | 113 | title = "# %s\n" % title 114 | header = "| model | top class | activation |\n" 115 | bar = "|---|---|---|\n" 116 | table = title + header + bar 117 | 118 | rows = [] 119 | for ds_model_name, values in results.items(): 120 | rows.append( 121 | f"| {ds_model_name} | {values['label']} | {values['prob']:.2f} |\n" 122 | ) 123 | 124 | table += "".join(rows) 125 | 126 | out_path = Path(tempfile.mkdtemp()) / "out.md" 127 | with open(out_path, "w") as f: 128 | f.write(table) 129 | return out_path 130 | 131 | def _download(self, url, ext="wav"): 132 | """Download a YouTube URL in the specified format to a temporal directory""" 133 | 134 | tmp_dir = Path(tempfile.mktemp()) 135 | ydl_opts = { 136 | # The download is quite slow, use the most compressed format that doesn't affect 137 | # the sense of the prediction (too much): 138 | # 139 | # Code Container Audio Codec Audio Bitrate Channels Still offered? 140 | # 250 WebM Opus (VBR) ~70 Kbps Stereo (2) Yes 141 | # 251 WebM Opus (VBR) <=160 Kbps Stereo (2) Yes 142 | # 40 MP4 AAC (LC) 128 Kbps Stereo (2) Yes, YT Music 143 | # 144 | # Download speeds: 145 | # 250 -> ~19s, 251 -> 30s, 40 -> ~35s 146 | # but 250 changes the predictions too munch. Using 251 as a compromise. 147 | # 148 | # From https://gist.github.com/AgentOak/34d47c65b1d28829bb17c24c04a0096f 149 | "format": "251", 150 | "postprocessors": [ 151 | { 152 | "key": "FFmpegExtractAudio", 153 | "preferredcodec": ext, 154 | } 155 | ], 156 | # render audio @16kHz to prevent resampling latter on 157 | "postprocessor_args": ["-ar", f"{self.sample_rate}"], 158 | "outtmpl": str(tmp_dir / "audio.%(ext)s"), 159 | } 160 | 161 | with youtube_dl.YoutubeDL(ydl_opts) as ydl: 162 | info = ydl.extract_info(url) 163 | 164 | if "title" in info: 165 | title = info["title"] 166 | else: 167 | title = "" # is it possible that the title metadata is unavailable? Continue anyway 168 | 169 | paths = [p for p in tmp_dir.glob(f"audio.{ext}")] 170 | assert ( 171 | len(paths) == 1 172 | ), "Something unexpected happened. Should be only one match!" 173 | 174 | return paths[0], title 175 | -------------------------------------------------------------------------------- /maest/predict.py: -------------------------------------------------------------------------------- 1 | # Prediction interface for Cog ⚙️ 2 | # Reference: https://github.com/replicate/cog/blob/main/docs/python.md 3 | 4 | import json 5 | import tempfile 6 | from itertools import chain 7 | from pathlib import Path 8 | from textwrap import wrap 9 | 10 | import numpy as np 11 | import matplotlib.pyplot as plt 12 | import pandas 13 | import seaborn as sns 14 | import youtube_dl 15 | from cog import BasePredictor, Input, Path 16 | from essentia.standard import ( 17 | MonoLoader, 18 | TensorflowPredictMAEST, 19 | ) 20 | 21 | from labels import labels 22 | 23 | 24 | def process_labels(label): 25 | genre, style = label.split("---") 26 | return f"{style}\n({genre})" 27 | 28 | 29 | processed_labels = list(map(process_labels, labels)) 30 | 31 | 32 | class Predictor(BasePredictor): 33 | def setup(self): 34 | """Load the model into memory and create the Essentia network for predictions""" 35 | self.embedding_model_file = "/models/discogs-maest-30s-pw-1.pb" 36 | self.output = "activations" 37 | self.sample_rate = 16000 38 | 39 | self.loader = MonoLoader() 40 | print("attempting to load MAEST") 41 | self.tensorflowPredictMAEST = TensorflowPredictMAEST( 42 | graphFilename=self.embedding_model_file, output="StatefulPartitionedCall:0" 43 | ) 44 | print("loaded MAEST") 45 | 46 | def predict( 47 | self, 48 | audio: Path = Input( 49 | description="Audio file to process", 50 | default=None, 51 | ), 52 | url: str = Input( 53 | description="YouTube URL to process (overrides audio input)", 54 | default=None, 55 | ), 56 | top_n: int = Input(description="Top n music styles to show", default=10), 57 | output_format: str = Input( 58 | description="Output either a bar chart visualization or a JSON blob", 59 | default="Visualization", 60 | choices=["Visualization", "JSON"], 61 | ), 62 | ) -> Path: 63 | """Run a single prediction on the model""" 64 | 65 | assert audio or url, "Specify either an audio filename or a YouTube url" 66 | 67 | # If there is a YouTube url use that. 68 | if url: 69 | if audio: 70 | print( 71 | "Warning: Both `url` and `audio` inputs were specified. " 72 | "The `url` will be process. To process the `audio` input clear the `url` input field." 73 | ) 74 | audio, title = self._download(url) 75 | else: 76 | title = audio.name 77 | 78 | print("loading audio...") 79 | self.loader.configure( 80 | sampleRate=self.sample_rate, 81 | resampleQuality=4, 82 | filename=str(audio), 83 | ) 84 | waveform = self.loader() 85 | 86 | print("running the model...") 87 | activations = self.tensorflowPredictMAEST(waveform) 88 | activations = np.squeeze(activations) 89 | if len(activations.shape) == 2: 90 | activations_mean = np.mean(activations, axis=0) 91 | else: 92 | activations_mean = activations 93 | 94 | if output_format == "JSON": 95 | out_path = Path(tempfile.mkdtemp()) / "out.json" 96 | with open(out_path, "w") as f: 97 | json.dump(dict(zip(labels, activations_mean.tolist())), f) 98 | return out_path 99 | 100 | print("plotting...") 101 | top_n_idx = np.argsort(activations_mean)[::-1][:top_n] 102 | 103 | result = { 104 | "label": list( 105 | chain( 106 | *[ 107 | [processed_labels[idx]] * activations.shape[0] 108 | for idx in top_n_idx 109 | ] 110 | ) 111 | ), 112 | "activation": list(chain(*[activations[:, idx] for idx in top_n_idx])), 113 | } 114 | result = pandas.DataFrame.from_dict(result) 115 | 116 | # Wrap title to lines of approximately 50 chars. 117 | title = wrap(title, width=50) 118 | 119 | # Allow a maximum of 2 lines of title. 120 | if len(title) > 2: 121 | title = title[:2] 122 | title[-1] += "..." 123 | 124 | title = "\n".join(title) 125 | 126 | g = sns.catplot( 127 | data=result, 128 | kind="bar", 129 | y="label", 130 | x="activation", 131 | color="#abc9ea", 132 | alpha=0.8, 133 | height=6, 134 | ) 135 | g.set(xlabel=None) 136 | g.set(ylabel=None) 137 | g.set(title=title) 138 | g.set(xlim=(0, 1)) 139 | 140 | # Add some margin so that the title is not cut. 141 | g.fig.subplots_adjust(top=0.90) 142 | 143 | out_path = Path(tempfile.mkdtemp()) / "out.png" 144 | plt.savefig(out_path) 145 | 146 | # Clean-up. 147 | if url: 148 | audio.unlink() 149 | 150 | print("done!") 151 | return out_path 152 | 153 | def _download(self, url, ext="wav"): 154 | """Download a YouTube URL in the specified format to a temporal directory""" 155 | 156 | tmp_dir = Path(tempfile.mktemp()) 157 | ydl_opts = { 158 | # The download is quite slow, use the most compressed format that doesn't affect 159 | # the sense of the prediction (too much): 160 | # 161 | # Code Container Audio Codec Audio Bitrate Channels Still offered? 162 | # 250 WebM Opus (VBR) ~70 Kbps Stereo (2) Yes 163 | # 251 WebM Opus (VBR) <=160 Kbps Stereo (2) Yes 164 | # 40 MP4 AAC (LC) 128 Kbps Stereo (2) Yes, YT Music 165 | # 166 | # Download speeds: 167 | # 250 -> ~19s, 251 -> 30s, 40 -> ~35s 168 | # but 250 changes the predictions too munch. Using 251 as a compromise. 169 | # 170 | # From https://gist.github.com/AgentOak/34d47c65b1d28829bb17c24c04a0096f 171 | "format": "251", 172 | "postprocessors": [ 173 | { 174 | "key": "FFmpegExtractAudio", 175 | "preferredcodec": ext, 176 | } 177 | ], 178 | # render audio @16kHz to prevent resampling latter on 179 | "postprocessor_args": ["-ar", f"{self.sample_rate}"], 180 | "outtmpl": str(tmp_dir / "audio.%(ext)s"), 181 | } 182 | 183 | with youtube_dl.YoutubeDL(ydl_opts) as ydl: 184 | info = ydl.extract_info(url) 185 | 186 | if "title" in info: 187 | title = info["title"] 188 | else: 189 | title = "" # is it possible that the title metadata is unavailable? Continue anyway 190 | 191 | paths = [p for p in tmp_dir.glob(f"audio.{ext}")] 192 | assert ( 193 | len(paths) == 1 194 | ), "Something unexpected happened. Should be only one match!" 195 | 196 | return paths[0], title 197 | -------------------------------------------------------------------------------- /effnet-discogs/predict.py: -------------------------------------------------------------------------------- 1 | # Prediction interface for Cog ⚙️ 2 | # Reference: https://github.com/replicate/cog/blob/main/docs/python.md 3 | 4 | import json 5 | import tempfile 6 | from itertools import chain 7 | from pathlib import Path 8 | from textwrap import wrap 9 | 10 | import numpy as np 11 | import matplotlib.pyplot as plt 12 | import pandas 13 | import seaborn as sns 14 | import youtube_dl 15 | from cog import BasePredictor, Input, Path 16 | from essentia.standard import ( 17 | MonoLoader, 18 | TensorflowPredictEffnetDiscogs, 19 | TensorflowPredict2D, 20 | ) 21 | 22 | from labels import labels 23 | 24 | 25 | def process_labels(label): 26 | genre, style = label.split("---") 27 | return f"{style}\n({genre})" 28 | 29 | 30 | processed_labels = list(map(process_labels, labels)) 31 | 32 | 33 | class Predictor(BasePredictor): 34 | def setup(self): 35 | """Load the model into memory and create the Essentia network for predictions""" 36 | 37 | self.embedding_model_file = "/models/discogs-effnet-bs64-1.pb" 38 | self.classification_model_file = "/models/genre_discogs400-discogs-effnet-1.pb" 39 | self.output = "activations" 40 | self.sample_rate = 16000 41 | 42 | self.loader = MonoLoader() 43 | self.tensorflowPredictEffnetDiscogs = TensorflowPredictEffnetDiscogs( 44 | graphFilename=self.embedding_model_file, 45 | output="PartitionedCall:1", 46 | patchHopSize=128, # remove overlap between patches for efficiency 47 | ) 48 | self.classification_model = TensorflowPredict2D( 49 | graphFilename=self.classification_model_file, 50 | input="serving_default_model_Placeholder", 51 | output="PartitionedCall:0", 52 | ) 53 | 54 | def predict( 55 | self, 56 | audio: Path = Input( 57 | description="Audio file to process", 58 | default=None, 59 | ), 60 | url: str = Input( 61 | description="YouTube URL to process (overrides audio input)", 62 | default=None, 63 | ), 64 | top_n: int = Input(description="Top n music styles to show", default=10), 65 | output_format: str = Input( 66 | description="Output either a bar chart visualization or a JSON blob", 67 | default="Visualization", 68 | choices=["Visualization", "JSON"], 69 | ), 70 | ) -> Path: 71 | """Run a single prediction on the model""" 72 | 73 | assert audio or url, "Specify either an audio filename or a YouTube url" 74 | 75 | # If there is a YouTube url use that. 76 | if url: 77 | if audio: 78 | print( 79 | "Warning: Both `url` and `audio` inputs were specified. " 80 | "The `url` will be process. To process the `audio` input clear the `url` input field." 81 | ) 82 | audio, title = self._download(url) 83 | else: 84 | title = audio.name 85 | 86 | print("loading audio...") 87 | self.loader.configure( 88 | sampleRate=self.sample_rate, 89 | resampleQuality=4, 90 | filename=str(audio), 91 | ) 92 | waveform = self.loader() 93 | 94 | print("running the model...") 95 | embeddings = self.tensorflowPredictEffnetDiscogs(waveform) 96 | activations = self.classification_model(embeddings) 97 | activations_mean = np.mean(activations, axis=0) 98 | 99 | if output_format == "JSON": 100 | out_path = Path(tempfile.mkdtemp()) / "out.json" 101 | with open(out_path, "w") as f: 102 | json.dump(dict(zip(labels, activations_mean.tolist())), f) 103 | return out_path 104 | 105 | print("plotting...") 106 | top_n_idx = np.argsort(activations_mean)[::-1][:top_n] 107 | 108 | result = { 109 | "label": list( 110 | chain( 111 | *[ 112 | [processed_labels[idx]] * activations.shape[0] 113 | for idx in top_n_idx 114 | ] 115 | ) 116 | ), 117 | "activation": list(chain(*[activations[:, idx] for idx in top_n_idx])), 118 | } 119 | result = pandas.DataFrame.from_dict(result) 120 | 121 | # Wrap title to lines of approximately 50 chars. 122 | title = wrap(title, width=50) 123 | 124 | # Allow a maximum of 2 lines of title. 125 | if len(title) > 2: 126 | title = title[:2] 127 | title[-1] += "..." 128 | 129 | title = "\n".join(title) 130 | 131 | g = sns.catplot( 132 | data=result, 133 | kind="bar", 134 | y="label", 135 | x="activation", 136 | color="#abc9ea", 137 | alpha=0.8, 138 | height=6, 139 | ) 140 | g.set(xlabel=None) 141 | g.set(ylabel=None) 142 | g.set(title=title) 143 | g.set(xlim=(0, 1)) 144 | 145 | # Add some margin so that the title is not cut. 146 | g.fig.subplots_adjust(top=0.90) 147 | 148 | out_path = Path(tempfile.mkdtemp()) / "out.png" 149 | plt.savefig(out_path) 150 | 151 | # Clean-up. 152 | if url: 153 | audio.unlink() 154 | 155 | print("done!") 156 | return out_path 157 | 158 | def _download(self, url, ext="wav"): 159 | """Download a YouTube URL in the specified format to a temporal directory""" 160 | 161 | tmp_dir = Path(tempfile.mktemp()) 162 | ydl_opts = { 163 | # The download is quite slow, use the most compressed format that doesn't affect 164 | # the sense of the prediction (too much): 165 | # 166 | # Code Container Audio Codec Audio Bitrate Channels Still offered? 167 | # 250 WebM Opus (VBR) ~70 Kbps Stereo (2) Yes 168 | # 251 WebM Opus (VBR) <=160 Kbps Stereo (2) Yes 169 | # 40 MP4 AAC (LC) 128 Kbps Stereo (2) Yes, YT Music 170 | # 171 | # Download speeds: 172 | # 250 -> ~19s, 251 -> 30s, 40 -> ~35s 173 | # but 250 changes the predictions too munch. Using 251 as a compromise. 174 | # 175 | # From https://gist.github.com/AgentOak/34d47c65b1d28829bb17c24c04a0096f 176 | "format": "251", 177 | "postprocessors": [ 178 | { 179 | "key": "FFmpegExtractAudio", 180 | "preferredcodec": ext, 181 | } 182 | ], 183 | # render audio @16kHz to prevent resampling latter on 184 | "postprocessor_args": ["-ar", f"{self.sample_rate}"], 185 | "outtmpl": str(tmp_dir / "audio.%(ext)s"), 186 | } 187 | 188 | with youtube_dl.YoutubeDL(ydl_opts) as ydl: 189 | info = ydl.extract_info(url) 190 | 191 | if "title" in info: 192 | title = info["title"] 193 | else: 194 | title = "" # is it possible that the title metadata is unavailable? Continue anyway 195 | 196 | paths = [p for p in tmp_dir.glob(f"audio.{ext}")] 197 | assert ( 198 | len(paths) == 1 199 | ), "Something unexpected happened. Should be only one match!" 200 | 201 | return paths[0], title 202 | -------------------------------------------------------------------------------- /music-arousal-valence/predict.py: -------------------------------------------------------------------------------- 1 | # Prediction interface for Cog ⚙️ 2 | # Reference: https://github.com/replicate/cog/blob/main/docs/python.md 3 | 4 | import json 5 | import tempfile 6 | 7 | import pandas as pd 8 | import numpy as np 9 | import seaborn as sns 10 | import youtube_dl 11 | from cog import BasePredictor, Input, Path 12 | from essentia.standard import ( 13 | MonoLoader, 14 | TensorflowPredictVGGish, 15 | TensorflowPredictMusiCNN, 16 | TensorflowPredict2D, 17 | ) 18 | from matplotlib import pyplot as plt 19 | 20 | 21 | MODELS_HOME = Path("/models") 22 | 23 | 24 | class Predictor(BasePredictor): 25 | def setup(self): 26 | """Load the model into memory and create the Essentia network for predictions""" 27 | 28 | self.musicnn_graph = str(MODELS_HOME / "msd-musicnn-1.pb") 29 | self.vggish_graph = str(MODELS_HOME / "audioset-vggish-3.pb") 30 | 31 | self.sample_rate = 16000 32 | 33 | self.loader = MonoLoader() 34 | self.embeddings = { 35 | "msd-musicnn": TensorflowPredictMusiCNN( 36 | graphFilename=self.musicnn_graph, 37 | output="model/dense/BiasAdd", 38 | patchHopSize=187, 39 | ), 40 | "audioset-vggish": TensorflowPredictVGGish( 41 | graphFilename=self.vggish_graph, 42 | output="model/vggish/embeddings", 43 | patchHopSize=96, 44 | ), 45 | } 46 | 47 | self.input = "flatten_in_input" 48 | self.output = "dense_out" 49 | # Algorithms for specific models. 50 | self.classifiers = {} 51 | 52 | datasets = ("emomusic", "deam", "muse") 53 | # datasets = ("deam", "muse") 54 | for dataset in datasets: 55 | for embedding in self.embeddings.keys(): 56 | classifier_name = f"{dataset}-{embedding}" 57 | graph_filename = str(MODELS_HOME / f"{classifier_name}-1.pb") 58 | self.classifiers[classifier_name] = TensorflowPredict2D( 59 | graphFilename=graph_filename, 60 | input=self.input, 61 | output=self.output, 62 | ) 63 | 64 | def predict( 65 | self, 66 | audio: Path = Input( 67 | description="Audio file to process", 68 | default=None, 69 | ), 70 | url: str = Input( 71 | description="YouTube URL to process (overrides audio input)", 72 | default=None, 73 | ), 74 | embedding_type: str = Input( 75 | description="Embedding type to use: vggish, or musicnn", 76 | default="msd-musicnn", 77 | choices=["msd-musicnn", "audioset-vggish"], 78 | ), 79 | dataset: str = Input( 80 | description="Arousal/Valence training dataset", 81 | default="emomusic", 82 | choices=["emomusic", "deam", "muse"], 83 | ), 84 | output_format: str = Input( 85 | description="Output either a bar chart visualization or a JSON blob", 86 | default="Visualization", 87 | choices=["Visualization", "JSON"], 88 | ), 89 | ) -> Path: 90 | """Run a single prediction on the model""" 91 | 92 | assert audio or url, "Specify either an audio filename or a YouTube url" 93 | 94 | # If there is a YouTube url use that. 95 | if url: 96 | if audio: 97 | print( 98 | "Warning: Both `url` and `audio` inputs were specified. " 99 | "The `url` will be process. To process the `audio` input clear the `url` input field." 100 | ) 101 | audio, title = self._download(url) 102 | else: 103 | title = audio.name 104 | 105 | print("loading audio...") 106 | self.loader.configure( 107 | sampleRate=self.sample_rate, 108 | filename=str(audio), 109 | resampleQuality=4, 110 | ) 111 | waveform = self.loader() 112 | 113 | embeddings = self.embeddings[embedding_type](waveform) 114 | 115 | classifier_name = f"{dataset}-{embedding_type}" 116 | results = self.classifiers[classifier_name](embeddings) 117 | results = np.mean(results.squeeze(), axis=0) 118 | 119 | # Manual normalization (1, 9) -> (-1, 1) 120 | results = (results - 5) / 4 121 | 122 | valence = results[0] 123 | arousal = results[1] 124 | 125 | if output_format == "JSON": 126 | out_path = Path(tempfile.mkdtemp()) / "out.json" 127 | with open(out_path, "w") as f: 128 | json.dump({"valence": float(valence), "arousal": float(arousal)}, f) 129 | return out_path 130 | 131 | sns.set_style("darkgrid") 132 | g = sns.lmplot( 133 | data=pd.DataFrame({"arousal": [arousal], "valence": [valence]}), 134 | x="valence", 135 | y="arousal", 136 | markers="x", 137 | scatter_kws={"s": 100}, 138 | ) 139 | 140 | g.set(ylim=(-1, 1)) 141 | g.set(xlim=(-1, 1)) 142 | plt.plot([-1, 1], [0, 0], linewidth=1.5, color="grey") 143 | plt.plot([0, 0], [-1, 1], linewidth=1.5, color="grey") 144 | plt.subplots_adjust(top=0.95, bottom=0.1, left=0.15) 145 | plt.title(title) 146 | 147 | out_path = Path(tempfile.mkdtemp()) / "out.png" 148 | plt.savefig(out_path) 149 | 150 | print("done!") 151 | return out_path 152 | 153 | def _download(self, url, ext="wav"): 154 | """Download a YouTube URL in the specified format to a temporal directory""" 155 | 156 | tmp_dir = Path(tempfile.mktemp()) 157 | ydl_opts = { 158 | # The download is quite slow, use the most compressed format that doesn't affect 159 | # the sense of the prediction (too much): 160 | # 161 | # Code Container Audio Codec Audio Bitrate Channels Still offered? 162 | # 250 WebM Opus (VBR) ~70 Kbps Stereo (2) Yes 163 | # 251 WebM Opus (VBR) <=160 Kbps Stereo (2) Yes 164 | # 40 MP4 AAC (LC) 128 Kbps Stereo (2) Yes, YT Music 165 | # 166 | # Download speeds: 167 | # 250 -> ~19s, 251 -> 30s, 40 -> ~35s 168 | # but 250 changes the predictions too munch. Using 251 as a compromise. 169 | # 170 | # From https://gist.github.com/AgentOak/34d47c65b1d28829bb17c24c04a0096f 171 | "format": "251", 172 | "postprocessors": [ 173 | { 174 | "key": "FFmpegExtractAudio", 175 | "preferredcodec": ext, 176 | } 177 | ], 178 | # render audio @16kHz to prevent resampling latter on 179 | "postprocessor_args": ["-ar", f"{self.sample_rate}"], 180 | "outtmpl": str(tmp_dir / "audio.%(ext)s"), 181 | } 182 | 183 | with youtube_dl.YoutubeDL(ydl_opts) as ydl: 184 | info = ydl.extract_info(url) 185 | 186 | if "title" in info: 187 | title = info["title"] 188 | else: 189 | title = "" # is it possible that the title metadata is unavailable? Continue anyway 190 | 191 | paths = [p for p in tmp_dir.glob(f"audio.{ext}")] 192 | assert len(paths) == 1, ( 193 | "Something unexpected happened. Should be only one match!" 194 | ) 195 | 196 | return paths[0], title 197 | -------------------------------------------------------------------------------- /music-approachability-engagement/predict.py: -------------------------------------------------------------------------------- 1 | # Prediction interface for Cog ⚙️ 2 | # Reference: https://github.com/replicate/cog/blob/main/docs/python.md 3 | 4 | import tempfile 5 | 6 | from cog import BasePredictor, Input, Path 7 | from essentia.standard import MonoLoader, TensorflowPredictEffnetDiscogs, TensorflowPredict2D 8 | import numpy as np 9 | import youtube_dl 10 | 11 | from models import models 12 | 13 | MODELS_HOME = Path("/models") 14 | 15 | 16 | def initialize_table(model_type: str, title: str): 17 | if model_type == "regression": 18 | title = "# %s\n" % title 19 | header = "| model | value |\n" 20 | bar = "|---|---|\n" 21 | table = title + header + bar 22 | else: 23 | title = "# %s\n" % title 24 | header = "| model | class | activation |\n" 25 | bar = "|---|---|---|\n" 26 | table = title + header + bar 27 | return table 28 | 29 | class Predictor(BasePredictor): 30 | def setup(self): 31 | """Load the model into memory and create the Essentia network for predictions""" 32 | 33 | self.model = str(MODELS_HOME / "discogs-effnet-bs64-1.pb") 34 | self.input = "model/Placeholder" 35 | self.output = "model/Softmax" 36 | self.sample_rate = 16000 37 | 38 | self.loader = MonoLoader() 39 | self.tensorflowPredictEffnetDiscogs = TensorflowPredictEffnetDiscogs( 40 | graphFilename=self.model, 41 | output="PartitionedCall:1", 42 | patchHopSize=128, 43 | ) 44 | 45 | # Algorithms for specific models. 46 | self.classifiers = {} 47 | # get model_types from dict keys 48 | model_types = models.keys() 49 | print(f"model_types: {model_types}") 50 | # load all models in self.classifiers for all model_types 51 | all_models = [models[model_type][key] for model_type in model_types for key in models[model_type].keys()] 52 | # build a dict of dicts to handle classifiers for each model type 53 | for model in all_models: 54 | modelFilename = str(MODELS_HOME / f"{model['name']}.pb") 55 | self.classifiers[model["name"]] = TensorflowPredict2D( 56 | graphFilename=modelFilename, 57 | input=self.input, 58 | output="model/Identity" if "regression" in model["name"] else self.output, 59 | ) 60 | 61 | def predict( 62 | self, 63 | audio: Path = Input( 64 | description="Audio file to process", 65 | default=None, 66 | ), 67 | url: str = Input( 68 | description="YouTube URL to process (overrides audio input)", 69 | default=None, 70 | ), 71 | model_type: str = Input( 72 | description="Regards to the downstream type: 2class, 3class, regression", 73 | default= "regression", 74 | choices=["regression", "2 classes", "3 classes"] 75 | ), 76 | ) -> Path: 77 | """Run a single prediction on the model""" 78 | 79 | assert audio or url, "Specify either an audio filename or a YouTube url" 80 | 81 | #If there is a YouTube url use that. 82 | if url: 83 | if audio: 84 | print( 85 | "Warning: Both `url` and `audio` inputs were specified. " 86 | "The `url` will be process. To process the `audio` input clear the `url` input field." 87 | ) 88 | audio, title = self._download(url) 89 | else: 90 | title = audio.name 91 | 92 | print("loading audio...") 93 | self.loader.configure(sampleRate=self.sample_rate, filename=str(audio), resampleQuality=4) 94 | waveform = self.loader() 95 | 96 | table = self._run_models(waveform, model_type, title) 97 | 98 | out_path = Path(tempfile.mkdtemp()) / "out.md" 99 | with open(out_path, "w") as f: 100 | f.write(table) 101 | 102 | print("done!") 103 | return out_path 104 | 105 | def _download(self, url, ext="wav"): 106 | """Download a YouTube URL in the specified format to a temporal directory""" 107 | 108 | tmp_dir = Path(tempfile.mktemp()) 109 | ydl_opts = { 110 | # The download is quite slow, use the most compressed format that doesn't affect 111 | # the sense of the prediction (too much): 112 | # 113 | # Code Container Audio Codec Audio Bitrate Channels Still offered? 114 | # 250 WebM Opus (VBR) ~70 Kbps Stereo (2) Yes 115 | # 251 WebM Opus (VBR) <=160 Kbps Stereo (2) Yes 116 | # 40 MP4 AAC (LC) 128 Kbps Stereo (2) Yes, YT Music 117 | # 118 | # Download speeds: 119 | # 250 -> ~19s, 251 -> 30s, 40 -> ~35s 120 | # but 250 changes the predictions too munch. Using 251 as a compromise. 121 | # 122 | # From https://gist.github.com/AgentOak/34d47c65b1d28829bb17c24c04a0096f 123 | "format": "251", 124 | "postprocessors": [ 125 | { 126 | "key": "FFmpegExtractAudio", 127 | "preferredcodec": ext, 128 | } 129 | ], 130 | # render audio @16kHz to prevent resampling latter on 131 | "postprocessor_args": ["-ar", f"{self.sample_rate}"], 132 | "outtmpl": str(tmp_dir / "audio.%(ext)s"), 133 | } 134 | 135 | with youtube_dl.YoutubeDL(ydl_opts) as ydl: 136 | info = ydl.extract_info(url) 137 | 138 | if "title" in info: 139 | title = info["title"] 140 | else: 141 | title = "" # is it possible that the title metadata is unavailable? Continue anyway 142 | 143 | paths = [p for p in tmp_dir.glob(f"audio.{ext}")] 144 | assert ( 145 | len(paths) == 1 146 | ), "Something unexpected happened. Should be only one match!" 147 | 148 | return paths[0], title 149 | 150 | def _run_models(self, waveform: np.ndarray, model_type: str, title: str): 151 | embeddings = self.tensorflowPredictEffnetDiscogs(waveform) 152 | 153 | 154 | # the header and bar table should change for a regression model 155 | table = initialize_table(model_type, title) 156 | 157 | # define a list of models for the model_type 158 | model_list = [models[model_type][key] for key in models[model_type].keys()] 159 | 160 | print("running classification heads...") 161 | if model_type == "regression": 162 | # predict with each regression model 163 | for model in model_list: 164 | results = self.classifiers[model["name"]](embeddings) 165 | average = np.mean(results.squeeze(), axis=0) 166 | std = np.std(results.squeeze(), axis=0) 167 | 168 | value = f"{average:.2f}±{std:.2f}" 169 | 170 | table += f"{model['name']} | {value}\n" 171 | if model != model_list[-1]: 172 | table += "|||\n" # separator for readability 173 | else: 174 | # predict with each classification model 175 | for model in model_list: 176 | results = self.classifiers[model["name"]](embeddings) 177 | average = np.mean(results.squeeze(), axis=0) 178 | 179 | labels = [] 180 | activations = [] 181 | 182 | top_class = np.argmax(average) 183 | for i, label in enumerate(model["labels"]): 184 | labels.append(label) 185 | if i == top_class: 186 | activations.append(f"**{average[i]:.2f}**") 187 | else: 188 | activations.append(f"{average[i]:.2f}") 189 | 190 | labels = "
".join(labels) 191 | activations = "
".join(activations) 192 | 193 | table += f"{model['name']} | {labels} | {activations}\n" 194 | if model != model_list[-1]: 195 | table += "||||\n" # separator for readability 196 | return table 197 | -------------------------------------------------------------------------------- /maest/labels.py: -------------------------------------------------------------------------------- 1 | labels = [ 2 | "Blues---Boogie Woogie", 3 | "Blues---Chicago Blues", 4 | "Blues---Country Blues", 5 | "Blues---Delta Blues", 6 | "Blues---Electric Blues", 7 | "Blues---Harmonica Blues", 8 | "Blues---Jump Blues", 9 | "Blues---Louisiana Blues", 10 | "Blues---Modern Electric Blues", 11 | "Blues---Piano Blues", 12 | "Blues---Rhythm & Blues", 13 | "Blues---Texas Blues", 14 | "Brass & Military---Brass Band", 15 | "Brass & Military---Marches", 16 | "Brass & Military---Military", 17 | "Children's---Educational", 18 | "Children's---Nursery Rhymes", 19 | "Children's---Story", 20 | "Classical---Baroque", 21 | "Classical---Choral", 22 | "Classical---Classical", 23 | "Classical---Contemporary", 24 | "Classical---Impressionist", 25 | "Classical---Medieval", 26 | "Classical---Modern", 27 | "Classical---Neo-Classical", 28 | "Classical---Neo-Romantic", 29 | "Classical---Opera", 30 | "Classical---Post-Modern", 31 | "Classical---Renaissance", 32 | "Classical---Romantic", 33 | "Electronic---Abstract", 34 | "Electronic---Acid", 35 | "Electronic---Acid House", 36 | "Electronic---Acid Jazz", 37 | "Electronic---Ambient", 38 | "Electronic---Bassline", 39 | "Electronic---Beatdown", 40 | "Electronic---Berlin-School", 41 | "Electronic---Big Beat", 42 | "Electronic---Bleep", 43 | "Electronic---Breakbeat", 44 | "Electronic---Breakcore", 45 | "Electronic---Breaks", 46 | "Electronic---Broken Beat", 47 | "Electronic---Chillwave", 48 | "Electronic---Chiptune", 49 | "Electronic---Dance-pop", 50 | "Electronic---Dark Ambient", 51 | "Electronic---Darkwave", 52 | "Electronic---Deep House", 53 | "Electronic---Deep Techno", 54 | "Electronic---Disco", 55 | "Electronic---Disco Polo", 56 | "Electronic---Donk", 57 | "Electronic---Downtempo", 58 | "Electronic---Drone", 59 | "Electronic---Drum n Bass", 60 | "Electronic---Dub", 61 | "Electronic---Dub Techno", 62 | "Electronic---Dubstep", 63 | "Electronic---Dungeon Synth", 64 | "Electronic---EBM", 65 | "Electronic---Electro", 66 | "Electronic---Electro House", 67 | "Electronic---Electroclash", 68 | "Electronic---Euro House", 69 | "Electronic---Euro-Disco", 70 | "Electronic---Eurobeat", 71 | "Electronic---Eurodance", 72 | "Electronic---Experimental", 73 | "Electronic---Freestyle", 74 | "Electronic---Future Jazz", 75 | "Electronic---Gabber", 76 | "Electronic---Garage House", 77 | "Electronic---Ghetto", 78 | "Electronic---Ghetto House", 79 | "Electronic---Glitch", 80 | "Electronic---Goa Trance", 81 | "Electronic---Grime", 82 | "Electronic---Halftime", 83 | "Electronic---Hands Up", 84 | "Electronic---Happy Hardcore", 85 | "Electronic---Hard House", 86 | "Electronic---Hard Techno", 87 | "Electronic---Hard Trance", 88 | "Electronic---Hardcore", 89 | "Electronic---Hardstyle", 90 | "Electronic---Hi NRG", 91 | "Electronic---Hip Hop", 92 | "Electronic---Hip-House", 93 | "Electronic---House", 94 | "Electronic---IDM", 95 | "Electronic---Illbient", 96 | "Electronic---Industrial", 97 | "Electronic---Italo House", 98 | "Electronic---Italo-Disco", 99 | "Electronic---Italodance", 100 | "Electronic---Jazzdance", 101 | "Electronic---Juke", 102 | "Electronic---Jumpstyle", 103 | "Electronic---Jungle", 104 | "Electronic---Latin", 105 | "Electronic---Leftfield", 106 | "Electronic---Makina", 107 | "Electronic---Minimal", 108 | "Electronic---Minimal Techno", 109 | "Electronic---Modern Classical", 110 | "Electronic---Musique Concrète", 111 | "Electronic---Neofolk", 112 | "Electronic---New Age", 113 | "Electronic---New Beat", 114 | "Electronic---New Wave", 115 | "Electronic---Noise", 116 | "Electronic---Nu-Disco", 117 | "Electronic---Power Electronics", 118 | "Electronic---Progressive Breaks", 119 | "Electronic---Progressive House", 120 | "Electronic---Progressive Trance", 121 | "Electronic---Psy-Trance", 122 | "Electronic---Rhythmic Noise", 123 | "Electronic---Schranz", 124 | "Electronic---Sound Collage", 125 | "Electronic---Speed Garage", 126 | "Electronic---Speedcore", 127 | "Electronic---Synth-pop", 128 | "Electronic---Synthwave", 129 | "Electronic---Tech House", 130 | "Electronic---Tech Trance", 131 | "Electronic---Techno", 132 | "Electronic---Trance", 133 | "Electronic---Tribal", 134 | "Electronic---Tribal House", 135 | "Electronic---Trip Hop", 136 | "Electronic---Tropical House", 137 | "Electronic---UK Garage", 138 | "Electronic---Vaporwave", 139 | "Folk, World, & Country---African", 140 | "Folk, World, & Country---Bluegrass", 141 | "Folk, World, & Country---Cajun", 142 | "Folk, World, & Country---Canzone Napoletana", 143 | "Folk, World, & Country---Catalan Music", 144 | "Folk, World, & Country---Celtic", 145 | "Folk, World, & Country---Country", 146 | "Folk, World, & Country---Fado", 147 | "Folk, World, & Country---Flamenco", 148 | "Folk, World, & Country---Folk", 149 | "Folk, World, & Country---Gospel", 150 | "Folk, World, & Country---Highlife", 151 | "Folk, World, & Country---Hillbilly", 152 | "Folk, World, & Country---Hindustani", 153 | "Folk, World, & Country---Honky Tonk", 154 | "Folk, World, & Country---Indian Classical", 155 | "Folk, World, & Country---Laïkó", 156 | "Folk, World, & Country---Nordic", 157 | "Folk, World, & Country---Pacific", 158 | "Folk, World, & Country---Polka", 159 | "Folk, World, & Country---Raï", 160 | "Folk, World, & Country---Romani", 161 | "Folk, World, & Country---Soukous", 162 | "Folk, World, & Country---Séga", 163 | "Folk, World, & Country---Volksmusik", 164 | "Folk, World, & Country---Zouk", 165 | "Folk, World, & Country---Éntekhno", 166 | "Funk / Soul---Afrobeat", 167 | "Funk / Soul---Boogie", 168 | "Funk / Soul---Contemporary R&B", 169 | "Funk / Soul---Disco", 170 | "Funk / Soul---Free Funk", 171 | "Funk / Soul---Funk", 172 | "Funk / Soul---Gospel", 173 | "Funk / Soul---Neo Soul", 174 | "Funk / Soul---New Jack Swing", 175 | "Funk / Soul---P.Funk", 176 | "Funk / Soul---Psychedelic", 177 | "Funk / Soul---Rhythm & Blues", 178 | "Funk / Soul---Soul", 179 | "Funk / Soul---Swingbeat", 180 | "Funk / Soul---UK Street Soul", 181 | "Hip Hop---Bass Music", 182 | "Hip Hop---Boom Bap", 183 | "Hip Hop---Bounce", 184 | "Hip Hop---Britcore", 185 | "Hip Hop---Cloud Rap", 186 | "Hip Hop---Conscious", 187 | "Hip Hop---Crunk", 188 | "Hip Hop---Cut-up/DJ", 189 | "Hip Hop---DJ Battle Tool", 190 | "Hip Hop---Electro", 191 | "Hip Hop---G-Funk", 192 | "Hip Hop---Gangsta", 193 | "Hip Hop---Grime", 194 | "Hip Hop---Hardcore Hip-Hop", 195 | "Hip Hop---Horrorcore", 196 | "Hip Hop---Instrumental", 197 | "Hip Hop---Jazzy Hip-Hop", 198 | "Hip Hop---Miami Bass", 199 | "Hip Hop---Pop Rap", 200 | "Hip Hop---Ragga HipHop", 201 | "Hip Hop---RnB/Swing", 202 | "Hip Hop---Screw", 203 | "Hip Hop---Thug Rap", 204 | "Hip Hop---Trap", 205 | "Hip Hop---Trip Hop", 206 | "Hip Hop---Turntablism", 207 | "Jazz---Afro-Cuban Jazz", 208 | "Jazz---Afrobeat", 209 | "Jazz---Avant-garde Jazz", 210 | "Jazz---Big Band", 211 | "Jazz---Bop", 212 | "Jazz---Bossa Nova", 213 | "Jazz---Contemporary Jazz", 214 | "Jazz---Cool Jazz", 215 | "Jazz---Dixieland", 216 | "Jazz---Easy Listening", 217 | "Jazz---Free Improvisation", 218 | "Jazz---Free Jazz", 219 | "Jazz---Fusion", 220 | "Jazz---Gypsy Jazz", 221 | "Jazz---Hard Bop", 222 | "Jazz---Jazz-Funk", 223 | "Jazz---Jazz-Rock", 224 | "Jazz---Latin Jazz", 225 | "Jazz---Modal", 226 | "Jazz---Post Bop", 227 | "Jazz---Ragtime", 228 | "Jazz---Smooth Jazz", 229 | "Jazz---Soul-Jazz", 230 | "Jazz---Space-Age", 231 | "Jazz---Swing", 232 | "Latin---Afro-Cuban", 233 | "Latin---Baião", 234 | "Latin---Batucada", 235 | "Latin---Beguine", 236 | "Latin---Bolero", 237 | "Latin---Boogaloo", 238 | "Latin---Bossanova", 239 | "Latin---Cha-Cha", 240 | "Latin---Charanga", 241 | "Latin---Compas", 242 | "Latin---Cubano", 243 | "Latin---Cumbia", 244 | "Latin---Descarga", 245 | "Latin---Forró", 246 | "Latin---Guaguancó", 247 | "Latin---Guajira", 248 | "Latin---Guaracha", 249 | "Latin---MPB", 250 | "Latin---Mambo", 251 | "Latin---Mariachi", 252 | "Latin---Merengue", 253 | "Latin---Norteño", 254 | "Latin---Nueva Cancion", 255 | "Latin---Pachanga", 256 | "Latin---Porro", 257 | "Latin---Ranchera", 258 | "Latin---Reggaeton", 259 | "Latin---Rumba", 260 | "Latin---Salsa", 261 | "Latin---Samba", 262 | "Latin---Son", 263 | "Latin---Son Montuno", 264 | "Latin---Tango", 265 | "Latin---Tejano", 266 | "Latin---Vallenato", 267 | "Non-Music---Audiobook", 268 | "Non-Music---Comedy", 269 | "Non-Music---Dialogue", 270 | "Non-Music---Education", 271 | "Non-Music---Field Recording", 272 | "Non-Music---Interview", 273 | "Non-Music---Monolog", 274 | "Non-Music---Poetry", 275 | "Non-Music---Political", 276 | "Non-Music---Promotional", 277 | "Non-Music---Radioplay", 278 | "Non-Music---Religious", 279 | "Non-Music---Spoken Word", 280 | "Pop---Ballad", 281 | "Pop---Bollywood", 282 | "Pop---Bubblegum", 283 | "Pop---Chanson", 284 | "Pop---City Pop", 285 | "Pop---Europop", 286 | "Pop---Indie Pop", 287 | "Pop---J-pop", 288 | "Pop---K-pop", 289 | "Pop---Kayōkyoku", 290 | "Pop---Light Music", 291 | "Pop---Music Hall", 292 | "Pop---Novelty", 293 | "Pop---Parody", 294 | "Pop---Schlager", 295 | "Pop---Vocal", 296 | "Reggae---Calypso", 297 | "Reggae---Dancehall", 298 | "Reggae---Dub", 299 | "Reggae---Lovers Rock", 300 | "Reggae---Ragga", 301 | "Reggae---Reggae", 302 | "Reggae---Reggae-Pop", 303 | "Reggae---Rocksteady", 304 | "Reggae---Roots Reggae", 305 | "Reggae---Ska", 306 | "Reggae---Soca", 307 | "Rock---AOR", 308 | "Rock---Acid Rock", 309 | "Rock---Acoustic", 310 | "Rock---Alternative Rock", 311 | "Rock---Arena Rock", 312 | "Rock---Art Rock", 313 | "Rock---Atmospheric Black Metal", 314 | "Rock---Avantgarde", 315 | "Rock---Beat", 316 | "Rock---Black Metal", 317 | "Rock---Blues Rock", 318 | "Rock---Brit Pop", 319 | "Rock---Classic Rock", 320 | "Rock---Coldwave", 321 | "Rock---Country Rock", 322 | "Rock---Crust", 323 | "Rock---Death Metal", 324 | "Rock---Deathcore", 325 | "Rock---Deathrock", 326 | "Rock---Depressive Black Metal", 327 | "Rock---Doo Wop", 328 | "Rock---Doom Metal", 329 | "Rock---Dream Pop", 330 | "Rock---Emo", 331 | "Rock---Ethereal", 332 | "Rock---Experimental", 333 | "Rock---Folk Metal", 334 | "Rock---Folk Rock", 335 | "Rock---Funeral Doom Metal", 336 | "Rock---Funk Metal", 337 | "Rock---Garage Rock", 338 | "Rock---Glam", 339 | "Rock---Goregrind", 340 | "Rock---Goth Rock", 341 | "Rock---Gothic Metal", 342 | "Rock---Grindcore", 343 | "Rock---Grunge", 344 | "Rock---Hard Rock", 345 | "Rock---Hardcore", 346 | "Rock---Heavy Metal", 347 | "Rock---Indie Rock", 348 | "Rock---Industrial", 349 | "Rock---Krautrock", 350 | "Rock---Lo-Fi", 351 | "Rock---Lounge", 352 | "Rock---Math Rock", 353 | "Rock---Melodic Death Metal", 354 | "Rock---Melodic Hardcore", 355 | "Rock---Metalcore", 356 | "Rock---Mod", 357 | "Rock---Neofolk", 358 | "Rock---New Wave", 359 | "Rock---No Wave", 360 | "Rock---Noise", 361 | "Rock---Noisecore", 362 | "Rock---Nu Metal", 363 | "Rock---Oi", 364 | "Rock---Parody", 365 | "Rock---Pop Punk", 366 | "Rock---Pop Rock", 367 | "Rock---Pornogrind", 368 | "Rock---Post Rock", 369 | "Rock---Post-Hardcore", 370 | "Rock---Post-Metal", 371 | "Rock---Post-Punk", 372 | "Rock---Power Metal", 373 | "Rock---Power Pop", 374 | "Rock---Power Violence", 375 | "Rock---Prog Rock", 376 | "Rock---Progressive Metal", 377 | "Rock---Psychedelic Rock", 378 | "Rock---Psychobilly", 379 | "Rock---Pub Rock", 380 | "Rock---Punk", 381 | "Rock---Rock & Roll", 382 | "Rock---Rockabilly", 383 | "Rock---Shoegaze", 384 | "Rock---Ska", 385 | "Rock---Sludge Metal", 386 | "Rock---Soft Rock", 387 | "Rock---Southern Rock", 388 | "Rock---Space Rock", 389 | "Rock---Speed Metal", 390 | "Rock---Stoner Rock", 391 | "Rock---Surf", 392 | "Rock---Symphonic Rock", 393 | "Rock---Technical Death Metal", 394 | "Rock---Thrash", 395 | "Rock---Twist", 396 | "Rock---Viking Metal", 397 | "Rock---Yé-Yé", 398 | "Stage & Screen---Musical", 399 | "Stage & Screen---Score", 400 | "Stage & Screen---Soundtrack", 401 | "Stage & Screen---Theme", 402 | ] 403 | -------------------------------------------------------------------------------- /effnet-discogs/labels.py: -------------------------------------------------------------------------------- 1 | labels = [ 2 | "Blues---Boogie Woogie", 3 | "Blues---Chicago Blues", 4 | "Blues---Country Blues", 5 | "Blues---Delta Blues", 6 | "Blues---Electric Blues", 7 | "Blues---Harmonica Blues", 8 | "Blues---Jump Blues", 9 | "Blues---Louisiana Blues", 10 | "Blues---Modern Electric Blues", 11 | "Blues---Piano Blues", 12 | "Blues---Rhythm & Blues", 13 | "Blues---Texas Blues", 14 | "Brass & Military---Brass Band", 15 | "Brass & Military---Marches", 16 | "Brass & Military---Military", 17 | "Children's---Educational", 18 | "Children's---Nursery Rhymes", 19 | "Children's---Story", 20 | "Classical---Baroque", 21 | "Classical---Choral", 22 | "Classical---Classical", 23 | "Classical---Contemporary", 24 | "Classical---Impressionist", 25 | "Classical---Medieval", 26 | "Classical---Modern", 27 | "Classical---Neo-Classical", 28 | "Classical---Neo-Romantic", 29 | "Classical---Opera", 30 | "Classical---Post-Modern", 31 | "Classical---Renaissance", 32 | "Classical---Romantic", 33 | "Electronic---Abstract", 34 | "Electronic---Acid", 35 | "Electronic---Acid House", 36 | "Electronic---Acid Jazz", 37 | "Electronic---Ambient", 38 | "Electronic---Bassline", 39 | "Electronic---Beatdown", 40 | "Electronic---Berlin-School", 41 | "Electronic---Big Beat", 42 | "Electronic---Bleep", 43 | "Electronic---Breakbeat", 44 | "Electronic---Breakcore", 45 | "Electronic---Breaks", 46 | "Electronic---Broken Beat", 47 | "Electronic---Chillwave", 48 | "Electronic---Chiptune", 49 | "Electronic---Dance-pop", 50 | "Electronic---Dark Ambient", 51 | "Electronic---Darkwave", 52 | "Electronic---Deep House", 53 | "Electronic---Deep Techno", 54 | "Electronic---Disco", 55 | "Electronic---Disco Polo", 56 | "Electronic---Donk", 57 | "Electronic---Downtempo", 58 | "Electronic---Drone", 59 | "Electronic---Drum n Bass", 60 | "Electronic---Dub", 61 | "Electronic---Dub Techno", 62 | "Electronic---Dubstep", 63 | "Electronic---Dungeon Synth", 64 | "Electronic---EBM", 65 | "Electronic---Electro", 66 | "Electronic---Electro House", 67 | "Electronic---Electroclash", 68 | "Electronic---Euro House", 69 | "Electronic---Euro-Disco", 70 | "Electronic---Eurobeat", 71 | "Electronic---Eurodance", 72 | "Electronic---Experimental", 73 | "Electronic---Freestyle", 74 | "Electronic---Future Jazz", 75 | "Electronic---Gabber", 76 | "Electronic---Garage House", 77 | "Electronic---Ghetto", 78 | "Electronic---Ghetto House", 79 | "Electronic---Glitch", 80 | "Electronic---Goa Trance", 81 | "Electronic---Grime", 82 | "Electronic---Halftime", 83 | "Electronic---Hands Up", 84 | "Electronic---Happy Hardcore", 85 | "Electronic---Hard House", 86 | "Electronic---Hard Techno", 87 | "Electronic---Hard Trance", 88 | "Electronic---Hardcore", 89 | "Electronic---Hardstyle", 90 | "Electronic---Hi NRG", 91 | "Electronic---Hip Hop", 92 | "Electronic---Hip-House", 93 | "Electronic---House", 94 | "Electronic---IDM", 95 | "Electronic---Illbient", 96 | "Electronic---Industrial", 97 | "Electronic---Italo House", 98 | "Electronic---Italo-Disco", 99 | "Electronic---Italodance", 100 | "Electronic---Jazzdance", 101 | "Electronic---Juke", 102 | "Electronic---Jumpstyle", 103 | "Electronic---Jungle", 104 | "Electronic---Latin", 105 | "Electronic---Leftfield", 106 | "Electronic---Makina", 107 | "Electronic---Minimal", 108 | "Electronic---Minimal Techno", 109 | "Electronic---Modern Classical", 110 | "Electronic---Musique Concrète", 111 | "Electronic---Neofolk", 112 | "Electronic---New Age", 113 | "Electronic---New Beat", 114 | "Electronic---New Wave", 115 | "Electronic---Noise", 116 | "Electronic---Nu-Disco", 117 | "Electronic---Power Electronics", 118 | "Electronic---Progressive Breaks", 119 | "Electronic---Progressive House", 120 | "Electronic---Progressive Trance", 121 | "Electronic---Psy-Trance", 122 | "Electronic---Rhythmic Noise", 123 | "Electronic---Schranz", 124 | "Electronic---Sound Collage", 125 | "Electronic---Speed Garage", 126 | "Electronic---Speedcore", 127 | "Electronic---Synth-pop", 128 | "Electronic---Synthwave", 129 | "Electronic---Tech House", 130 | "Electronic---Tech Trance", 131 | "Electronic---Techno", 132 | "Electronic---Trance", 133 | "Electronic---Tribal", 134 | "Electronic---Tribal House", 135 | "Electronic---Trip Hop", 136 | "Electronic---Tropical House", 137 | "Electronic---UK Garage", 138 | "Electronic---Vaporwave", 139 | "Folk, World, & Country---African", 140 | "Folk, World, & Country---Bluegrass", 141 | "Folk, World, & Country---Cajun", 142 | "Folk, World, & Country---Canzone Napoletana", 143 | "Folk, World, & Country---Catalan Music", 144 | "Folk, World, & Country---Celtic", 145 | "Folk, World, & Country---Country", 146 | "Folk, World, & Country---Fado", 147 | "Folk, World, & Country---Flamenco", 148 | "Folk, World, & Country---Folk", 149 | "Folk, World, & Country---Gospel", 150 | "Folk, World, & Country---Highlife", 151 | "Folk, World, & Country---Hillbilly", 152 | "Folk, World, & Country---Hindustani", 153 | "Folk, World, & Country---Honky Tonk", 154 | "Folk, World, & Country---Indian Classical", 155 | "Folk, World, & Country---Laïkó", 156 | "Folk, World, & Country---Nordic", 157 | "Folk, World, & Country---Pacific", 158 | "Folk, World, & Country---Polka", 159 | "Folk, World, & Country---Raï", 160 | "Folk, World, & Country---Romani", 161 | "Folk, World, & Country---Soukous", 162 | "Folk, World, & Country---Séga", 163 | "Folk, World, & Country---Volksmusik", 164 | "Folk, World, & Country---Zouk", 165 | "Folk, World, & Country---Éntekhno", 166 | "Funk / Soul---Afrobeat", 167 | "Funk / Soul---Boogie", 168 | "Funk / Soul---Contemporary R&B", 169 | "Funk / Soul---Disco", 170 | "Funk / Soul---Free Funk", 171 | "Funk / Soul---Funk", 172 | "Funk / Soul---Gospel", 173 | "Funk / Soul---Neo Soul", 174 | "Funk / Soul---New Jack Swing", 175 | "Funk / Soul---P.Funk", 176 | "Funk / Soul---Psychedelic", 177 | "Funk / Soul---Rhythm & Blues", 178 | "Funk / Soul---Soul", 179 | "Funk / Soul---Swingbeat", 180 | "Funk / Soul---UK Street Soul", 181 | "Hip Hop---Bass Music", 182 | "Hip Hop---Boom Bap", 183 | "Hip Hop---Bounce", 184 | "Hip Hop---Britcore", 185 | "Hip Hop---Cloud Rap", 186 | "Hip Hop---Conscious", 187 | "Hip Hop---Crunk", 188 | "Hip Hop---Cut-up/DJ", 189 | "Hip Hop---DJ Battle Tool", 190 | "Hip Hop---Electro", 191 | "Hip Hop---G-Funk", 192 | "Hip Hop---Gangsta", 193 | "Hip Hop---Grime", 194 | "Hip Hop---Hardcore Hip-Hop", 195 | "Hip Hop---Horrorcore", 196 | "Hip Hop---Instrumental", 197 | "Hip Hop---Jazzy Hip-Hop", 198 | "Hip Hop---Miami Bass", 199 | "Hip Hop---Pop Rap", 200 | "Hip Hop---Ragga HipHop", 201 | "Hip Hop---RnB/Swing", 202 | "Hip Hop---Screw", 203 | "Hip Hop---Thug Rap", 204 | "Hip Hop---Trap", 205 | "Hip Hop---Trip Hop", 206 | "Hip Hop---Turntablism", 207 | "Jazz---Afro-Cuban Jazz", 208 | "Jazz---Afrobeat", 209 | "Jazz---Avant-garde Jazz", 210 | "Jazz---Big Band", 211 | "Jazz---Bop", 212 | "Jazz---Bossa Nova", 213 | "Jazz---Contemporary Jazz", 214 | "Jazz---Cool Jazz", 215 | "Jazz---Dixieland", 216 | "Jazz---Easy Listening", 217 | "Jazz---Free Improvisation", 218 | "Jazz---Free Jazz", 219 | "Jazz---Fusion", 220 | "Jazz---Gypsy Jazz", 221 | "Jazz---Hard Bop", 222 | "Jazz---Jazz-Funk", 223 | "Jazz---Jazz-Rock", 224 | "Jazz---Latin Jazz", 225 | "Jazz---Modal", 226 | "Jazz---Post Bop", 227 | "Jazz---Ragtime", 228 | "Jazz---Smooth Jazz", 229 | "Jazz---Soul-Jazz", 230 | "Jazz---Space-Age", 231 | "Jazz---Swing", 232 | "Latin---Afro-Cuban", 233 | "Latin---Baião", 234 | "Latin---Batucada", 235 | "Latin---Beguine", 236 | "Latin---Bolero", 237 | "Latin---Boogaloo", 238 | "Latin---Bossanova", 239 | "Latin---Cha-Cha", 240 | "Latin---Charanga", 241 | "Latin---Compas", 242 | "Latin---Cubano", 243 | "Latin---Cumbia", 244 | "Latin---Descarga", 245 | "Latin---Forró", 246 | "Latin---Guaguancó", 247 | "Latin---Guajira", 248 | "Latin---Guaracha", 249 | "Latin---MPB", 250 | "Latin---Mambo", 251 | "Latin---Mariachi", 252 | "Latin---Merengue", 253 | "Latin---Norteño", 254 | "Latin---Nueva Cancion", 255 | "Latin---Pachanga", 256 | "Latin---Porro", 257 | "Latin---Ranchera", 258 | "Latin---Reggaeton", 259 | "Latin---Rumba", 260 | "Latin---Salsa", 261 | "Latin---Samba", 262 | "Latin---Son", 263 | "Latin---Son Montuno", 264 | "Latin---Tango", 265 | "Latin---Tejano", 266 | "Latin---Vallenato", 267 | "Non-Music---Audiobook", 268 | "Non-Music---Comedy", 269 | "Non-Music---Dialogue", 270 | "Non-Music---Education", 271 | "Non-Music---Field Recording", 272 | "Non-Music---Interview", 273 | "Non-Music---Monolog", 274 | "Non-Music---Poetry", 275 | "Non-Music---Political", 276 | "Non-Music---Promotional", 277 | "Non-Music---Radioplay", 278 | "Non-Music---Religious", 279 | "Non-Music---Spoken Word", 280 | "Pop---Ballad", 281 | "Pop---Bollywood", 282 | "Pop---Bubblegum", 283 | "Pop---Chanson", 284 | "Pop---City Pop", 285 | "Pop---Europop", 286 | "Pop---Indie Pop", 287 | "Pop---J-pop", 288 | "Pop---K-pop", 289 | "Pop---Kayōkyoku", 290 | "Pop---Light Music", 291 | "Pop---Music Hall", 292 | "Pop---Novelty", 293 | "Pop---Parody", 294 | "Pop---Schlager", 295 | "Pop---Vocal", 296 | "Reggae---Calypso", 297 | "Reggae---Dancehall", 298 | "Reggae---Dub", 299 | "Reggae---Lovers Rock", 300 | "Reggae---Ragga", 301 | "Reggae---Reggae", 302 | "Reggae---Reggae-Pop", 303 | "Reggae---Rocksteady", 304 | "Reggae---Roots Reggae", 305 | "Reggae---Ska", 306 | "Reggae---Soca", 307 | "Rock---AOR", 308 | "Rock---Acid Rock", 309 | "Rock---Acoustic", 310 | "Rock---Alternative Rock", 311 | "Rock---Arena Rock", 312 | "Rock---Art Rock", 313 | "Rock---Atmospheric Black Metal", 314 | "Rock---Avantgarde", 315 | "Rock---Beat", 316 | "Rock---Black Metal", 317 | "Rock---Blues Rock", 318 | "Rock---Brit Pop", 319 | "Rock---Classic Rock", 320 | "Rock---Coldwave", 321 | "Rock---Country Rock", 322 | "Rock---Crust", 323 | "Rock---Death Metal", 324 | "Rock---Deathcore", 325 | "Rock---Deathrock", 326 | "Rock---Depressive Black Metal", 327 | "Rock---Doo Wop", 328 | "Rock---Doom Metal", 329 | "Rock---Dream Pop", 330 | "Rock---Emo", 331 | "Rock---Ethereal", 332 | "Rock---Experimental", 333 | "Rock---Folk Metal", 334 | "Rock---Folk Rock", 335 | "Rock---Funeral Doom Metal", 336 | "Rock---Funk Metal", 337 | "Rock---Garage Rock", 338 | "Rock---Glam", 339 | "Rock---Goregrind", 340 | "Rock---Goth Rock", 341 | "Rock---Gothic Metal", 342 | "Rock---Grindcore", 343 | "Rock---Grunge", 344 | "Rock---Hard Rock", 345 | "Rock---Hardcore", 346 | "Rock---Heavy Metal", 347 | "Rock---Indie Rock", 348 | "Rock---Industrial", 349 | "Rock---Krautrock", 350 | "Rock---Lo-Fi", 351 | "Rock---Lounge", 352 | "Rock---Math Rock", 353 | "Rock---Melodic Death Metal", 354 | "Rock---Melodic Hardcore", 355 | "Rock---Metalcore", 356 | "Rock---Mod", 357 | "Rock---Neofolk", 358 | "Rock---New Wave", 359 | "Rock---No Wave", 360 | "Rock---Noise", 361 | "Rock---Noisecore", 362 | "Rock---Nu Metal", 363 | "Rock---Oi", 364 | "Rock---Parody", 365 | "Rock---Pop Punk", 366 | "Rock---Pop Rock", 367 | "Rock---Pornogrind", 368 | "Rock---Post Rock", 369 | "Rock---Post-Hardcore", 370 | "Rock---Post-Metal", 371 | "Rock---Post-Punk", 372 | "Rock---Power Metal", 373 | "Rock---Power Pop", 374 | "Rock---Power Violence", 375 | "Rock---Prog Rock", 376 | "Rock---Progressive Metal", 377 | "Rock---Psychedelic Rock", 378 | "Rock---Psychobilly", 379 | "Rock---Pub Rock", 380 | "Rock---Punk", 381 | "Rock---Rock & Roll", 382 | "Rock---Rockabilly", 383 | "Rock---Shoegaze", 384 | "Rock---Ska", 385 | "Rock---Sludge Metal", 386 | "Rock---Soft Rock", 387 | "Rock---Southern Rock", 388 | "Rock---Space Rock", 389 | "Rock---Speed Metal", 390 | "Rock---Stoner Rock", 391 | "Rock---Surf", 392 | "Rock---Symphonic Rock", 393 | "Rock---Technical Death Metal", 394 | "Rock---Thrash", 395 | "Rock---Twist", 396 | "Rock---Viking Metal", 397 | "Rock---Yé-Yé", 398 | "Stage & Screen---Musical", 399 | "Stage & Screen---Score", 400 | "Stage & Screen---Soundtrack", 401 | "Stage & Screen---Theme", 402 | ] 403 | -------------------------------------------------------------------------------- /transfer-learning-music/cog.yaml: -------------------------------------------------------------------------------- 1 | # Configuration for Cog ⚙️ 2 | # Reference: https://github.com/replicate/cog/blob/main/docs/yaml.md 3 | image: "r8.im/mtg/essentia-transfer-learning-music" 4 | 5 | build: 6 | # set to true if your model requires a GPU 7 | gpu: false 8 | # cuda: "11.2" 9 | 10 | # a list of ubuntu apt packages to install 11 | system_packages: 12 | - "ffmpeg" 13 | 14 | # python version in the form '3.8' or '3.8.12' 15 | python_version: "3.10" 16 | 17 | # a list of packages in the format == 18 | python_packages: 19 | - "essentia-tensorflow==2.1b6.dev1110" 20 | - "numpy==1.21.3" 21 | - "youtube-dl==2021.6.6" 22 | 23 | run: 24 | - mkdir models 25 | 26 | # embeddings models 27 | - curl -s -o models/discogs-effnet-bs64-1.pb https://essentia.upf.edu/models/feature-extractors/discogs-effnet/discogs-effnet-bs64-1.pb 28 | - curl -s -o models/msd-musicnn-1.pb https://essentia.upf.edu/models/feature-extractors/musicnn/msd-musicnn-1.pb 29 | - curl -s -o models/audioset-vggish-3.pb https://essentia.upf.edu/models/feature-extractors/vggish/audioset-vggish-3.pb 30 | 31 | # effnet models 32 | 33 | # genre models 34 | # - curl -s -o models/fma_small-discogs-effnet-1.pb https://essentia.upf.edu/models/classification-heads/fma_small/fma_small-discogs-effnet-1.pb 35 | # - curl -s -o models/genre_dortmund-discogs-effnet-1.pb https://essentia.upf.edu/models/classification-heads/genre_dortmund/genre_dortmund-discogs-effnet-1.pb 36 | - curl -s -o models/genre_discogs400-discogs-effnet-1.pb https://essentia.upf.edu/models/classification-heads/genre_discogs400/genre_discogs400-discogs-effnet-1.pb 37 | # - curl -s -o models/genre_electronic-discogs-effnet-1.pb https://essentia.upf.edu/models/classification-heads/genre_electronic/genre_electronic-discogs-effnet-1.pb 38 | # - curl -s -o models/genre_rosamerica-discogs-effnet-1.pb https://essentia.upf.edu/models/classification-heads/genre_rosamerica/genre_rosamerica-discogs-effnet-1.pb 39 | # - curl -s -o models/genre_tzanetakis-discogs-effnet-1.pb https://essentia.upf.edu/models/classification-heads/genre_tzanetakis/genre_tzanetakis-discogs-effnet-1.pb 40 | - curl -s -o models/mtg_jamendo_genre-discogs-effnet-1.pb https://essentia.upf.edu/models/classification-heads/mtg_jamendo_genre/mtg_jamendo_genre-discogs-effnet-1.pb 41 | 42 | # mood models 43 | - curl -s -o models/mood_acoustic-discogs-effnet-1.pb https://essentia.upf.edu/models/classification-heads/mood_acoustic/mood_acoustic-discogs-effnet-1.pb 44 | - curl -s -o models/mood_aggressive-discogs-effnet-1.pb https://essentia.upf.edu/models/classification-heads/mood_aggressive/mood_aggressive-discogs-effnet-1.pb 45 | - curl -s -o models/mood_electronic-discogs-effnet-1.pb https://essentia.upf.edu/models/classification-heads/mood_electronic/mood_electronic-discogs-effnet-1.pb 46 | - curl -s -o models/mood_happy-discogs-effnet-1.pb https://essentia.upf.edu/models/classification-heads/mood_happy/mood_happy-discogs-effnet-1.pb 47 | - curl -s -o models/mood_party-discogs-effnet-1.pb https://essentia.upf.edu/models/classification-heads/mood_party/mood_party-discogs-effnet-1.pb 48 | - curl -s -o models/mood_relaxed-discogs-effnet-1.pb https://essentia.upf.edu/models/classification-heads/mood_relaxed/mood_relaxed-discogs-effnet-1.pb 49 | - curl -s -o models/mood_sad-discogs-effnet-1.pb https://essentia.upf.edu/models/classification-heads/mood_sad/mood_sad-discogs-effnet-1.pb 50 | - curl -s -o models/mtg_jamendo_moodtheme-discogs-effnet-1.pb https://essentia.upf.edu/models/classification-heads/mtg_jamendo_moodtheme/mtg_jamendo_moodtheme-discogs-effnet-1.pb 51 | 52 | # other models 53 | # - curl -s -o models/approachability_2c-discogs-effnet-1.pb https://essentia.upf.edu/models/classification-heads/approachability/approachability_2c-discogs-effnet-1.pb 54 | # - curl -s -o models/approachability_3c-discogs-effnet-1.pb https://essentia.upf.edu/models/classification-heads/approachability/approachability_3c-discogs-effnet-1.pb 55 | - curl -s -o models/approachability_regression-discogs-effnet-1.pb https://essentia.upf.edu/models/classification-heads/approachability/approachability_regression-discogs-effnet-1.pb 56 | - curl -s -o models/danceability-discogs-effnet-1.pb https://essentia.upf.edu/models/classification-heads/danceability/danceability-discogs-effnet-1.pb 57 | # - curl -s -o models/engagement_2c-discogs-effnet-1.pb https://essentia.upf.edu/models/classification-heads/engagement/engagement_2c-discogs-effnet-1.pb 58 | # - curl -s -o models/engagement_3c-discogs-effnet-1.pb https://essentia.upf.edu/models/classification-heads/engagement/engagement_3c-discogs-effnet-1.pb 59 | - curl -s -o models/engagement_regression-discogs-effnet-1.pb https://essentia.upf.edu/models/classification-heads/engagement/engagement_regression-discogs-effnet-1.pb 60 | - curl -s -o models/gender-discogs-effnet-1.pb https://essentia.upf.edu/models/classification-heads/gender/gender-discogs-effnet-1.pb 61 | - curl -s -o models/mtt-discogs-effnet-1.pb https://essentia.upf.edu/models/classification-heads/mtt/mtt-discogs-effnet-1.pb 62 | - curl -s -o models/mtg_jamendo_instrument-discogs-effnet-1.pb https://essentia.upf.edu/models/classification-heads/mtg_jamendo_instrument/mtg_jamendo_instrument-discogs-effnet-1.pb 63 | # - curl -s -o models/mtg_jamendo_top50tags-discogs-effnet-1.pb https://essentia.upf.edu/models/classification-heads/mtg_jamendo_top50tags/mtg_jamendo_top50tags-discogs-effnet-1.pb 64 | # - curl -s -o models/nsynth_acoustic_electronic-discogs-effnet-1.pb https://essentia.upf.edu/models/classification-heads/nsynth_acoustic_electronic/nsynth_acoustic_electronic-discogs-effnet-1.pb 65 | # - curl -s -o models/nsynth_bright_dark-discogs-effnet-1.pb https://essentia.upf.edu/models/classification-heads/nsynth_bright_dark/nsynth_bright_dark-discogs-effnet-1.pb 66 | # - curl -s -o models/nsynth_instrument-discogs-effnet-1.pb https://essentia.upf.edu/models/classification-heads/nsynth_instrument/nsynth_instrument-discogs-effnet-1.pb 67 | # - curl -s -o models/nsynth_reverb-discogs-effnet-1.pb https://essentia.upf.edu/models/classification-heads/nsynth_reverb/nsynth_reverb-discogs-effnet-1.pb 68 | - curl -s -o models/timbre-discogs-effnet-1.pb https://essentia.upf.edu/models/classification-heads/timbre/timbre-discogs-effnet-1.pb 69 | - curl -s -o models/tonal_atonal-discogs-effnet-1.pb https://essentia.upf.edu/models/classification-heads/tonal_atonal/tonal_atonal-discogs-effnet-1.pb 70 | - curl -s -o models/voice_instrumental-discogs-effnet-1.pb https://essentia.upf.edu/models/classification-heads/voice_instrumental/voice_instrumental-discogs-effnet-1.pb 71 | 72 | # genre models 73 | # - curl -s -o models/fma_small-discogs-effnet-1.json https://essentia.upf.edu/models/classification-heads/fma_small/fma_small-discogs-effnet-1.json 74 | # - curl -s -o models/genre_dortmund-discogs-effnet-1.json https://essentia.upf.edu/models/classification-heads/genre_dortmund/genre_dortmund-discogs-effnet-1.json 75 | - curl -s -o models/genre_discogs400-discogs-effnet-1.json https://essentia.upf.edu/models/classification-heads/genre_discogs400/genre_discogs400-discogs-effnet-1.json 76 | # - curl -s -o models/genre_electronic-discogs-effnet-1.json https://essentia.upf.edu/models/classification-heads/genre_electronic/genre_electronic-discogs-effnet-1.json 77 | # - curl -s -o models/genre_rosamerica-discogs-effnet-1.json https://essentia.upf.edu/models/classification-heads/genre_rosamerica/genre_rosamerica-discogs-effnet-1.json 78 | # - curl -s -o models/genre_tzanetakis-discogs-effnet-1.json https://essentia.upf.edu/models/classification-heads/genre_tzanetakis/genre_tzanetakis-discogs-effnet-1.json 79 | - curl -s -o models/mtg_jamendo_genre-discogs-effnet-1.json https://essentia.upf.edu/models/classification-heads/mtg_jamendo_genre/mtg_jamendo_genre-discogs-effnet-1.json 80 | 81 | # mood models 82 | - curl -s -o models/mood_acoustic-discogs-effnet-1.json https://essentia.upf.edu/models/classification-heads/mood_acoustic/mood_acoustic-discogs-effnet-1.json 83 | - curl -s -o models/mood_aggressive-discogs-effnet-1.json https://essentia.upf.edu/models/classification-heads/mood_aggressive/mood_aggressive-discogs-effnet-1.json 84 | - curl -s -o models/mood_electronic-discogs-effnet-1.json https://essentia.upf.edu/models/classification-heads/mood_electronic/mood_electronic-discogs-effnet-1.json 85 | - curl -s -o models/mood_happy-discogs-effnet-1.json https://essentia.upf.edu/models/classification-heads/mood_happy/mood_happy-discogs-effnet-1.json 86 | - curl -s -o models/mood_party-discogs-effnet-1.json https://essentia.upf.edu/models/classification-heads/mood_party/mood_party-discogs-effnet-1.json 87 | - curl -s -o models/mood_relaxed-discogs-effnet-1.json https://essentia.upf.edu/models/classification-heads/mood_relaxed/mood_relaxed-discogs-effnet-1.json 88 | - curl -s -o models/mood_sad-discogs-effnet-1.json https://essentia.upf.edu/models/classification-heads/mood_sad/mood_sad-discogs-effnet-1.json 89 | - curl -s -o models/mtg_jamendo_moodtheme-discogs-effnet-1.json https://essentia.upf.edu/models/classification-heads/mtg_jamendo_moodtheme/mtg_jamendo_moodtheme-discogs-effnet-1.json 90 | 91 | # other models 92 | # - curl -s -o models/approachability_2c-discogs-effnet-1.json https://essentia.upf.edu/models/classification-heads/approachability/approachability_2c-discogs-effnet-1.json 93 | # - curl -s -o models/approachability_3c-discogs-effnet-1.json https://essentia.upf.edu/models/classification-heads/approachability/approachability_3c-discogs-effnet-1.json 94 | - curl -s -o models/approachability_regression-discogs-effnet-1.json https://essentia.upf.edu/models/classification-heads/approachability/approachability_regression-discogs-effnet-1.json 95 | - curl -s -o models/danceability-discogs-effnet-1.json https://essentia.upf.edu/models/classification-heads/danceability/danceability-discogs-effnet-1.json 96 | # - curl -s -o models/engagement_2c-discogs-effnet-1.json https://essentia.upf.edu/models/classification-heads/engagement/engagement_2c-discogs-effnet-1.json 97 | # - curl -s -o models/engagement_3c-discogs-effnet-1.json https://essentia.upf.edu/models/classification-heads/engagement/engagement_3c-discogs-effnet-1.json 98 | - curl -s -o models/engagement_regression-discogs-effnet-1.json https://essentia.upf.edu/models/classification-heads/engagement/engagement_regression-discogs-effnet-1.json 99 | - curl -s -o models/gender-discogs-effnet-1.json https://essentia.upf.edu/models/classification-heads/gender/gender-discogs-effnet-1.json 100 | - curl -s -o models/mtt-discogs-effnet-1.json https://essentia.upf.edu/models/classification-heads/mtt/mtt-discogs-effnet-1.json 101 | - curl -s -o models/mtg_jamendo_instrument-discogs-effnet-1.json https://essentia.upf.edu/models/classification-heads/mtg_jamendo_instrument/mtg_jamendo_instrument-discogs-effnet-1.json 102 | # - curl -s -o models/mtg_jamendo_top50tags-discogs-effnet-1.json https://essentia.upf.edu/models/classification-heads/mtg_jamendo_top50tags/mtg_jamendo_top50tags-discogs-effnet-1.json 103 | # - curl -s -o models/nsynth_acoustic_electronic-discogs-effnet-1.json https://essentia.upf.edu/models/classification-heads/nsynth_acoustic_electronic/nsynth_acoustic_electronic-discogs-effnet-1.json 104 | # - curl -s -o models/nsynth_bright_dark-discogs-effnet-1.json https://essentia.upf.edu/models/classification-heads/nsynth_bright_dark/nsynth_bright_dark-discogs-effnet-1.json 105 | # - curl -s -o models/nsynth_instrument-discogs-effnet-1.json https://essentia.upf.edu/models/classification-heads/nsynth_instrument/nsynth_instrument-discogs-effnet-1.json 106 | # - curl -s -o models/nsynth_reverb-discogs-effnet-1.json https://essentia.upf.edu/models/classification-heads/nsynth_reverb/nsynth_reverb-discogs-effnet-1.json 107 | - curl -s -o models/timbre-discogs-effnet-1.json https://essentia.upf.edu/models/classification-heads/timbre/timbre-discogs-effnet-1.json 108 | - curl -s -o models/tonal_atonal-discogs-effnet-1.json https://essentia.upf.edu/models/classification-heads/tonal_atonal/tonal_atonal-discogs-effnet-1.json 109 | - curl -s -o models/voice_instrumental-discogs-effnet-1.json https://essentia.upf.edu/models/classification-heads/voice_instrumental/voice_instrumental-discogs-effnet-1.json 110 | 111 | # musicnn models 112 | 113 | # genre 114 | # - curl -s -o models/genre_tzanetakis-msd-musicnn-1.pb https://essentia.upf.edu/models/classification-heads/genre_tzanetakis/genre_tzanetakis-msd-musicnn-1.pb 115 | # - curl -s -o models/genre_rosamerica-msd-musicnn-1.pb https://essentia.upf.edu/models/classification-heads/genre_rosamerica/genre_rosamerica-msd-musicnn-1.pb 116 | # - curl -s -o models/genre_dortmund-msd-musicnn-1.pb https://essentia.upf.edu/models/classification-heads/genre_dortmund/genre_dortmund-msd-musicnn-1.pb 117 | 118 | # tagging 119 | - curl -s -o models/msd-msd-musicnn-1.pb https://essentia.upf.edu/models/classification-heads/msd/msd-msd-musicnn-1.pb 120 | 121 | # misc 122 | - curl -s -o models/gender-msd-musicnn-1.pb https://essentia.upf.edu/models/classification-heads/gender/gender-msd-musicnn-1.pb 123 | - curl -s -o models/voice_instrumental-msd-musicnn-1.pb https://essentia.upf.edu/models/classification-heads/voice_instrumental/voice_instrumental-msd-musicnn-1.pb 124 | - curl -s -o models/tonal_atonal-msd-musicnn-1.pb https://essentia.upf.edu/models/classification-heads/tonal_atonal/tonal_atonal-msd-musicnn-1.pb 125 | - curl -s -o models/danceability-msd-musicnn-1.pb https://essentia.upf.edu/models/classification-heads/danceability/danceability-msd-musicnn-1.pb 126 | - curl -s -o models/fs_loop_ds-msd-musicnn-1.pb https://essentia.upf.edu/models/classification-heads/fs_loop_ds/fs_loop_ds-msd-musicnn-1.pb 127 | 128 | # mood 129 | - curl -s -o models/moods_mirex-msd-musicnn-1.pb https://essentia.upf.edu/models/classification-heads/moods_mirex/moods_mirex-msd-musicnn-1.pb 130 | - curl -s -o models/mood_acoustic-msd-musicnn-1.pb https://essentia.upf.edu/models/classification-heads/mood_acoustic/mood_acoustic-msd-musicnn-1.pb 131 | - curl -s -o models/mood_party-msd-musicnn-1.pb https://essentia.upf.edu/models/classification-heads/mood_party/mood_party-msd-musicnn-1.pb 132 | - curl -s -o models/mood_happy-msd-musicnn-1.pb https://essentia.upf.edu/models/classification-heads/mood_happy/mood_happy-msd-musicnn-1.pb 133 | - curl -s -o models/mood_sad-msd-musicnn-1.pb https://essentia.upf.edu/models/classification-heads/mood_sad/mood_sad-msd-musicnn-1.pb 134 | - curl -s -o models/mood_relaxed-msd-musicnn-1.pb https://essentia.upf.edu/models/classification-heads/mood_relaxed/mood_relaxed-msd-musicnn-1.pb 135 | - curl -s -o models/mood_electronic-msd-musicnn-1.pb https://essentia.upf.edu/models/classification-heads/mood_electronic/mood_electronic-msd-musicnn-1.pb 136 | - curl -s -o models/mood_aggressive-msd-musicnn-1.pb https://essentia.upf.edu/models/classification-heads/mood_aggressive/mood_aggressive-msd-musicnn-1.pb 137 | 138 | # arousal and valence 139 | - curl -s -o models/muse-msd-musicnn-1.pb https://essentia.upf.edu/models/classification-heads/muse/muse-msd-musicnn-1.pb 140 | - curl -s -o models/emomusic-msd-musicnn-1.pb https://essentia.upf.edu/models/classification-heads/emomusic/emomusic-msd-musicnn-1.pb 141 | - curl -s -o models/deam-msd-musicnn-1.pb https://essentia.upf.edu/models/classification-heads/deam/deam-msd-musicnn-1.pb 142 | 143 | # genre 144 | # - curl -s -o models/genre_tzanetakis-msd-musicnn-1.json https://essentia.upf.edu/models/classification-heads/genre_tzanetakis/genre_tzanetakis-msd-musicnn-1.json 145 | # - curl -s -o models/genre_rosamerica-msd-musicnn-1.json https://essentia.upf.edu/models/classification-heads/genre_rosamerica/genre_rosamerica-msd-musicnn-1.json 146 | # - curl -s -o models/genre_dortmund-msd-musicnn-1.json https://essentia.upf.edu/models/classification-heads/genre_dortmund/genre_dortmund-msd-musicnn-1.json 147 | 148 | # tagging 149 | - curl -s -o models/msd-msd-musicnn-1.json https://essentia.upf.edu/models/classification-heads/msd/msd-msd-musicnn-1.json 150 | 151 | # misc 152 | - curl -s -o models/gender-msd-musicnn-1.json https://essentia.upf.edu/models/classification-heads/gender/gender-msd-musicnn-1.json 153 | - curl -s -o models/voice_instrumental-msd-musicnn-1.json https://essentia.upf.edu/models/classification-heads/voice_instrumental/voice_instrumental-msd-musicnn-1.json 154 | - curl -s -o models/tonal_atonal-msd-musicnn-1.json https://essentia.upf.edu/models/classification-heads/tonal_atonal/tonal_atonal-msd-musicnn-1.json 155 | - curl -s -o models/danceability-msd-musicnn-1.json https://essentia.upf.edu/models/classification-heads/danceability/danceability-msd-musicnn-1.json 156 | - curl -s -o models/fs_loop_ds-msd-musicnn-1.json https://essentia.upf.edu/models/classification-heads/fs_loop_ds/fs_loop_ds-msd-musicnn-1.json 157 | 158 | # mood 159 | - curl -s -o models/moods_mirex-msd-musicnn-1.json https://essentia.upf.edu/models/classification-heads/moods_mirex/moods_mirex-msd-musicnn-1.json 160 | - curl -s -o models/mood_acoustic-msd-musicnn-1.json https://essentia.upf.edu/models/classification-heads/mood_acoustic/mood_acoustic-msd-musicnn-1.json 161 | - curl -s -o models/mood_party-msd-musicnn-1.json https://essentia.upf.edu/models/classification-heads/mood_party/mood_party-msd-musicnn-1.json 162 | - curl -s -o models/mood_happy-msd-musicnn-1.json https://essentia.upf.edu/models/classification-heads/mood_happy/mood_happy-msd-musicnn-1.json 163 | - curl -s -o models/mood_sad-msd-musicnn-1.json https://essentia.upf.edu/models/classification-heads/mood_sad/mood_sad-msd-musicnn-1.json 164 | - curl -s -o models/mood_relaxed-msd-musicnn-1.json https://essentia.upf.edu/models/classification-heads/mood_relaxed/mood_relaxed-msd-musicnn-1.json 165 | - curl -s -o models/mood_electronic-msd-musicnn-1.json https://essentia.upf.edu/models/classification-heads/mood_electronic/mood_electronic-msd-musicnn-1.json 166 | - curl -s -o models/mood_aggressive-msd-musicnn-1.json https://essentia.upf.edu/models/classification-heads/mood_aggressive/mood_aggressive-msd-musicnn-1.json 167 | 168 | # arousal and valence 169 | - curl -s -o models/muse-msd-musicnn-1.json https://essentia.upf.edu/models/classification-heads/muse/muse-msd-musicnn-1.json 170 | - curl -s -o models/emomusic-msd-musicnn-1.json https://essentia.upf.edu/models/classification-heads/emomusic/emomusic-msd-musicnn-1.json 171 | - curl -s -o models/deam-msd-musicnn-1.json https://essentia.upf.edu/models/classification-heads/deam/deam-msd-musicnn-1.json 172 | 173 | 174 | # vggish 175 | 176 | #genre 177 | # - curl -s -o models/genre_tzanetakis-audioset-vggish-1.pb https://essentia.upf.edu/models/classification-heads/genre_tzanetakis/genre_tzanetakis-audioset-vggish-1.pb 178 | # - curl -s -o models/genre_rosamerica-audioset-vggish-1.pb https://essentia.upf.edu/models/classification-heads/genre_rosamerica/genre_rosamerica-audioset-vggish-1.pb 179 | # - curl -s -o models/genre_dortmund-audioset-vggish-1.pb https://essentia.upf.edu/models/classification-heads/genre_dortmund/genre_dortmund-audioset-vggish-1.pb 180 | 181 | # mood 182 | - curl -s -o models/mood_sad-audioset-vggish-1.pb https://essentia.upf.edu/models/classification-heads/mood_sad/mood_sad-audioset-vggish-1.pb 183 | - curl -s -o models/mood_relaxed-audioset-vggish-1.pb https://essentia.upf.edu/models/classification-heads/mood_relaxed/mood_relaxed-audioset-vggish-1.pb 184 | - curl -s -o models/moods_mirex-audioset-vggish-1.pb https://essentia.upf.edu/models/classification-heads/moods_mirex/moods_mirex-audioset-vggish-1.pb 185 | - curl -s -o models/mood_acoustic-audioset-vggish-1.pb https://essentia.upf.edu/models/classification-heads/mood_acoustic/mood_acoustic-audioset-vggish-1.pb 186 | - curl -s -o models/mood_electronic-audioset-vggish-1.pb https://essentia.upf.edu/models/classification-heads/mood_electronic/mood_electronic-audioset-vggish-1.pb 187 | - curl -s -o models/mood_aggressive-audioset-vggish-1.pb https://essentia.upf.edu/models/classification-heads/mood_aggressive/mood_aggressive-audioset-vggish-1.pb 188 | - curl -s -o models/mood_party-audioset-vggish-1.pb https://essentia.upf.edu/models/classification-heads/mood_party/mood_party-audioset-vggish-1.pb 189 | - curl -s -o models/mood_happy-audioset-vggish-1.pb https://essentia.upf.edu/models/classification-heads/mood_happy/mood_happy-audioset-vggish-1.pb 190 | 191 | # other 192 | - curl -s -o models/gender-audioset-vggish-1.pb https://essentia.upf.edu/models/classification-heads/gender/gender-audioset-vggish-1.pb 193 | - curl -s -o models/voice_instrumental-audioset-vggish-1.pb https://essentia.upf.edu/models/classification-heads/voice_instrumental/voice_instrumental-audioset-vggish-1.pb 194 | - curl -s -o models/tonal_atonal-audioset-vggish-1.pb https://essentia.upf.edu/models/classification-heads/tonal_atonal/tonal_atonal-audioset-vggish-1.pb 195 | - curl -s -o models/danceability-audioset-vggish-1.pb https://essentia.upf.edu/models/classification-heads/danceability/danceability-audioset-vggish-1.pb 196 | 197 | # arousal and valence 198 | - curl -s -o models/emomusic-audioset-vggish-1.pb https://essentia.upf.edu/models/classification-heads/emomusic/emomusic-audioset-vggish-1.pb 199 | - curl -s -o models/deam-audioset-vggish-1.pb https://essentia.upf.edu/models/classification-heads/deam/deam-audioset-vggish-1.pb 200 | - curl -s -o models/muse-audioset-vggish-1.pb https://essentia.upf.edu/models/classification-heads/muse/muse-audioset-vggish-1.pb 201 | 202 | #genre 203 | # - curl -s -o models/genre_tzanetakis-audioset-vggish-1.json https://essentia.upf.edu/models/classification-heads/genre_tzanetakis/genre_tzanetakis-audioset-vggish-1.json 204 | # - curl -s -o models/genre_rosamerica-audioset-vggish-1.json https://essentia.upf.edu/models/classification-heads/genre_rosamerica/genre_rosamerica-audioset-vggish-1.json 205 | # - curl -s -o models/genre_dortmund-audioset-vggish-1.json https://essentia.upf.edu/models/classification-heads/genre_dortmund/genre_dortmund-audioset-vggish-1.json 206 | 207 | # mood 208 | - curl -s -o models/mood_sad-audioset-vggish-1.json https://essentia.upf.edu/models/classification-heads/mood_sad/mood_sad-audioset-vggish-1.json 209 | - curl -s -o models/mood_relaxed-audioset-vggish-1.json https://essentia.upf.edu/models/classification-heads/mood_relaxed/mood_relaxed-audioset-vggish-1.json 210 | - curl -s -o models/moods_mirex-audioset-vggish-1.json https://essentia.upf.edu/models/classification-heads/moods_mirex/moods_mirex-audioset-vggish-1.json 211 | - curl -s -o models/mood_acoustic-audioset-vggish-1.json https://essentia.upf.edu/models/classification-heads/mood_acoustic/mood_acoustic-audioset-vggish-1.json 212 | - curl -s -o models/mood_electronic-audioset-vggish-1.json https://essentia.upf.edu/models/classification-heads/mood_electronic/mood_electronic-audioset-vggish-1.json 213 | - curl -s -o models/mood_aggressive-audioset-vggish-1.json https://essentia.upf.edu/models/classification-heads/mood_aggressive/mood_aggressive-audioset-vggish-1.json 214 | - curl -s -o models/mood_party-audioset-vggish-1.json https://essentia.upf.edu/models/classification-heads/mood_party/mood_party-audioset-vggish-1.json 215 | - curl -s -o models/mood_happy-audioset-vggish-1.json https://essentia.upf.edu/models/classification-heads/mood_happy/mood_happy-audioset-vggish-1.json 216 | 217 | # other 218 | - curl -s -o models/gender-audioset-vggish-1.json https://essentia.upf.edu/models/classification-heads/gender/gender-audioset-vggish-1.json 219 | - curl -s -o models/voice_instrumental-audioset-vggish-1.json https://essentia.upf.edu/models/classification-heads/voice_instrumental/voice_instrumental-audioset-vggish-1.json 220 | - curl -s -o models/tonal_atonal-audioset-vggish-1.json https://essentia.upf.edu/models/classification-heads/tonal_atonal/tonal_atonal-audioset-vggish-1.json 221 | - curl -s -o models/danceability-audioset-vggish-1.json https://essentia.upf.edu/models/classification-heads/danceability/danceability-audioset-vggish-1.json 222 | 223 | # arousal and valence 224 | - curl -s -o models/emomusic-audioset-vggish-1.json https://essentia.upf.edu/models/classification-heads/emomusic/emomusic-audioset-vggish-1.json 225 | - curl -s -o models/deam-audioset-vggish-1.json https://essentia.upf.edu/models/classification-heads/deam/deam-audioset-vggish-1.json 226 | - curl -s -o models/muse-audioset-vggish-1.json https://essentia.upf.edu/models/classification-heads/muse/muse-audioset-vggish-1.json 227 | 228 | 229 | # predict.py defines how predictions are run on your model 230 | predict: "predict.py:Predictor" 231 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | --------------------------------------------------------------------------------