Update a.py
Browse files
a.py
CHANGED
|
@@ -102,38 +102,7 @@ def generate_video(image_path, prompt_text, progress=gr.Progress()):
|
|
| 102 |
|
| 103 |
progress(0.3, desc="Polling for results...")
|
| 104 |
|
| 105 |
-
|
| 106 |
-
attempts = 0
|
| 107 |
-
max_attempts = 120
|
| 108 |
-
|
| 109 |
-
while attempts < max_attempts:
|
| 110 |
-
try:
|
| 111 |
-
get_result = client.content_generation.tasks.get(task_id=task_id)
|
| 112 |
-
status = get_result.status
|
| 113 |
-
|
| 114 |
-
if status == "succeeded":
|
| 115 |
-
progress(1.0, desc="Complete!")
|
| 116 |
-
video_url = get_result.content.video_url if hasattr(get_result, 'content') else None
|
| 117 |
-
print(f"Video URL: {video_url}")
|
| 118 |
-
yield "✅ Video generated successfully!", video_url
|
| 119 |
-
return
|
| 120 |
-
|
| 121 |
-
elif status == "failed":
|
| 122 |
-
error_msg = get_result.error if hasattr(get_result, 'error') else "Unknown error"
|
| 123 |
-
yield f"❌ Failed: {error_msg}", None
|
| 124 |
-
return
|
| 125 |
-
else:
|
| 126 |
-
progress(0.3 + (attempts/max_attempts)*0.7, desc=f"Status: {status}")
|
| 127 |
-
yield f"⏳ Status: {status}... (attempt {attempts + 1})", None
|
| 128 |
-
time.sleep(1)
|
| 129 |
-
attempts += 1
|
| 130 |
-
|
| 131 |
-
except Exception as e:
|
| 132 |
-
print(f"Polling error: {e}")
|
| 133 |
-
time.sleep(2)
|
| 134 |
-
attempts += 1
|
| 135 |
-
|
| 136 |
-
yield "⏰ Timeout after 2 minutes", None
|
| 137 |
|
| 138 |
except Exception as e:
|
| 139 |
print(f"Error: {e}")
|
|
|
|
| 102 |
|
| 103 |
progress(0.3, desc="Polling for results...")
|
| 104 |
|
| 105 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
|
| 107 |
except Exception as e:
|
| 108 |
print(f"Error: {e}")
|