File size: 981 Bytes
21e9df7
 
55cbfca
 
21e9df7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""PyTorch Lightning module for InstructMusicGen model with adapter-based instruction tuning.

Trimmed to the inference path only i.e. removed training_step/ validation_step/test_step, torchmetrics/wandb 
logging bcs not needed for inference; only kept what load_from_checkpoint() needs.
"""
import torch
from lightning import LightningModule
from .components.model import Instructor


class InstructMusicGenAdapterLitModule(LightningModule):
    def __init__(
            self,
            optimizer: torch.optim.Optimizer,
            scheduler: torch.optim.lr_scheduler,
            tmp_dir: str,
            compile: bool,
            instructor: Instructor,
            audio_regularization: float,
    ) -> None:

        super().__init__()

        # this line allows to access init params with 'self.hparams' attribute
        # also ensures init params will be stored in ckpt
        self.save_hyperparameters(logger=False)

        self.model = self.hparams.instructor()