seawolf2357 commited on
Commit
513a44d
β€’
1 Parent(s): a0b6e16

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -12
app.py CHANGED
@@ -6,21 +6,16 @@ import shutil # 이 뢀뢄을 μΆ”κ°€
6
 
7
 
8
  def images_to_video(image_files):
 
9
  temp_dir = tempfile.mkdtemp()
10
- image_paths = []
11
 
 
12
  for i, image_file in enumerate(image_files):
13
- image_path = os.path.join(temp_dir, f"image_{i}.png")
14
-
15
- # 파일 λ‚΄μš©μ„ λ°”μ΄νŠΈλ‘œ μ“°κ±°λ‚˜ 이미 μ‘΄μž¬ν•˜λŠ” νŒŒμΌμ„ 볡사
16
- if isinstance(image_file, bytes):
17
- with open(image_path, "wb") as f:
18
- f.write(image_file)
19
- else:
20
- # shutil λͺ¨λ“ˆμ˜ copy ν•¨μˆ˜ μ‚¬μš©
21
- shutil.copy(image_file, image_path)
22
-
23
- image_paths.append(image_path)
24
 
25
  # 이미지 μ‹œν€€μŠ€λ‘œλΆ€ν„° λΉ„λ””μ˜€ 클립 생성 및 기타 둜직...
26
 
@@ -35,6 +30,8 @@ def images_to_video(image_files):
35
  # μƒμ„±λœ λΉ„λ””μ˜€ 파일 경둜 λ°˜ν™˜
36
  return output_video_path
37
 
 
 
38
  # Gradio μΈν„°νŽ˜μ΄μŠ€ μ •μ˜
39
  with gr.Blocks() as demo:
40
  with gr.Row():
 
6
 
7
 
8
  def images_to_video(image_files):
9
+ # μž„μ‹œ 디렉터리 생성
10
  temp_dir = tempfile.mkdtemp()
 
11
 
12
+ image_paths = []
13
  for i, image_file in enumerate(image_files):
14
+ # μ—…λ‘œλ“œλœ νŒŒμΌμ„ μž„μ‹œ 파일둜 μ €μž₯
15
+ temp_file_path = os.path.join(temp_dir, f"image_{i}.png")
16
+ with open(temp_file_path, "wb") as f:
17
+ f.write(image_file.read()) # λ°”μ΄νŠΈ 데이터λ₯Ό 파일둜 μ €μž₯
18
+ image_paths.append(temp_file_path)
 
 
 
 
 
 
19
 
20
  # 이미지 μ‹œν€€μŠ€λ‘œλΆ€ν„° λΉ„λ””μ˜€ 클립 생성 및 기타 둜직...
21
 
 
30
  # μƒμ„±λœ λΉ„λ””μ˜€ 파일 경둜 λ°˜ν™˜
31
  return output_video_path
32
 
33
+ return image_paths # μ˜ˆμ‹œ λ°˜ν™˜κ°’, μ‹€μ œλ‘œλŠ” μƒμ„±λœ λΉ„λ””μ˜€ 파일 경둜λ₯Ό λ°˜ν™˜ν•΄μ•Ό 함
34
+
35
  # Gradio μΈν„°νŽ˜μ΄μŠ€ μ •μ˜
36
  with gr.Blocks() as demo:
37
  with gr.Row():