donghuna commited on
Commit
3a6db82
·
verified ·
1 Parent(s): e4249e7

Update preprocessing.py

Browse files
Files changed (1) hide show
  1. preprocessing.py +14 -10
preprocessing.py CHANGED
@@ -14,6 +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
 
18
  # FTP 연결 설정
19
  ftp = FTP()
@@ -21,22 +22,25 @@ def get_video_file(file_path, ftp_password):
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):
35
- frames.append(frame.to_ndarray(format="rgb24").astype(np.uint8))
36
 
37
- sampled_frames = sample_frames(frames, num_frames)
38
- processed_frames = preprocess_frames(sampled_frames, target_size)
39
- return processed_frames
40
 
41
  def sample_frames(frames, num_frames):
42
  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()
 
22
  ftp.login(user=ftp_user, passwd=ftp_password)
23
  ftp.set_pasv(True)
24
 
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)