Uhhy commited on
Commit
d1805ac
1 Parent(s): e9cb163

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -25,8 +25,14 @@ def load_model():
25
  processor_bytes = io.BytesIO()
26
  processor = MusicgenProcessor.from_pretrained("facebook/musicgen-small")
27
 
28
- # Save the tokenizer and feature extractor using the `save_vocabulary` and `save_pretrained` methods respectively
29
- processor.tokenizer.save_vocabulary(processor_bytes)
 
 
 
 
 
 
30
  processor.feature_extractor.save_pretrained(processor_bytes)
31
 
32
  processor = MusicgenProcessor.from_pretrained(processor_bytes)
 
25
  processor_bytes = io.BytesIO()
26
  processor = MusicgenProcessor.from_pretrained("facebook/musicgen-small")
27
 
28
+ # Get the vocabulary from the tokenizer and write it directly to the BytesIO object
29
+ vocabulary = processor.tokenizer.get_vocab()
30
+ with io.open(processor_bytes, "w", encoding="utf-8") as f:
31
+ for word, index in vocabulary.items():
32
+ f.write(f"{word} {index}\n")
33
+
34
+ processor_bytes.seek(0) # Reset the stream position
35
+
36
  processor.feature_extractor.save_pretrained(processor_bytes)
37
 
38
  processor = MusicgenProcessor.from_pretrained(processor_bytes)