The MuseCoco Text-to-MIDI Service is a refactored version of the MuseCoco repository, designed as a deployable service module. This service adapts to new data, manages the history of its checkpoints, and abstracts away the underlying implementation details to provide a seamless interface for generating MIDI files from textual inputs. Detailed comments are included to facilitate easy navigation and understanding of the codebase.
- Text-to-MIDI Conversion: Converts textual descriptions into MIDI files using the MuseCoco model.
- Adaptive Data Handling: Capable of adapting to new data for more customized MIDI generation.
- Checkpoint Management: Manages the history of model checkpoints to ensure reproducibility and flexibility.
- Abstracted Implementation: Provides an abstract interface for easy integration while maintaining detailed internal documentation.
The repository is organized as follows:
musecoco-text2midi-service/
├── src/
│ └── musecoco_text2midi_service/
│ ├── control/ # Controllers for orchestrating service logic
│ │ ├── __init__.py
│ │ ├── _musecoco/
│ │ │ ├── __init__.py
│ │ │ └── view.py
│ │ └── _text2midi.py
│ ├── dao/ # Data Access Objects for configuration management
│ │ ├── __init__.py
│ │ └── _config_manager.py
│ ├── model/ # Models representing the structure and workflow of MIDI generation
│ │ ├── __init__.py
│ │ └── _config_model.py
│ ├── utils/ # Utility functions for common tasks
│ │ ├── __init__.py
│ │ └── _watch_dog.py
│ └── view/ # Views for API or CLI outputs
│ ├── __init__.py
│ └── _app_view.py
├── storage/
│ ├── checkpoints/ # Model checkpoints
│ │ └── linear_mask-1billion/
│ │ ├── checkpoint_2_280000.pt
│ │ └── README.md # Instructions for managing checkpoints
│ ├── config/ # Configuration files
│ │ ├── main_config.yaml # Main configuration file
│ │ ├── att_key.json
│ │ └── num_labels.json
│ ├── input/ # Input files for predictions
│ │ ├── predict_backup.json # Example input format for predictions
│ │ └── predict.json
│ ├── log/ # Log files
│ └── tmp/ # Temporary files and outputs
├── tests/
│ ├── __init__.py # Initializer for the tests package
│ └── ... # Test modules for various components
├── .gitignore # Specifies files and directories to ignore in version control
├── LICENSE # License file
├── main.py # Entry point for running the service
├── README.md # Project description and instructions
└── setup.py # Setup script for packaging and distribution
To install the MuseCoco Text-to-MIDI Service, follow these steps:
-
Clone the Repository:
git clone https://github.com/your-repo/musecoco-text2midi-service.git cd musecoco-text2midi-service
-
Install Dependencies:
Create a new environment and install the dependencies. Currently, PyTorch needs to be installed with
conda
:conda env create -f conda_env.yml conda activate MuseCoco conda -c nvidia/label/cuda-12.3 pip install torch==2.3 pip install --user --no-cache-dir pytorch-fast-transformers pip install -e . <!-- cd modules git clone https://github.com/pytorch/fairseq cd fairseq pip install -e . -->
Note: Other dependencies can be installed with
pip install -e .
orpip install musecoco_text2midi_service
. PyTorch installation withpip
will be supported later.
The service uses YAML configuration files located in storage/config/
. The main configuration file is main_config.yaml
, which is used by the main.py
script. You can modify these files to configure parameters such as model checkpoints, logging settings, and API keys.
Checkpoints should follow the instructions provided in storage/checkpoints/linear_mask-1billion/README.md
and be saved in the same directory as the README.md file.
To start the service, run:
python main.py
The main.py
file provides a terminal-based app demo.
Refer to
storage/input/predict_backup.json
for examples of acceptable input formats for the service. This file contains sample data that illustrates how to structure text input for the MIDI generation process.
You can also import the package to your project.
from musecoco_text2midi_service.control import Text2Midi
from musecoco_text2midi_service.dao import load_config_from_file
config = load_config_from_file("storage/config/main_config.yaml")
text2midi = Text2Midi(config)
input_text = "This music's use of major key creates a distinct atmosphere, with a playtime of 1 ~ 15 seconds. The rhythm in this song is very pronounced, and the music is enriched by grand piano, cello and drum. Overall, the song's length is around about 6 bars. The music conveys edginess."
midi_data, meta_data = text2midi.text_to_midi(input_text, return_midi=True)
Later this will launch the MuseCoco Text-to-MIDI Service, allowing you to convert textual descriptions into MIDI files through the defined APIs or CLI.
To run the test suite, use:
pytest /tests
This command will execute all test cases in the tests
directory and provide a report of the test results. Ensure that the project is built correctly before running the tests.
We welcome contributions from the community. Please follow these steps to contribute:
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Commit your changes with descriptive commit messages.
- Push your changes to your forked repository.
- Create a pull request with a detailed description of your changes.
This project is licensed under Apache License 2.0 - see the LICENSE file for more details.
- https://askubuntu.com/questions/1288672/how-do-you-install-cuda-11-on-ubuntu-20-10-and-verify-the-installation
- https://docs.nvidia.com/cuda/archive/12.1.0/cuda-installation-guide-linux/#conda-overview
- https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&Distribution=Ubuntu&target_version=22.04&target_type=deb_network
- The only othing that kinda difficult it installing the pytorch-fast-transformers
Thank you for your interest in the MuseCoco Text-to-MIDI Service! If you have any questions or need further assistance, feel free to open an issue or contact us.