Zeroxdesignart commited on
Commit
47c3e14
·
verified ·
1 Parent(s): 302cf9d

Create model2.py

Browse files
Files changed (1) hide show
  1. model2.py +17 -0
model2.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import AutoModelForCausalLM, AutoTokenizer
2
+ import torch
3
+
4
+ # Load the generator model
5
+ melody_model = AutoModelForCausalLM.from_pretrained("your_model_repo/multi-model-music-generator")
6
+ tokenizer = AutoTokenizer.from_pretrained("gpt2")
7
+
8
+ # Define a prompt for generating music
9
+ prompt = "A smooth jazz melody with a lively rhythm"
10
+
11
+ # Tokenize input and generate music
12
+ inputs = tokenizer(prompt, return_tensors="pt")
13
+ outputs = melody_model.generate(inputs['input_ids'], max_length=200)
14
+
15
+ # Decode to text or MIDI, based on the final setup
16
+ generated_music = tokenizer.decode(outputs[0], skip_special_tokens=True)
17
+ print(generated_music)