reach-vb HF staff commited on
Commit
4f3af99
β€’
1 Parent(s): 2f922d0

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +5 -5
README.md CHANGED
@@ -63,13 +63,13 @@ Try out MusicGen yourself!
63
 
64
  ## πŸ€— Transformers Usage
65
 
66
- You can run MusicGen locally with the πŸ€— Transformers library from version 4.31.0 onwards.
67
 
68
  1. First install the πŸ€— [Transformers library](https://github.com/huggingface/transformers) and scipy:
69
 
70
  ```
71
  pip install --upgrade pip
72
- pip install --upgrade transformers scipy
73
  ```
74
 
75
  2. Run inference via the `Text-to-Audio` (TTA) pipeline. You can infer the MusicGen model via the TTA pipeline in just a few lines of code!
@@ -78,7 +78,7 @@ pip install --upgrade transformers scipy
78
  from transformers import pipeline
79
  import scipy
80
 
81
- synthesiser = pipeline("text-to-audio", "facebook/musicgen-stereo-small")
82
 
83
  music = synthesiser("lo-fi music with a soothing melody", forward_params={"do_sample": True})
84
 
@@ -91,13 +91,13 @@ scipy.io.wavfile.write("musicgen_out.wav", rate=music["sampling_rate"], music=au
91
  from transformers import AutoProcessor, MusicgenForConditionalGeneration
92
 
93
  processor = AutoProcessor.from_pretrained("facebook/musicgen-stereo-small")
94
- model = MusicgenForConditionalGeneration.from_pretrained("facebook/musicgen-stereo-small")
95
 
96
  inputs = processor(
97
  text=["80s pop track with bassy drums and synth", "90s rock song with loud guitars and heavy drums"],
98
  padding=True,
99
  return_tensors="pt",
100
- )
101
 
102
  audio_values = model.generate(**inputs, max_new_tokens=256)
103
  ```
 
63
 
64
  ## πŸ€— Transformers Usage
65
 
66
+ You can run MusicGen Stereo models locally with the πŸ€— Transformers library from `main` onward.
67
 
68
  1. First install the πŸ€— [Transformers library](https://github.com/huggingface/transformers) and scipy:
69
 
70
  ```
71
  pip install --upgrade pip
72
+ pip install --upgrade git+https://github.com/huggingface/transformers.git scipy
73
  ```
74
 
75
  2. Run inference via the `Text-to-Audio` (TTA) pipeline. You can infer the MusicGen model via the TTA pipeline in just a few lines of code!
 
78
  from transformers import pipeline
79
  import scipy
80
 
81
+ synthesiser = pipeline("text-to-audio", "facebook/musicgen-stereo-small", device="cuda")
82
 
83
  music = synthesiser("lo-fi music with a soothing melody", forward_params={"do_sample": True})
84
 
 
91
  from transformers import AutoProcessor, MusicgenForConditionalGeneration
92
 
93
  processor = AutoProcessor.from_pretrained("facebook/musicgen-stereo-small")
94
+ model = MusicgenForConditionalGeneration.from_pretrained("facebook/musicgen-stereo-small").to("cuda")
95
 
96
  inputs = processor(
97
  text=["80s pop track with bassy drums and synth", "90s rock song with loud guitars and heavy drums"],
98
  padding=True,
99
  return_tensors="pt",
100
+ ).to("cuda")
101
 
102
  audio_values = model.generate(**inputs, max_new_tokens=256)
103
  ```