sander-wood commited on
Commit
c95e20d
1 Parent(s): 0e3e69a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -7
app.py CHANGED
@@ -9,7 +9,7 @@ import requests
9
  from samplings import top_p_sampling, top_k_sampling, temperature_sampling
10
  from transformers import GPT2Config, GPT2Model, GPT2LMHeadModel, PreTrainedModel
11
 
12
- device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
13
 
14
  description = """
15
  <div>
@@ -23,7 +23,7 @@ description = """
23
  ## ℹ️ How to use this demo?
24
  1. Enter the control codes to set the musical form of the generated music. For details, please refer to the below "Control Codes" section. (optional)
25
  2. Enter the prompt of the generated music. You can set the control codes to set the musical form, ABC header (i.e., note length, tempo, meter, and key) and the motif of the melody. (optional)
26
- 2. You can set the parameters (i.e., number of tunes, maximum patch, top-p, top-k, temperature and random seed) for the generation. (optional)
27
  3. Click "Submit" and wait for the result.
28
  4. The generated ABC notation can be played or edited using [EasyABC]([ABC Sheet Music Editor - EasyABC](https://easyabc.sourceforge.net/), you can also use this [Online ABC Player](https://abc.rectanglered.com/) to render the tune.
29
 
@@ -99,11 +99,6 @@ def generate_abc(prompt,
99
  temperature,
100
  seed):
101
 
102
- if torch.cuda.is_available():
103
- device = torch.device("cuda")
104
- else:
105
- device = torch.device("cpu")
106
-
107
  tokenizer = ABCTokenizer()
108
  config = GPT2Config(vocab_size=len(tokenizer))
109
  model = GPT2LMHeadModel(config).to(device)
 
9
  from samplings import top_p_sampling, top_k_sampling, temperature_sampling
10
  from transformers import GPT2Config, GPT2Model, GPT2LMHeadModel, PreTrainedModel
11
 
12
+ device = torch.device("cpu")
13
 
14
  description = """
15
  <div>
 
23
  ## ℹ️ How to use this demo?
24
  1. Enter the control codes to set the musical form of the generated music. For details, please refer to the below "Control Codes" section. (optional)
25
  2. Enter the prompt of the generated music. You can set the control codes to set the musical form, ABC header (i.e., note length, tempo, meter, and key) and the motif of the melody. (optional)
26
+ 2. You can set the parameters (i.e., number of tunes, maximum length, top-p, top-k, temperature and random seed) for the generation. (optional)
27
  3. Click "Submit" and wait for the result.
28
  4. The generated ABC notation can be played or edited using [EasyABC]([ABC Sheet Music Editor - EasyABC](https://easyabc.sourceforge.net/), you can also use this [Online ABC Player](https://abc.rectanglered.com/) to render the tune.
29
 
 
99
  temperature,
100
  seed):
101
 
 
 
 
 
 
102
  tokenizer = ABCTokenizer()
103
  config = GPT2Config(vocab_size=len(tokenizer))
104
  model = GPT2LMHeadModel(config).to(device)