multimodalart HF Staff commited on
Commit
ca5ee29
·
verified ·
1 Parent(s): 9b92b0d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -12
app.py CHANGED
@@ -303,7 +303,6 @@ with gr.Blocks(theme=gr.themes.Citrus(), css=css) as demo:
303
  generate_button = gr.Button("Generate", variant="primary")
304
  with gr.Column(scale=1):
305
  output_image = gr.Image(label="Output", interactive=False, elem_id="output", type="filepath")
306
- status_message = gr.Markdown("", visible=True)
307
  use_image_button = gr.Button("♻️ Use this Image for Next Edit", variant="primary")
308
  with gr.Row():
309
  create_video_button = gr.Button("Create video between the two images 🎥", variant="secondary", visible=False)
@@ -311,7 +310,7 @@ with gr.Blocks(theme=gr.themes.Citrus(), css=css) as demo:
311
  with gr.Group(visible=False) as video_group:
312
  video_output = gr.Video(label="Generated Video", show_download_button=True, autoplay=True)
313
  gr.Markdown("Generate more with [Wan 2.2 first-last-frame](https://huggingface.co/spaces/multimodalart/wan-2-2-first-last-frame)", elem_id="wan_ad")
314
- manual_token = gr.Textbox("Manual Token (to use with the API)", visible=False)
315
  gr.Markdown("<h2 style='text-align: center'>Thank you for being a PRO! 🤗</h2>")
316
 
317
  login_button = gr.LoginButton()
@@ -320,15 +319,15 @@ with gr.Blocks(theme=gr.themes.Citrus(), css=css) as demo:
320
  triggers=[generate_button.click, prompt_input.submit],
321
  fn=unified_image_generator,
322
  inputs=[prompt_input, image_input_gallery, previous_video_state, last_frame_of_video_state, manual_token],
323
- outputs=[output_image, create_video_button, extend_video_button, video_group, status_message]
324
  )
325
  use_image_button.click(
326
  fn=lambda img: (
327
  [img] if img else None, None, gr.update(visible=False),
328
- gr.update(visible=False), gr.update(visible=False), ""
329
  ),
330
  inputs=[output_image],
331
- outputs=[image_input_gallery, output_image, create_video_button, extend_video_button, video_group, status_message]
332
  )
333
  create_video_button.click(
334
  fn=lambda: gr.update(visible=True), outputs=[video_group]
@@ -346,12 +345,9 @@ with gr.Blocks(theme=gr.themes.Citrus(), css=css) as demo:
346
  )
347
 
348
  def control_access(profile: Optional[gr.OAuthProfile] = None, oauth_token: Optional[gr.OAuthToken] = None):
349
- if not profile: return gr.update(visible=False), gr.update(visible=False), ""
350
  if verify_pro_status(oauth_token):
351
- username = get_username(oauth_token)
352
- remaining = get_remaining_generations(username) if username else 80
353
- status = f"Welcome! You have {remaining} generations remaining today."
354
- return gr.update(visible=True), gr.update(visible=False), status
355
  else:
356
  message = (
357
  "## ✨ Exclusive Access for PRO Users\n\n"
@@ -359,8 +355,8 @@ with gr.Blocks(theme=gr.themes.Citrus(), css=css) as demo:
359
  "To unlock this and many other cool stuff, please consider upgrading your account.\n\n"
360
  "### [**Become a PRO Today!**](http://huggingface.co/subscribe/pro?source=nana_banana)"
361
  )
362
- return gr.update(visible=False), gr.update(visible=True, value=message), ""
363
- demo.load(control_access, inputs=None, outputs=[main_interface, pro_message, status_message])
364
 
365
  if __name__ == "__main__":
366
  demo.queue(max_size=None, default_concurrency_limit=None).launch(show_error=True)
 
303
  generate_button = gr.Button("Generate", variant="primary")
304
  with gr.Column(scale=1):
305
  output_image = gr.Image(label="Output", interactive=False, elem_id="output", type="filepath")
 
306
  use_image_button = gr.Button("♻️ Use this Image for Next Edit", variant="primary")
307
  with gr.Row():
308
  create_video_button = gr.Button("Create video between the two images 🎥", variant="secondary", visible=False)
 
310
  with gr.Group(visible=False) as video_group:
311
  video_output = gr.Video(label="Generated Video", show_download_button=True, autoplay=True)
312
  gr.Markdown("Generate more with [Wan 2.2 first-last-frame](https://huggingface.co/spaces/multimodalart/wan-2-2-first-last-frame)", elem_id="wan_ad")
313
+ manual_token = gr.Textbox("Manual Token (to use with the API)", visible=False)
314
  gr.Markdown("<h2 style='text-align: center'>Thank you for being a PRO! 🤗</h2>")
315
 
316
  login_button = gr.LoginButton()
 
319
  triggers=[generate_button.click, prompt_input.submit],
320
  fn=unified_image_generator,
321
  inputs=[prompt_input, image_input_gallery, previous_video_state, last_frame_of_video_state, manual_token],
322
+ outputs=[output_image, create_video_button, extend_video_button, video_group]
323
  )
324
  use_image_button.click(
325
  fn=lambda img: (
326
  [img] if img else None, None, gr.update(visible=False),
327
+ gr.update(visible=False), gr.update(visible=False)
328
  ),
329
  inputs=[output_image],
330
+ outputs=[image_input_gallery, output_image, create_video_button, extend_video_button, video_group]
331
  )
332
  create_video_button.click(
333
  fn=lambda: gr.update(visible=True), outputs=[video_group]
 
345
  )
346
 
347
  def control_access(profile: Optional[gr.OAuthProfile] = None, oauth_token: Optional[gr.OAuthToken] = None):
348
+ if not profile: return gr.update(visible=False), gr.update(visible=False)
349
  if verify_pro_status(oauth_token):
350
+ return gr.update(visible=True), gr.update(visible=False)
 
 
 
351
  else:
352
  message = (
353
  "## ✨ Exclusive Access for PRO Users\n\n"
 
355
  "To unlock this and many other cool stuff, please consider upgrading your account.\n\n"
356
  "### [**Become a PRO Today!**](http://huggingface.co/subscribe/pro?source=nana_banana)"
357
  )
358
+ return gr.update(visible=False), gr.update(visible=True, value=message)
359
+ demo.load(control_access, inputs=None, outputs=[main_interface, pro_message])
360
 
361
  if __name__ == "__main__":
362
  demo.queue(max_size=None, default_concurrency_limit=None).launch(show_error=True)