Update main.py
Browse files
main.py
CHANGED
@@ -21,9 +21,6 @@ import requests
|
|
21 |
import tempfile
|
22 |
from datetime import datetime
|
23 |
|
24 |
-
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
25 |
-
from transformers import pipeline
|
26 |
-
|
27 |
|
28 |
# ่จญๅฎ Google AI API ้้ฐ
|
29 |
genai_gen.configure(api_key=os.environ["GOOGLE_API_KEY"])
|
@@ -115,18 +112,18 @@ def generate_image_with_gemini(prompt):
|
|
115 |
model="gemini-2.0-flash-exp-image-generation",
|
116 |
contents=prompt,
|
117 |
config=types.GenerateContentConfig(
|
118 |
-
response_modalities=['Text', 'Image']
|
119 |
)
|
120 |
-
)
|
121 |
|
122 |
for part in response.candidates[0].content.parts:
|
123 |
if part.text is not None:
|
124 |
print(part.text)
|
125 |
elif part.inline_data is not None:
|
126 |
-
|
127 |
-
|
128 |
|
129 |
|
|
|
130 |
# ไฝฟ็จ Hugging Face ็ๆๅ็
|
131 |
def generate_image_hf(prompt):
|
132 |
API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-2"
|
@@ -137,7 +134,7 @@ def generate_image_hf(prompt):
|
|
137 |
else:
|
138 |
print("ๅ็็ๆๅคฑๆ:", response.text)
|
139 |
return None
|
140 |
-
|
141 |
#==========================
|
142 |
# ไฝฟ็จ่
ไธๅณๅ็
|
143 |
#==========================
|
|
|
21 |
import tempfile
|
22 |
from datetime import datetime
|
23 |
|
|
|
|
|
|
|
24 |
|
25 |
# ่จญๅฎ Google AI API ้้ฐ
|
26 |
genai_gen.configure(api_key=os.environ["GOOGLE_API_KEY"])
|
|
|
112 |
model="gemini-2.0-flash-exp-image-generation",
|
113 |
contents=prompt,
|
114 |
config=types.GenerateContentConfig(
|
115 |
+
response_modalities=['Text', 'Image'])
|
116 |
)
|
|
|
117 |
|
118 |
for part in response.candidates[0].content.parts:
|
119 |
if part.text is not None:
|
120 |
print(part.text)
|
121 |
elif part.inline_data is not None:
|
122 |
+
#image = PIL.Image.open(io.BytesIO(part.inline_data.data))
|
123 |
+
return part.inline_data.data
|
124 |
|
125 |
|
126 |
+
''''
|
127 |
# ไฝฟ็จ Hugging Face ็ๆๅ็
|
128 |
def generate_image_hf(prompt):
|
129 |
API_URL = "https://api-inference.huggingface.co/models/stabilityai/stable-diffusion-2"
|
|
|
134 |
else:
|
135 |
print("ๅ็็ๆๅคฑๆ:", response.text)
|
136 |
return None
|
137 |
+
''''
|
138 |
#==========================
|
139 |
# ไฝฟ็จ่
ไธๅณๅ็
|
140 |
#==========================
|