Spaces:
Paused
Paused
Update util.py
Browse files
util.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import base64, cv2
|
| 2 |
import pandas as pd
|
| 3 |
from openai import OpenAI
|
| 4 |
|
|
@@ -12,27 +12,27 @@ def get_questions(file_path):
|
|
| 12 |
|
| 13 |
return result
|
| 14 |
|
| 15 |
-
def get_img_b64(file_path):
|
| 16 |
-
with open(file_path, "rb") as file:
|
| 17 |
-
return base64.b64encode(file.read()).decode("utf-8")
|
| 18 |
|
| 19 |
-
def get_imgs_b64(file_path):
|
| 20 |
-
video = cv2.VideoCapture(file_path)
|
| 21 |
|
| 22 |
-
result = []
|
| 23 |
|
| 24 |
-
while video.isOpened():
|
| 25 |
-
success, frame = video.read()
|
| 26 |
|
| 27 |
-
if not success:
|
| 28 |
-
break
|
| 29 |
|
| 30 |
-
_, buffer = cv2.imencode(".png", frame)
|
| 31 |
-
result.append(base64.b64encode(buffer).decode("utf-8"))
|
| 32 |
|
| 33 |
-
video.release()
|
| 34 |
|
| 35 |
-
return result
|
| 36 |
|
| 37 |
def get_final_answer(model, question, answer):
|
| 38 |
prompt_template = """
|
|
|
|
| 1 |
+
#import base64, cv2
|
| 2 |
import pandas as pd
|
| 3 |
from openai import OpenAI
|
| 4 |
|
|
|
|
| 12 |
|
| 13 |
return result
|
| 14 |
|
| 15 |
+
#def get_img_b64(file_path):
|
| 16 |
+
# with open(file_path, "rb") as file:
|
| 17 |
+
# return base64.b64encode(file.read()).decode("utf-8")
|
| 18 |
|
| 19 |
+
#def get_imgs_b64(file_path):
|
| 20 |
+
# video = cv2.VideoCapture(file_path)
|
| 21 |
|
| 22 |
+
# result = []
|
| 23 |
|
| 24 |
+
# while video.isOpened():
|
| 25 |
+
# success, frame = video.read()
|
| 26 |
|
| 27 |
+
# if not success:
|
| 28 |
+
# break
|
| 29 |
|
| 30 |
+
# _, buffer = cv2.imencode(".png", frame)
|
| 31 |
+
# result.append(base64.b64encode(buffer).decode("utf-8"))
|
| 32 |
|
| 33 |
+
# video.release()
|
| 34 |
|
| 35 |
+
# return result
|
| 36 |
|
| 37 |
def get_final_answer(model, question, answer):
|
| 38 |
prompt_template = """
|