openfree commited on
Commit
068452f
Β·
verified Β·
1 Parent(s): 7409da1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -21
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
- # λΉ„λ””μ˜€ 생성 API 호좜
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 and sound_generation == "μ‚¬μš΄λ“œ 생성" and MMAUDIO_LOADED:
271
- # μ‚¬μš΄λ“œ ν”„λ‘¬ν”„νŠΈκ°€ λΉ„μ–΄μžˆμœΌλ©΄ κΈ°λ³Έκ°’ μ‚¬μš©
272
- if not sound_prompt:
273
- sound_prompt = prompt if prompt else "ambient sound"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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)}")