Spaces:
Running
Running
re deploy
Browse files- text2image.py +2 -3
text2image.py
CHANGED
@@ -13,13 +13,12 @@ logging.basicConfig(
|
|
13 |
|
14 |
# 初始化 Gemini API
|
15 |
GEMINI_API_KEY = os.environ.get("GEMINI_API_KEY")
|
16 |
-
genai.
|
17 |
-
google_client = genai.GenerativeModel(model_name="gemini-2.0-flash")
|
18 |
|
19 |
# 定義「圖解釋文」功能
|
20 |
def explain_image(image: Image.Image):
|
21 |
# 直接把 PIL image 傳進去
|
22 |
-
response =
|
23 |
contents=[image, "請用繁體中文描述這張圖片"]
|
24 |
)
|
25 |
# 取出回答
|
|
|
13 |
|
14 |
# 初始化 Gemini API
|
15 |
GEMINI_API_KEY = os.environ.get("GEMINI_API_KEY")
|
16 |
+
client = genai.Client(api_key=GEMINI_API_KEY)
|
|
|
17 |
|
18 |
# 定義「圖解釋文」功能
|
19 |
def explain_image(image: Image.Image):
|
20 |
# 直接把 PIL image 傳進去
|
21 |
+
response = client.generate_content(
|
22 |
contents=[image, "請用繁體中文描述這張圖片"]
|
23 |
)
|
24 |
# 取出回答
|