aiqcamp commited on
Commit
c388283
ยท
verified ยท
1 Parent(s): 1b1ded9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -4
app.py CHANGED
@@ -30,7 +30,9 @@ from mmaudio.model.flow_matching import FlowMatching
30
  from mmaudio.model.networks import MMAudio, get_my_mmaudio
31
  from mmaudio.model.sequence_config import SequenceConfig
32
  from mmaudio.model.utils.features_utils import FeaturesUtils
33
-
 
 
34
  # 3. API ์„ค์ •
35
  CATBOX_USER_HASH = "30f52c895fd9d9cb387eee489"
36
  REPLICATE_API_TOKEN = os.getenv("API_KEY")
@@ -424,31 +426,43 @@ with gr.Blocks(theme="Yntec/HaleyCH_Theme_Orange", css=css) as demo:
424
  with gr.Column(scale=4):
425
  video_output = gr.Video(label="Generated Video")
426
 
 
 
 
 
427
  def process_and_generate_video(image, prompt):
428
  if image is None:
429
  return "Please upload an image"
430
 
431
  try:
 
 
 
 
 
 
 
432
  img = Image.open(image)
433
  if img.mode != 'RGB':
434
  img = img.convert('RGB')
435
-
436
  temp_path = f"temp_{int(time.time())}.png"
437
  img.save(temp_path, 'PNG')
438
-
439
  result = generate_video(temp_path, prompt)
440
 
441
  try:
442
  os.remove(temp_path)
443
  except:
444
  pass
445
-
446
  return result
447
 
448
  except Exception as e:
449
  logger.error(f"Error processing image: {str(e)}")
450
  return "Error processing image"
451
 
 
452
  video_generate_btn.click(
453
  process_and_generate_video,
454
  inputs=[upload_image, video_prompt],
 
30
  from mmaudio.model.networks import MMAudio, get_my_mmaudio
31
  from mmaudio.model.sequence_config import SequenceConfig
32
  from mmaudio.model.utils.features_utils import FeaturesUtils
33
+ # ์ƒ๋‹จ์— ๋ฒˆ์—ญ ๋ชจ๋ธ import ์ถ”๊ฐ€
34
+ from transformers import pipeline
35
+ translator = pipeline("translation", model="Helsinki-NLP/opus-mt-ko-en")
36
  # 3. API ์„ค์ •
37
  CATBOX_USER_HASH = "30f52c895fd9d9cb387eee489"
38
  REPLICATE_API_TOKEN = os.getenv("API_KEY")
 
426
  with gr.Column(scale=4):
427
  video_output = gr.Video(label="Generated Video")
428
 
429
+
430
+
431
+
432
+ # process_and_generate_video ํ•จ์ˆ˜ ์ˆ˜์ •
433
  def process_and_generate_video(image, prompt):
434
  if image is None:
435
  return "Please upload an image"
436
 
437
  try:
438
+ # ํ•œ๊ธ€ ํ”„๋กฌํ”„ํŠธ ๊ฐ์ง€ ๋ฐ ๋ฒˆ์—ญ
439
+ contains_korean = any(ord('๊ฐ€') <= ord(char) <= ord('ํžฃ') for char in prompt)
440
+ if contains_korean:
441
+ translated = translator(prompt)[0]['translation_text']
442
+ logger.info(f"Translated prompt from '{prompt}' to '{translated}'")
443
+ prompt = translated
444
+
445
  img = Image.open(image)
446
  if img.mode != 'RGB':
447
  img = img.convert('RGB')
448
+
449
  temp_path = f"temp_{int(time.time())}.png"
450
  img.save(temp_path, 'PNG')
451
+
452
  result = generate_video(temp_path, prompt)
453
 
454
  try:
455
  os.remove(temp_path)
456
  except:
457
  pass
458
+
459
  return result
460
 
461
  except Exception as e:
462
  logger.error(f"Error processing image: {str(e)}")
463
  return "Error processing image"
464
 
465
+
466
  video_generate_btn.click(
467
  process_and_generate_video,
468
  inputs=[upload_image, video_prompt],