Giter Club home page Giter Club logo

melgan's Introduction

MelGAN

This project is about MelGAN, proposed in this paper.

Quick start

If you want run script and don't care you can run this commands in your terminal:

git clone https://github.com/PUSSYMIPT/MelGAN.git && cd MelGAN
pip install -r requirements/requirements.txt
sudo apt-get install libsndfile1 -y  # not necessary but sometimes required
bash bin/download_lj_speech.sh
export PYTHONPATH=$PYTHONPATH:.  # not necessary but sometimes required
bash bin/download_lj_speach.sh
python scripts/preprocess.py -d data/LJSpeech-1.1/wavs
catalyst-dl run -C configs/LJ_config.yml --verbose

Run experiment

First of all we need to install all required dependencies

$ pip install -r requirements/requirements.txt

Sometimes if librosa wasn't install we also need to install some other additional library

$ sudo apt-get install libsndfile1 -y

Also we need to download and preprocess dataset. For example LJ1.1.

bash bin/download_lj_speech.sh
export PYTHONPATH=$PYTHONPATH:.  # not necessary but sometimes required
bash bin/download_lj_speach.sh
python scripts/preprocess.py -d data/LJSpeech-1.1/wavs

Config API

The most product-ready and kinda professional way to run script in catalyst is to run it via config API. You need to write your config.yml file and download your dataset. Then just run

$ catalyst-dl run -C PATH_TO_CONFIG

Also we can run in distributed or/and apex mode:

$ catalyst-dl run -C PATH_TO_CONFIG --distributed --apex

{% hint style="info" %} Reproducibility guaranteed only in non-distributed mode. {% endhint %}

Notebook API

If you want to create something new and run small experiment to check your hypothesis you can use notebook API. Here is a minimal example.

from collections import OrderedDict

from catalyst import dl
from src.callbacks.discriminator_loss_callback import DiscriminatorLossCallback
from src.callbacks.generator_loss_callback import GeneratorLossCallback
from src.data.dataset import MelFromDisk
from src.models import Discriminator, Generator
from src.runner import MelGANRunner
import torch


def main():
    """Test Notebook API"""
    dataset = MelFromDisk(path="data/test")
    dataloader = torch.utils.data.DataLoader(dataset)
    loaders = OrderedDict({"train": dataloader})
    generator = Generator(80)
    discriminator = Discriminator()

    model = torch.nn.ModuleDict(
        {"generator": generator, "discriminator": discriminator}
    )
    optimizer = {
        "opt_g": torch.optim.Adam(generator.parameters()),
        "opt_d": torch.optim.Adam(discriminator.parameters()),
    }
    callbacks = {
        "loss_g": GeneratorLossCallback(),
        "loss_d": DiscriminatorLossCallback(),
        "o_g": dl.OptimizerCallback(
            metric_key="generator_loss", optimizer_key="opt_g"
        ),
        "o_d": dl.OptimizerCallback(
            metric_key="discriminator_loss", optimizer_key="opt_d"
        ),
    }
    runner = MelGANRunner()

    runner.train(
        model=model,
        loaders=loaders,
        optimizer=optimizer,
        callbacks=callbacks,
        check=True,
        main_metric="discriminator_loss",
    )

melgan's People

Contributors

elephantmipt avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.