seawolf2357 commited on
Commit
5d3bf28
β€’
1 Parent(s): 80d6daf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -7,14 +7,20 @@ def images_to_video(image_files):
7
  # μž„μ‹œ 디렉터리 생성
8
  temp_dir = tempfile.mkdtemp()
9
 
10
- # 이미지 νŒŒμΌμ„ μž„μ‹œ λ””λ ‰ν„°λ¦¬λ‘œ μ €μž₯
11
  image_paths = []
12
  for i, image_file in enumerate(image_files):
 
 
 
 
 
13
  image_path = os.path.join(temp_dir, f"image_{i}.png")
14
- with open(image_path, "wb") as f:
15
- f.write(image_file)
16
  image_paths.append(image_path)
17
 
 
 
18
  # 이미지 μ‹œν€€μŠ€λ‘œλΆ€ν„° λΉ„λ””μ˜€ 클립 생성 (각 μ΄λ―Έμ§€μ˜ 지속 μ‹œκ°„μ€ 2초)
19
  clip = ImageSequenceClip(image_paths, fps=0.5) # fps=0.5 => 각 μ΄λ―Έμ§€λŠ” 2초 λ™μ•ˆ λ³΄μž„
20
 
 
7
  # μž„μ‹œ 디렉터리 생성
8
  temp_dir = tempfile.mkdtemp()
9
 
 
10
  image_paths = []
11
  for i, image_file in enumerate(image_files):
12
+ # μ—…λ‘œλ“œλœ 파일이 λ°”μ΄νŠΈ ν˜•νƒœμΈμ§€ ν™•μΈν•˜κ³ , 그렇지 μ•Šλ‹€λ©΄ λ³€ν™˜
13
+ if not isinstance(image_file, bytes):
14
+ # 파일 λ‚΄μš©μ„ λ°”μ΄νŠΈλ‘œ λ³€ν™˜ (이 뢀뢄은 μ—…λ‘œλ“œλœ 파일 ν˜•νƒœμ— 따라 λ‹¬λΌμ§ˆ 수 있음)
15
+ image_file = image_file.read() # Gradioμ—μ„œ μ—…λ‘œλ“œλœ 파일 처리 μ‹œ μ‚¬μš©
16
+
17
  image_path = os.path.join(temp_dir, f"image_{i}.png")
18
+ with open(image_path, "wb") as f: # λ°”μ΄λ„ˆλ¦¬ λͺ¨λ“œλ‘œ 파일 μ—΄κΈ°
19
+ f.write(image_file) # 이미지 파일 λ‚΄μš©μ„ λ””μŠ€ν¬μ— μ“°κΈ°
20
  image_paths.append(image_path)
21
 
22
+ # 이미지 μ‹œν€€μŠ€λ‘œλΆ€ν„° λΉ„λ””μ˜€ 클립 생성 및 기타 둜직...
23
+
24
  # 이미지 μ‹œν€€μŠ€λ‘œλΆ€ν„° λΉ„λ””μ˜€ 클립 생성 (각 μ΄λ―Έμ§€μ˜ 지속 μ‹œκ°„μ€ 2초)
25
  clip = ImageSequenceClip(image_paths, fps=0.5) # fps=0.5 => 각 μ΄λ―Έμ§€λŠ” 2초 λ™μ•ˆ λ³΄μž„
26