supersolar commited on
Commit
73b7b49
·
verified ·
1 Parent(s): a1be244

Update all_in_one.py

Browse files
Files changed (1) hide show
  1. all_in_one.py +9 -8
all_in_one.py CHANGED
@@ -7,19 +7,20 @@ import re
7
  import pickle
8
  from moviepy.editor import VideoFileClip, ImageSequenceClip
9
  import subprocess
10
-
 
11
  def set_prompt_and_get_coordinates(output_video, texts=['men', 'the table']):
12
  if isinstance(texts, str):
13
  texts = texts.split(',') # Assuming prompts are separated by commas
14
  texts = [text.strip() for text in texts]
15
  print(texts)
16
  # 保存提示词到文件
17
- with open('/workspace/florence-sam/texts.pkl', 'wb') as file:
18
  pickle.dump(texts, file)
19
- with open('/workspace/florence-sam/output_video.pkl', 'wb') as file:
20
  pickle.dump(output_video, file)
21
  # 构建命令
22
- command = ['python', '/workspace/florence-sam/1.py']
23
 
24
  # 执行命令并捕获输出
25
  all_ok_bboxes = subprocess.run(command, capture_output=True, text=True)
@@ -38,7 +39,7 @@ print(result.stdout)
38
  def run_sam2(output_video):
39
 
40
  # 定义脚本路径
41
- script_path = '/workspace/florence-sam/2.py'
42
 
43
  # 构建命令
44
  command = ['python3', script_path]
@@ -93,7 +94,7 @@ def create_video_with_audio(image_folder, input_video_path):
93
 
94
  # 生成与输入视频同名的输出文件
95
  #output_video_path = os.path.join('/tmp/gradio/', os.path.basename(input_video_path))
96
- output_video_path = os.path.join('/workspace/florence-sam/sam2_videos/', os.path.basename(input_video_path))
97
  # 确保输出目录存在
98
  os.makedirs(os.path.dirname(output_video_path), exist_ok=True)
99
 
@@ -104,8 +105,8 @@ def create_video_with_audio(image_folder, input_video_path):
104
  return output_video_path
105
 
106
  # 示例调用
107
- image_folder = '/workspace/florence-sam/output'
108
- with open('/workspace/florence-sam/output_video.pkl', 'rb') as file:
109
  output_video = pickle.load(file)
110
  print(output_video)
111
  input_video_path = output_video
 
7
  import pickle
8
  from moviepy.editor import VideoFileClip, ImageSequenceClip
9
  import subprocess
10
+ out_dir = "/workspace/tem"
11
+ os.makedirs(out_dir, exist_ok=True)
12
  def set_prompt_and_get_coordinates(output_video, texts=['men', 'the table']):
13
  if isinstance(texts, str):
14
  texts = texts.split(',') # Assuming prompts are separated by commas
15
  texts = [text.strip() for text in texts]
16
  print(texts)
17
  # 保存提示词到文件
18
+ with open('/workspace/tem/texts.pkl', 'wb') as file:
19
  pickle.dump(texts, file)
20
+ with open('/workspace/tem/output_video.pkl', 'wb') as file:
21
  pickle.dump(output_video, file)
22
  # 构建命令
23
+ command = ['python', '/workspace/florence-sam-tencent/1.py']
24
 
25
  # 执行命令并捕获输出
26
  all_ok_bboxes = subprocess.run(command, capture_output=True, text=True)
 
39
  def run_sam2(output_video):
40
 
41
  # 定义脚本路径
42
+ script_path = '/workspace/florence-sam-tencent/2.py'
43
 
44
  # 构建命令
45
  command = ['python3', script_path]
 
94
 
95
  # 生成与输入视频同名的输出文件
96
  #output_video_path = os.path.join('/tmp/gradio/', os.path.basename(input_video_path))
97
+ output_video_path = os.path.join('/workspace/tem/sam2_videos/', os.path.basename(input_video_path))
98
  # 确保输出目录存在
99
  os.makedirs(os.path.dirname(output_video_path), exist_ok=True)
100
 
 
105
  return output_video_path
106
 
107
  # 示例调用
108
+ image_folder = '/workspace/tem/output'
109
+ with open('/workspace/tem/output_video.pkl', 'rb') as file:
110
  output_video = pickle.load(file)
111
  print(output_video)
112
  input_video_path = output_video