Update trainer.py
Browse files- trainer.py +24 -0
trainer.py
CHANGED
@@ -1,3 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
class Text2VideoTrainer:
|
2 |
def __init__(self, model, optimizer, device):
|
3 |
self.model = model
|
|
|
1 |
+
from models.text2video_model import Text2VideoModel
|
2 |
+
from training.trainer import Text2VideoTrainer
|
3 |
+
from config.model_config import CONFIG
|
4 |
+
import torch
|
5 |
+
|
6 |
+
def main():
|
7 |
+
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
8 |
+
|
9 |
+
model = Text2VideoModel(
|
10 |
+
vocab_size=CONFIG['vocab_size'],
|
11 |
+
embed_dim=CONFIG['embed_dim'],
|
12 |
+
latent_dim=CONFIG['latent_dim'],
|
13 |
+
num_frames=CONFIG['num_frames'],
|
14 |
+
frame_size=CONFIG['frame_size']
|
15 |
+
).to(device)
|
16 |
+
|
17 |
+
optimizer = torch.optim.Adam(model.parameters(), lr=CONFIG['learning_rate'])
|
18 |
+
trainer = Text2VideoTrainer(model, optimizer, device)
|
19 |
+
|
20 |
+
# Add your data loading and training loop here
|
21 |
+
|
22 |
+
if __name__ == '__main__':
|
23 |
+
main()
|
24 |
+
|
25 |
class Text2VideoTrainer:
|
26 |
def __init__(self, model, optimizer, device):
|
27 |
self.model = model
|