Update Gradio app with multiple files
Browse files
app.py
CHANGED
|
@@ -41,7 +41,7 @@ def _save_bytes_as_temp_mp4(data: bytes) -> str:
|
|
| 41 |
finally:
|
| 42 |
temp_file.close()
|
| 43 |
|
| 44 |
-
def generate_video_with_auth(image, prompt, token: gr.OAuthToken | None
|
| 45 |
"""
|
| 46 |
Generate a video from an image using the Ovi model with authentication check.
|
| 47 |
|
|
@@ -49,7 +49,6 @@ def generate_video_with_auth(image, prompt, token: gr.OAuthToken | None, progres
|
|
| 49 |
image: Input image (PIL Image or file path)
|
| 50 |
prompt: Text prompt describing the desired motion/animation
|
| 51 |
token: OAuth token for authentication
|
| 52 |
-
progress: Gradio progress tracker
|
| 53 |
|
| 54 |
Returns:
|
| 55 |
Tuple of (video_path, status_message)
|
|
@@ -66,8 +65,6 @@ def generate_video_with_auth(image, prompt, token: gr.OAuthToken | None, progres
|
|
| 66 |
|
| 67 |
cleanup_temp_files()
|
| 68 |
|
| 69 |
-
progress(0.2, desc="Processing image...")
|
| 70 |
-
|
| 71 |
# Read the image file
|
| 72 |
if isinstance(image, str):
|
| 73 |
with open(image, "rb") as image_file:
|
|
@@ -89,8 +86,6 @@ def generate_video_with_auth(image, prompt, token: gr.OAuthToken | None, progres
|
|
| 89 |
pil_image.save(buffer, format='PNG')
|
| 90 |
input_image = buffer.getvalue()
|
| 91 |
|
| 92 |
-
progress(0.4, desc="Generating video with AI...")
|
| 93 |
-
|
| 94 |
# Create client with user's token
|
| 95 |
client = _client_from_token(token.token)
|
| 96 |
|
|
@@ -107,13 +102,9 @@ def generate_video_with_auth(image, prompt, token: gr.OAuthToken | None, progres
|
|
| 107 |
return None, "❌ Access denied by provider (403). Make sure your HF account has credits/permission for provider 'fal-ai' and model 'chetwinlow1/Ovi'."
|
| 108 |
raise
|
| 109 |
|
| 110 |
-
progress(0.9, desc="Finalizing video...")
|
| 111 |
-
|
| 112 |
# Save the video to a temporary file
|
| 113 |
video_path = _save_bytes_as_temp_mp4(video)
|
| 114 |
|
| 115 |
-
progress(1.0, desc="Complete!")
|
| 116 |
-
|
| 117 |
return video_path, f"✅ Video generated successfully with motion: '{prompt[:50]}...'"
|
| 118 |
|
| 119 |
except gr.Error as e:
|
|
|
|
| 41 |
finally:
|
| 42 |
temp_file.close()
|
| 43 |
|
| 44 |
+
def generate_video_with_auth(image, prompt, token: gr.OAuthToken | None):
|
| 45 |
"""
|
| 46 |
Generate a video from an image using the Ovi model with authentication check.
|
| 47 |
|
|
|
|
| 49 |
image: Input image (PIL Image or file path)
|
| 50 |
prompt: Text prompt describing the desired motion/animation
|
| 51 |
token: OAuth token for authentication
|
|
|
|
| 52 |
|
| 53 |
Returns:
|
| 54 |
Tuple of (video_path, status_message)
|
|
|
|
| 65 |
|
| 66 |
cleanup_temp_files()
|
| 67 |
|
|
|
|
|
|
|
| 68 |
# Read the image file
|
| 69 |
if isinstance(image, str):
|
| 70 |
with open(image, "rb") as image_file:
|
|
|
|
| 86 |
pil_image.save(buffer, format='PNG')
|
| 87 |
input_image = buffer.getvalue()
|
| 88 |
|
|
|
|
|
|
|
| 89 |
# Create client with user's token
|
| 90 |
client = _client_from_token(token.token)
|
| 91 |
|
|
|
|
| 102 |
return None, "❌ Access denied by provider (403). Make sure your HF account has credits/permission for provider 'fal-ai' and model 'chetwinlow1/Ovi'."
|
| 103 |
raise
|
| 104 |
|
|
|
|
|
|
|
| 105 |
# Save the video to a temporary file
|
| 106 |
video_path = _save_bytes_as_temp_mp4(video)
|
| 107 |
|
|
|
|
|
|
|
| 108 |
return video_path, f"✅ Video generated successfully with motion: '{prompt[:50]}...'"
|
| 109 |
|
| 110 |
except gr.Error as e:
|