Update app.py
Browse files
app.py
CHANGED
@@ -248,7 +248,7 @@ def generate_video_from_image(image, prompt="", length=4.0, sound_generation="
|
|
248 |
temp_path = fp.name
|
249 |
Image.fromarray(image).save(temp_path)
|
250 |
|
251 |
-
#
|
252 |
client = Client(VIDEO_API_URL)
|
253 |
result = client.predict(
|
254 |
input_image=handle_file(temp_path),
|
@@ -266,27 +266,33 @@ def generate_video_from_image(image, prompt="", length=4.0, sound_generation="
|
|
266 |
video_dict = result[0]
|
267 |
video_path = video_dict.get("video") if isinstance(video_dict, dict) else None
|
268 |
|
269 |
-
#
|
270 |
-
if video_path
|
271 |
-
# μ¬μ΄λ
|
272 |
-
if
|
273 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
274 |
|
275 |
-
#
|
276 |
-
|
277 |
-
video_with_sound = video_to_audio(
|
278 |
-
video_path=video_path,
|
279 |
-
prompt=sound_prompt,
|
280 |
-
negative_prompt=sound_negative_prompt,
|
281 |
-
seed=random.randint(0, 9999999),
|
282 |
-
num_steps=25,
|
283 |
-
cfg_strength=4.5,
|
284 |
-
target_duration=length # duration β target_duration
|
285 |
-
)
|
286 |
-
|
287 |
-
return video_with_sound
|
288 |
-
|
289 |
-
return video_path
|
290 |
|
291 |
except Exception as e:
|
292 |
logging.error(f"Video generation error: {str(e)}")
|
|
|
248 |
temp_path = fp.name
|
249 |
Image.fromarray(image).save(temp_path)
|
250 |
|
251 |
+
# API νΈμΆ (μλ μ½λμ λμΌ)
|
252 |
client = Client(VIDEO_API_URL)
|
253 |
result = client.predict(
|
254 |
input_image=handle_file(temp_path),
|
|
|
266 |
video_dict = result[0]
|
267 |
video_path = video_dict.get("video") if isinstance(video_dict, dict) else None
|
268 |
|
269 |
+
# λΉλμ€ μμ±μ΄ μ±κ³΅ν κ²½μ°μλ§ μ¬μ΄λ μΆκ°
|
270 |
+
if video_path:
|
271 |
+
# μ¬μ΄λ μμ± μ΅μ
μ΄ μ νλ κ²½μ°
|
272 |
+
if sound_generation == "μ¬μ΄λ μμ±" and MMAUDIO_LOADED:
|
273 |
+
try:
|
274 |
+
# μ¬μ΄λ ν둬ννΈκ° λΉμ΄μμΌλ©΄ κΈ°λ³Έκ° μ¬μ©
|
275 |
+
if not sound_prompt:
|
276 |
+
sound_prompt = prompt if prompt else "ambient sound"
|
277 |
+
|
278 |
+
# λΉλμ€μ μ¬μ΄λ μΆκ°
|
279 |
+
video_with_sound = video_to_audio(
|
280 |
+
video_path=video_path,
|
281 |
+
prompt=sound_prompt,
|
282 |
+
negative_prompt=sound_negative_prompt,
|
283 |
+
seed=random.randint(0, 9999999),
|
284 |
+
num_steps=25,
|
285 |
+
cfg_strength=4.5,
|
286 |
+
target_duration=length
|
287 |
+
)
|
288 |
+
return video_with_sound
|
289 |
+
except Exception as e:
|
290 |
+
logging.error(f"Sound generation error: {str(e)}")
|
291 |
+
# μ¬μ΄λ μμ± μ€ν¨ μ μλ³Έ λΉλμ€ λ°ν
|
292 |
+
return video_path
|
293 |
|
294 |
+
# μ¬μ΄λ μμ±μ μ ννμ§ μμ κ²½μ° μλ³Έ λΉλμ€ λ°ν
|
295 |
+
return video_path
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
296 |
|
297 |
except Exception as e:
|
298 |
logging.error(f"Video generation error: {str(e)}")
|