jbilcke-hf HF staff commited on
Commit
898e44d
1 Parent(s): d5723da

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -10
app.py CHANGED
@@ -24,6 +24,8 @@ from audiocraft.data.audio import audio_write
24
  from audiocraft.models import MAGNeT
25
 
26
 
 
 
27
  MODEL = None # Last used model
28
  SPACE_ID = os.environ.get('SPACE_ID', '')
29
  MAX_BATCH_SIZE = 12
@@ -131,11 +133,15 @@ def predict_batched(texts, melodies):
131
  res = _do_predictions(texts, melodies)
132
  return res
133
 
134
- def predict_full(model, model_path, text, temperature, topp,
135
  max_cfg_coef, min_cfg_coef,
136
  decoding_steps1, decoding_steps2, decoding_steps3, decoding_steps4,
137
  span_score,
138
  progress=gr.Progress()):
 
 
 
 
139
  global INTERRUPTING
140
  INTERRUPTING = False
141
  progress(0, desc="Loading model...")
@@ -191,15 +197,13 @@ def predict_full(model, model_path, text, temperature, topp,
191
 
192
  def ui_full(launch_kwargs):
193
  with gr.Blocks() as interface:
194
- gr.Markdown(
195
- """
196
- # MAGNeT
197
- This is a temporary demo for [MAGNeT](https://github.com/facebookresearch/audiocraft),
198
- [running from <a href="https://github.com/facebookresearch/audiocraft/commit/7dece43a4d186e47e5e1c67983ed10a99f225948" target="_blank">"magnet_xformers_0_0_22_fix" audiocraft branch</a>]<br />
199
- A fast text-to-music model, consists of a single, non-autoregressive transformer.
200
- presented at: ["Masked Audio Generation using a Single Non-Autoregressive Transformer"] (https://huggingface.co/papers/2401.04577)
201
- """
202
- )
203
  with gr.Row():
204
  with gr.Column():
205
  secret_token = gr.Textbox((label="Secret Token")
 
24
  from audiocraft.models import MAGNeT
25
 
26
 
27
+ SECRET_TOKEN = os.getenv('SECRET_TOKEN', 'default_secret')
28
+
29
  MODEL = None # Last used model
30
  SPACE_ID = os.environ.get('SPACE_ID', '')
31
  MAX_BATCH_SIZE = 12
 
133
  res = _do_predictions(texts, melodies)
134
  return res
135
 
136
+ def predict_full(secre_token, model, model_path, text, temperature, topp,
137
  max_cfg_coef, min_cfg_coef,
138
  decoding_steps1, decoding_steps2, decoding_steps3, decoding_steps4,
139
  span_score,
140
  progress=gr.Progress()):
141
+ if secret_token != SECRET_TOKEN:
142
+ raise gr.Error(
143
+ f'Invalid secret token. Please fork the original space if you want to use it for yourself.')
144
+
145
  global INTERRUPTING
146
  INTERRUPTING = False
147
  progress(0, desc="Loading model...")
 
197
 
198
  def ui_full(launch_kwargs):
199
  with gr.Blocks() as interface:
200
+ gr.HTML("""
201
+ <div style="z-index: 100; position: fixed; top: 0px; right: 0px; left: 0px; bottom: 0px; width: 100%; height: 100%; background: white; display: flex; align-items: center; justify-content: center; color: black;">
202
+ <div style="text-align: center; color: black;">
203
+ <p style="color: black;">This space is a headless component of the cloud rendering engine used by AiTube.</p>
204
+ <p style="color: black;">It is not available for public use, but you can use the <a href="https://huggingface.co/spaces/doevent/AnimateLCM-SVD" target="_blank">original space</a>.</p>
205
+ </div>
206
+ </div>""")
 
 
207
  with gr.Row():
208
  with gr.Column():
209
  secret_token = gr.Textbox((label="Secret Token")