mrfakename commited on
Commit
e3212c0
1 Parent(s): badc317

Update musiclib.py

Browse files
Files changed (1) hide show
  1. musiclib.py +17 -6
musiclib.py CHANGED
@@ -6,7 +6,7 @@ from cached_path import cached_path
6
  np.set_printoptions(precision=4, suppress=True, linewidth=200)
7
 
8
  os.environ['RWKV_JIT_ON'] = '1' #### set these before import RWKV
9
- os.environ["RWKV_CUDA_ON"] = '0'
10
  os.environ["RWKV_RESCALE_LAYER"] = '999' # must set this for RWKV-music models and "pip install rwkv --upgrade" to v0.8.12+
11
 
12
  from rwkv.model import RWKV
@@ -18,14 +18,25 @@ ABC_MODE = ('-ABC-' in MODEL_FILE)
18
  MIDI_MODE = ('-MIDI-' in MODEL_FILE)
19
  device = 'cpu'
20
  if torch.cuda.is_available(): device = 'cuda'
21
- model = RWKV(model=MODEL_FILE, strategy=f'{device} fp32')
22
- pipeline = PIPELINE(model, "tokenizer-midi.json")
23
 
24
- tokenizer = pipeline
25
- EOS_ID = 0
26
- TOKEN_SEP = ' '
 
 
 
 
 
27
 
28
  def musicgen(ccc='<pad>', piano_only=False, length=4096):
 
 
 
 
 
 
 
29
  # ccc = '<pad>'
30
  ccc_output = '<start>'
31
  # ccc = "v:5b:3 v:5b:2 t125 t125 t125 t106 pi:43:5 t24 pi:4a:7 t15 pi:4f:7 t17 pi:56:7 t18 pi:54:7 t125 t49 pi:51:7 t117 pi:4d:7 t125 t125 t111 pi:37:7 t14 pi:3e:6 t15 pi:43:6 t12 pi:4a:7 t17 pi:48:7 t125 t60 pi:45:7 t121 pi:41:7 t125 t117 s:46:5 s:52:5 f:46:5 f:52:5 t121 s:45:5 s:46:0 s:51:5 s:52:0 f:45:5 f:46:0 f:51:5 f:52:0 t121 s:41:5 s:45:0 s:4d:5 s:51:0 f:41:5 f:45:0 f:4d:5 f:51:0 t102 pi:37:0 pi:3e:0 pi:41:0 pi:43:0 pi:45:0 pi:48:0 pi:4a:0 pi:4d:0 pi:4f:0 pi:51:0 pi:54:0 pi:56:0 t19 s:3e:5 s:41:0 s:4a:5 s:4d:0 f:3e:5 f:41:0 f:4a:5 f:4d:0 t121 v:3a:5 t121 v:39:7 t15 v:3a:0 t106 v:35:8 t10 v:39:0 t111 v:30:8 v:35:0 t125 t117 v:32:8 t10 v:30:0 t125 t125 t103 v:5b:0 v:5b:0 t9 pi:4a:7"
 
6
  np.set_printoptions(precision=4, suppress=True, linewidth=200)
7
 
8
  os.environ['RWKV_JIT_ON'] = '1' #### set these before import RWKV
9
+ # os.environ["RWKV_CUDA_ON"] = '0'
10
  os.environ["RWKV_RESCALE_LAYER"] = '999' # must set this for RWKV-music models and "pip install rwkv --upgrade" to v0.8.12+
11
 
12
  from rwkv.model import RWKV
 
18
  MIDI_MODE = ('-MIDI-' in MODEL_FILE)
19
  device = 'cpu'
20
  if torch.cuda.is_available(): device = 'cuda'
21
+ # model = RWKV(model=MODEL_FILE, strategy=f'{device} fp32')
 
22
 
23
+
24
+
25
+ # model = RWKV(model=MODEL_FILE, strategy=f'cuda fp32')
26
+ # pipeline = PIPELINE(model, "tokenizer-midi.json")
27
+
28
+ # tokenizer = pipeline
29
+ # EOS_ID = 0
30
+ # TOKEN_SEP = ' '
31
 
32
  def musicgen(ccc='<pad>', piano_only=False, length=4096):
33
+ model = RWKV(model=MODEL_FILE, strategy=f'cuda fp32')
34
+ pipeline = PIPELINE(model, "tokenizer-midi.json")
35
+
36
+ tokenizer = pipeline
37
+ EOS_ID = 0
38
+ TOKEN_SEP = ' '
39
+
40
  # ccc = '<pad>'
41
  ccc_output = '<start>'
42
  # ccc = "v:5b:3 v:5b:2 t125 t125 t125 t106 pi:43:5 t24 pi:4a:7 t15 pi:4f:7 t17 pi:56:7 t18 pi:54:7 t125 t49 pi:51:7 t117 pi:4d:7 t125 t125 t111 pi:37:7 t14 pi:3e:6 t15 pi:43:6 t12 pi:4a:7 t17 pi:48:7 t125 t60 pi:45:7 t121 pi:41:7 t125 t117 s:46:5 s:52:5 f:46:5 f:52:5 t121 s:45:5 s:46:0 s:51:5 s:52:0 f:45:5 f:46:0 f:51:5 f:52:0 t121 s:41:5 s:45:0 s:4d:5 s:51:0 f:41:5 f:45:0 f:4d:5 f:51:0 t102 pi:37:0 pi:3e:0 pi:41:0 pi:43:0 pi:45:0 pi:48:0 pi:4a:0 pi:4d:0 pi:4f:0 pi:51:0 pi:54:0 pi:56:0 t19 s:3e:5 s:41:0 s:4a:5 s:4d:0 f:3e:5 f:41:0 f:4a:5 f:4d:0 t121 v:3a:5 t121 v:39:7 t15 v:3a:0 t106 v:35:8 t10 v:39:0 t111 v:30:8 v:35:0 t125 t117 v:32:8 t10 v:30:0 t125 t125 t103 v:5b:0 v:5b:0 t9 pi:4a:7"