multimodalart HF Staff commited on
Commit
2f66ff4
·
verified ·
1 Parent(s): 45b95b2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -106,14 +106,14 @@ def _generate_video_segment(input_image_path: str, output_image_path: str, promp
106
  )
107
  return result[0]["video"]
108
 
109
- def unified_image_generator(prompt: str, images: Optional[List[str]], previous_video_path: Optional[str], last_frame_path: Optional[str], oauth_token: Optional[gr.OAuthToken]) -> tuple:
110
- if not verify_pro_status(oauth_token): raise gr.Error("Access Denied.")
111
  try:
112
  contents = [Image.open(image_path[0]) for image_path in images] if images else []
113
  contents.append(prompt)
114
  response = client.models.generate_content(model=GEMINI_MODEL_NAME, contents=contents)
115
  image_data = _extract_image_data_from_response(response)
116
- if not image_data: raise ValueError("No image data in response.")
117
  with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as tmp:
118
  Image.open(BytesIO(image_data)).save(tmp.name)
119
  output_path = tmp.name
@@ -195,6 +195,7 @@ with gr.Blocks(theme=gr.themes.Citrus(), css=css) as demo:
195
  with gr.Group(visible=False) as video_group:
196
  video_output = gr.Video(label="Generated Video", show_download_button=True, autoplay=True)
197
  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")
 
198
  gr.Markdown("<h2 style='text-align: center'>Thank you for being a PRO! 🤗</h2>")
199
 
200
  login_button = gr.LoginButton()
@@ -202,7 +203,7 @@ with gr.Blocks(theme=gr.themes.Citrus(), css=css) as demo:
202
  gr.on(
203
  triggers=[generate_button.click, prompt_input.submit],
204
  fn=unified_image_generator,
205
- inputs=[prompt_input, image_input_gallery, previous_video_state, last_frame_of_video_state],
206
  outputs=[output_image, create_video_button, extend_video_button, video_group]
207
  )
208
  use_image_button.click(
 
106
  )
107
  return result[0]["video"]
108
 
109
+ def unified_image_generator(prompt: str, images: Optional[List[str]], previous_video_path: Optional[str], last_frame_path: Optional[str], manual_token: str, oauth_token: Optional[gr.OAuthToken]) -> tuple:
110
+ if not (verify_pro_status(oauth_token) or verify_pro_status(manual_token)): raise gr.Error("Access Denied.")
111
  try:
112
  contents = [Image.open(image_path[0]) for image_path in images] if images else []
113
  contents.append(prompt)
114
  response = client.models.generate_content(model=GEMINI_MODEL_NAME, contents=contents)
115
  image_data = _extract_image_data_from_response(response)
116
+ if not image_data: raise gr.Error("No image data in response.")
117
  with tempfile.NamedTemporaryFile(delete=False, suffix=".png") as tmp:
118
  Image.open(BytesIO(image_data)).save(tmp.name)
119
  output_path = tmp.name
 
195
  with gr.Group(visible=False) as video_group:
196
  video_output = gr.Video(label="Generated Video", show_download_button=True, autoplay=True)
197
  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")
198
+ manual_token = gr.Textbox("Manual Token (to use with the API)", visible=False)
199
  gr.Markdown("<h2 style='text-align: center'>Thank you for being a PRO! 🤗</h2>")
200
 
201
  login_button = gr.LoginButton()
 
203
  gr.on(
204
  triggers=[generate_button.click, prompt_input.submit],
205
  fn=unified_image_generator,
206
+ inputs=[prompt_input, image_input_gallery, previous_video_state, last_frame_of_video_state, manual_token],
207
  outputs=[output_image, create_video_button, extend_video_button, video_group]
208
  )
209
  use_image_button.click(