supersolar commited on
Commit
ff3bcb6
1 Parent(s): e93626d

Update 1.py

Browse files
Files changed (1) hide show
  1. 1.py +7 -7
1.py CHANGED
@@ -13,15 +13,15 @@ def set_prompt_and_get_coordinates(output_video, texts=['men', 'the table']):
13
  print(texts)
14
  with open('/kaggle/texts.pkl', 'wb') as file:
15
  pickle.dump(texts, file)
16
- with open('/kaggle/output_video2.pkl', 'wb') as file:
17
  pickle.dump(output_video, file)
18
- command = ['python', '/kaggle/florence-sam-kaggle/kaggle_florence_gpu_2.py']
19
  all_ok_bboxes = subprocess.run(command, capture_output=True, text=True)
20
  return all_ok_bboxes
21
 
22
  # 运行 sam2 处理
23
  def run_sam2(output_video):
24
- script_path = '/kaggle/florence-sam-kaggle/kaggle_sam2_gpu_2.py'
25
  command = ['python3', script_path]
26
  sam2_output = subprocess.run(command, capture_output=True, text=True)
27
  print(sam2_output)
@@ -53,7 +53,7 @@ def create_video_with_audio(image_folder, input_video_path):
53
  os.makedirs(os.path.dirname(output_video_path), exist_ok=True)
54
 
55
  fourcc = cv2.VideoWriter_fourcc(*'mp4v')
56
- video_writer = cv2.VideoWriter('/kaggle/image_sequence_video2.mp4', fourcc, fps, (width, height))
57
 
58
  for image_file in image_files:
59
  image_path = os.path.join(image_folder, image_file)
@@ -62,7 +62,7 @@ def create_video_with_audio(image_folder, input_video_path):
62
 
63
  video_writer.release()
64
 
65
- temp_video_path = '/kaggle/image_sequence_video2.mp4'
66
  command = [
67
  'ffmpeg',
68
  '-y', # 覆盖输出文件
@@ -98,7 +98,7 @@ def process_all_videos(source_dir, target_dir, image_folder):
98
  video_files = [f for f in os.listdir(source_dir) if f.endswith(('.mp4', '.avi', '.mov'))]
99
  video_files.sort(key=natural_sort_key)
100
  # 反转列表
101
- video_files.reverse()
102
  print(video_files)
103
  for video_file in video_files:
104
  video_path = os.path.join(source_dir, video_file)
@@ -124,6 +124,6 @@ def process_all_videos(source_dir, target_dir, image_folder):
124
  # 示例调用
125
  source_dir = '/kaggle/o_videos'
126
  target_dir = '/kaggle'
127
- image_folder = '/kaggle/output2'
128
 
129
  process_all_videos(source_dir, target_dir, image_folder)
 
13
  print(texts)
14
  with open('/kaggle/texts.pkl', 'wb') as file:
15
  pickle.dump(texts, file)
16
+ with open('/kaggle/output_video1.pkl', 'wb') as file:
17
  pickle.dump(output_video, file)
18
+ command = ['python', '/kaggle/florence-sam-kaggle/kaggle_florence_gpu_1.py']
19
  all_ok_bboxes = subprocess.run(command, capture_output=True, text=True)
20
  return all_ok_bboxes
21
 
22
  # 运行 sam2 处理
23
  def run_sam2(output_video):
24
+ script_path = '/kaggle/florence-sam-kaggle/kaggle_sam2_gpu_1.py'
25
  command = ['python3', script_path]
26
  sam2_output = subprocess.run(command, capture_output=True, text=True)
27
  print(sam2_output)
 
53
  os.makedirs(os.path.dirname(output_video_path), exist_ok=True)
54
 
55
  fourcc = cv2.VideoWriter_fourcc(*'mp4v')
56
+ video_writer = cv2.VideoWriter('/kaggle/image_sequence_video1.mp4', fourcc, fps, (width, height))
57
 
58
  for image_file in image_files:
59
  image_path = os.path.join(image_folder, image_file)
 
62
 
63
  video_writer.release()
64
 
65
+ temp_video_path = '/kaggle/image_sequence_video1.mp4'
66
  command = [
67
  'ffmpeg',
68
  '-y', # 覆盖输出文件
 
98
  video_files = [f for f in os.listdir(source_dir) if f.endswith(('.mp4', '.avi', '.mov'))]
99
  video_files.sort(key=natural_sort_key)
100
  # 反转列表
101
+ #video_files.reverse()
102
  print(video_files)
103
  for video_file in video_files:
104
  video_path = os.path.join(source_dir, video_file)
 
124
  # 示例调用
125
  source_dir = '/kaggle/o_videos'
126
  target_dir = '/kaggle'
127
+ image_folder = '/kaggle/output1'
128
 
129
  process_all_videos(source_dir, target_dir, image_folder)