donghuna commited on
Commit
6255548
·
verified ·
1 Parent(s): 415dae8

Update preprocessing.py

Browse files
Files changed (1) hide show
  1. preprocessing.py +12 -12
preprocessing.py CHANGED
@@ -14,7 +14,7 @@ def get_video_file(file_path, ftp_password):
14
  ftp_port = 21
15
  ftp_user = "donghuna_ftp"
16
  # folder_path = "homes/donghuna/database/Diving48_rgb/rgb/"
17
- folder_path = "web/donghuna.com/inference-endpoints/dive-sequence-classification/"
18
 
19
  # FTP 연결 설정
20
  ftp = FTP()
@@ -25,22 +25,22 @@ def get_video_file(file_path, ftp_password):
25
  local_path = "test.mp4"
26
 
27
  with open(local_path, 'wb') as local_file:
28
- ftp.retrbinary(f'RETR {folder_path}{file_path}', local_file.write)
29
 
30
 
31
- def read_video(file_path, num_frames=24, target_size=(224, 224)):
32
  get_video_file(file_path, ftp_password)
33
 
 
 
 
 
 
 
34
 
35
- # logging.info(f"Reading video from: {file_path}")
36
- # container = av.open(file_path)
37
- # frames = []
38
- # for frame in container.decode(video=0):
39
- # frames.append(frame.to_ndarray(format="rgb24").astype(np.uint8))
40
-
41
- # sampled_frames = sample_frames(frames, num_frames)
42
- # processed_frames = preprocess_frames(sampled_frames, target_size)
43
- # return processed_frames
44
 
45
  def sample_frames(frames, num_frames):
46
  total_frames = len(frames)
 
14
  ftp_port = 21
15
  ftp_user = "donghuna_ftp"
16
  # folder_path = "homes/donghuna/database/Diving48_rgb/rgb/"
17
+ # folder_path = "web/donghuna.com/inference-endpoints/dive-sequence-classification/"
18
 
19
  # FTP 연결 설정
20
  ftp = FTP()
 
25
  local_path = "test.mp4"
26
 
27
  with open(local_path, 'wb') as local_file:
28
+ ftp.retrbinary(f'RETR {file_path}', local_file.write)
29
 
30
 
31
+ def read_video(file_path, ftp_password, num_frames=24, target_size=(224, 224)):
32
  get_video_file(file_path, ftp_password)
33
 
34
+ local_path = "test.mp4"
35
+ logging.info(f"Reading video from: {local_path}")
36
+ container = av.open(local_path)
37
+ frames = []
38
+ for frame in container.decode(video=0):
39
+ frames.append(frame.to_ndarray(format="rgb24").astype(np.uint8))
40
 
41
+ sampled_frames = sample_frames(frames, num_frames)
42
+ processed_frames = preprocess_frames(sampled_frames, target_size)
43
+ return processed_frames
 
 
 
 
 
 
44
 
45
  def sample_frames(frames, num_frames):
46
  total_frames = len(frames)