akhaliq HF Staff commited on
Commit
8422115
·
verified ·
1 Parent(s): c0a903a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -45,15 +45,14 @@ def _save_bytes_as_temp_mp4(data: bytes) -> str:
45
  finally:
46
  temp_file.close()
47
 
48
- def generate_video_with_auth(image, prompt, token: gr.OAuthToken | None, *args, progress=gr.Progress()):
49
  """
50
  Generate a video from an image using the Ovi model with authentication check.
51
 
52
  Args:
53
  image: Input image (PIL Image or file path)
54
  prompt: Text prompt describing the desired motion/animation
55
- token: OAuth token for authentication
56
- *args: Additional arguments from Gradio
57
  progress: Gradio progress tracker
58
 
59
  Returns:
@@ -61,7 +60,7 @@ def generate_video_with_auth(image, prompt, token: gr.OAuthToken | None, *args,
61
  """
62
  try:
63
  # Check authentication
64
- if token is None or not getattr(token, "token", None):
65
  return None, "❌ Sign in with Hugging Face to continue. This app uses your inference provider credits."
66
 
67
  if image is None:
@@ -97,8 +96,12 @@ def generate_video_with_auth(image, prompt, token: gr.OAuthToken | None, *args,
97
 
98
  progress(0.4, desc="Generating video with AI...")
99
 
100
- # Create client with user's token
101
- client = _client_from_token(token.token)
 
 
 
 
102
 
103
  # Generate video using the inference client
104
  try:
 
45
  finally:
46
  temp_file.close()
47
 
48
+ def generate_video_with_auth(image, prompt, profile: gr.OAuthProfile | None, progress=gr.Progress()):
49
  """
50
  Generate a video from an image using the Ovi model with authentication check.
51
 
52
  Args:
53
  image: Input image (PIL Image or file path)
54
  prompt: Text prompt describing the desired motion/animation
55
+ profile: OAuth profile for authentication
 
56
  progress: Gradio progress tracker
57
 
58
  Returns:
 
60
  """
61
  try:
62
  # Check authentication
63
+ if profile is None:
64
  return None, "❌ Sign in with Hugging Face to continue. This app uses your inference provider credits."
65
 
66
  if image is None:
 
96
 
97
  progress(0.4, desc="Generating video with AI...")
98
 
99
+ # Create client with user's OAuth token (not HF_TOKEN)
100
+ # IMPORTANT: Do not use bill_to parameter - this ensures user gets billed
101
+ client = InferenceClient(
102
+ provider="fal-ai",
103
+ api_key=profile.oauth_info.access_token, # Use user's token
104
+ )
105
 
106
  # Generate video using the inference client
107
  try: