Spaces:
Runtime error
Runtime error
Update run.py
Browse files
run.py
CHANGED
@@ -33,6 +33,8 @@ def fast_caption(sys_prompt, usr_prompt, temp, top_p, max_tokens, model, key, en
|
|
33 |
caption = api.get_caption(sys_prompt, usr_prompt, base64_list)
|
34 |
return f"{caption}", f"Using model '{model}' with {len(frames)} frames extracted.", debug_image
|
35 |
elif video_hf and video_hf_auth:
|
|
|
|
|
36 |
print('begin video_hf')
|
37 |
# Process all videos in the dataset
|
38 |
all_captions = []
|
@@ -51,15 +53,16 @@ def fast_caption(sys_prompt, usr_prompt, temp, top_p, max_tokens, model, key, en
|
|
51 |
|
52 |
md5 = hashlib.md5(video).hexdigest()
|
53 |
print(md5)
|
54 |
-
with
|
55 |
-
|
|
|
56 |
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
|
64 |
return "\n\n\n".join(all_captions), f"Processed {len(video_paths)} videos.", None
|
65 |
|
|
|
33 |
caption = api.get_caption(sys_prompt, usr_prompt, base64_list)
|
34 |
return f"{caption}", f"Using model '{model}' with {len(frames)} frames extracted.", debug_image
|
35 |
elif video_hf and video_hf_auth:
|
36 |
+
current_file_path = os.path.abspath(__file__)
|
37 |
+
current_directory = os.path.dirname(current_file_path)
|
38 |
print('begin video_hf')
|
39 |
# Process all videos in the dataset
|
40 |
all_captions = []
|
|
|
53 |
|
54 |
md5 = hashlib.md5(video).hexdigest()
|
55 |
print(md5)
|
56 |
+
with tempfile.NamedTemporaryFile(dir=current_directory) as temp_file:
|
57 |
+
temp_file.write(video)
|
58 |
+
video_path = temp_file.name
|
59 |
|
60 |
+
processor = VideoProcessor(frame_format=frame_format, frame_limit=frame_limit)
|
61 |
+
frames = processor._decode(video_path)
|
62 |
+
base64_list = processor.to_base64_list(frames)
|
63 |
+
api = AzureAPI(key=key, endpoint=endpoint, model=model, temp=temp, top_p=top_p, max_tokens=max_tokens)
|
64 |
+
caption = api.get_caption(sys_prompt, usr_prompt, base64_list)
|
65 |
+
all_captions.append(caption)
|
66 |
|
67 |
return "\n\n\n".join(all_captions), f"Processed {len(video_paths)} videos.", None
|
68 |
|