Spaces:
Sleeping
Sleeping
Update run.py
Browse files
run.py
CHANGED
@@ -28,6 +28,7 @@ def fast_caption(sys_prompt, usr_prompt, temp, top_p, max_tokens, model, key, en
|
|
28 |
progress_info = []
|
29 |
processor = VideoProcessor(frame_format=frame_format, frame_limit=frame_limit)
|
30 |
api = AzureAPI(key=key, endpoint=endpoint, model=model, temp=temp, top_p=top_p, max_tokens=max_tokens)
|
|
|
31 |
with tempfile.TemporaryDirectory() as temp_dir:
|
32 |
# temp_dir = '/opt/run'
|
33 |
csv_filename = os.path.join('/dev/shm', str(parquet_index).zfill(6) + '_gpt4o_caption.csv')
|
@@ -54,6 +55,7 @@ def fast_caption(sys_prompt, usr_prompt, temp, top_p, max_tokens, model, key, en
|
|
54 |
_chunk = []
|
55 |
df = batch.to_pandas()
|
56 |
for binary in df["video"]:
|
|
|
57 |
if(binary):
|
58 |
_v = tempfile.NamedTemporaryFile(suffix=".mp4", delete=False)
|
59 |
with open(_v.name, "wb") as f:
|
@@ -67,7 +69,8 @@ def fast_caption(sys_prompt, usr_prompt, temp, top_p, max_tokens, model, key, en
|
|
67 |
writer.writerow({'md5': md5, 'caption': caption})
|
68 |
# writer.writerow({'md5': md5, 'caption': 'caption'})
|
69 |
progress_info.append(f"Processed video with MD5: {md5}")
|
70 |
-
|
|
|
71 |
return csv_filename, "\n".join(progress_info), None
|
72 |
else:
|
73 |
return "", "No video source selected.", None
|
|
|
28 |
progress_info = []
|
29 |
processor = VideoProcessor(frame_format=frame_format, frame_limit=frame_limit)
|
30 |
api = AzureAPI(key=key, endpoint=endpoint, model=model, temp=temp, top_p=top_p, max_tokens=max_tokens)
|
31 |
+
ind = 0
|
32 |
with tempfile.TemporaryDirectory() as temp_dir:
|
33 |
# temp_dir = '/opt/run'
|
34 |
csv_filename = os.path.join('/dev/shm', str(parquet_index).zfill(6) + '_gpt4o_caption.csv')
|
|
|
55 |
_chunk = []
|
56 |
df = batch.to_pandas()
|
57 |
for binary in df["video"]:
|
58 |
+
ind += 1
|
59 |
if(binary):
|
60 |
_v = tempfile.NamedTemporaryFile(suffix=".mp4", delete=False)
|
61 |
with open(_v.name, "wb") as f:
|
|
|
69 |
writer.writerow({'md5': md5, 'caption': caption})
|
70 |
# writer.writerow({'md5': md5, 'caption': 'caption'})
|
71 |
progress_info.append(f"Processed video with MD5: {md5}")
|
72 |
+
if ind == 2:
|
73 |
+
return csv_filename, "\n".join(progress_info), None
|
74 |
return csv_filename, "\n".join(progress_info), None
|
75 |
else:
|
76 |
return "", "No video source selected.", None
|