donghuna commited on
Commit
fd22feb
·
verified ·
1 Parent(s): 8b2bb9b

Update preprocessing.py

Browse files
Files changed (1) hide show
  1. preprocessing.py +22 -2
preprocessing.py CHANGED
@@ -3,11 +3,32 @@ import torch
3
  from torchvision import transforms
4
  import av
5
  import logging
 
 
6
 
7
  logging.basicConfig(filename='/mnt/data/uploads/logfile-video.log', level=logging.INFO)
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  def read_video(file_path, num_frames=24, target_size=(224, 224)):
10
- logging.info(f"Reading video from: {file_path}")
11
  container = av.open(file_path)
12
  frames = []
13
  for frame in container.decode(video=0):
@@ -19,7 +40,6 @@ def read_video(file_path, num_frames=24, target_size=(224, 224)):
19
 
20
  def sample_frames(frames, num_frames):
21
  total_frames = len(frames)
22
- logging.info(f"Total frames: {total_frames}")
23
  if total_frames <= num_frames:
24
  if total_frames < num_frames:
25
  padding = [np.zeros_like(frames[0]) for _ in range(num_frames - total_frames)]
 
3
  from torchvision import transforms
4
  import av
5
  import logging
6
+ from ftplib import FTP
7
+
8
 
9
  logging.basicConfig(filename='/mnt/data/uploads/logfile-video.log', level=logging.INFO)
10
 
11
+ def get_video_file(file_path, ftp_password):
12
+ # FTP 서버 정보
13
+ ftp_server = "121.136.96.223"
14
+ ftp_port = 21
15
+ ftp_user = "donghuna_ftp"
16
+ # folder_path = "homes/donghuna/database/Diving48_rgb/rgb/"
17
+
18
+ # FTP 연결 설정
19
+ ftp = FTP()
20
+ ftp.connect(ftp_server, ftp_port)
21
+ ftp.login(user=ftp_user, passwd=ftp_password)
22
+ ftp.set_pasv(True)
23
+
24
+ video_path = "test.mp4"
25
+
26
+ with open(video_path, 'wb') as local_file:
27
+ ftp.retrbinary(f'RETR {file_path}', local_file.write)
28
+
29
+
30
  def read_video(file_path, num_frames=24, target_size=(224, 224)):
31
+ # logging.info(f"Reading video from: {file_path}")
32
  container = av.open(file_path)
33
  frames = []
34
  for frame in container.decode(video=0):
 
40
 
41
  def sample_frames(frames, num_frames):
42
  total_frames = len(frames)
 
43
  if total_frames <= num_frames:
44
  if total_frames < num_frames:
45
  padding = [np.zeros_like(frames[0]) for _ in range(num_frames - total_frames)]