Update main.py
Browse files
main.py
CHANGED
@@ -99,8 +99,8 @@ def analyze_with_gemini(image_path, user_text):
|
|
99 |
raise FileNotFoundError(f"圖片路徑無效:{image_path}")
|
100 |
|
101 |
# 打開本地圖片文件並將其轉換為 Base64 編碼
|
102 |
-
|
103 |
-
|
104 |
|
105 |
# 將二進制數據編碼為 Base64
|
106 |
image_base64 = base64.b64encode(image_binary).decode('utf-8')
|
|
|
99 |
raise FileNotFoundError(f"圖片路徑無效:{image_path}")
|
100 |
|
101 |
# 打開本地圖片文件並將其轉換為 Base64 編碼
|
102 |
+
with open(image_path, "rb") as image_file:
|
103 |
+
image_binary = image_file.read()
|
104 |
|
105 |
# 將二進制數據編碼為 Base64
|
106 |
image_base64 = base64.b64encode(image_binary).decode('utf-8')
|