Spaces:
Sleeping
Sleeping
Update image_gen.py
Browse files- image_gen.py +2 -2
image_gen.py
CHANGED
|
@@ -51,7 +51,7 @@ def configure_gemini(api_key):
|
|
| 51 |
raise
|
| 52 |
|
| 53 |
# Initialize Gemini model for story generation
|
| 54 |
-
|
| 55 |
|
| 56 |
def is_valid_png(file_path):
|
| 57 |
"""Check if the PNG file at `file_path` is valid."""
|
|
@@ -187,7 +187,7 @@ def generate_image(prompt_text, style, model="hf"):
|
|
| 187 |
headers_pexels = {
|
| 188 |
"Authorization": pexels_api_key
|
| 189 |
}
|
| 190 |
-
new_prompt =
|
| 191 |
pexel_prompt = str(new_prompt.text)
|
| 192 |
params = {
|
| 193 |
"query": pexel_prompt,
|
|
|
|
| 51 |
raise
|
| 52 |
|
| 53 |
# Initialize Gemini model for story generation
|
| 54 |
+
model_g = configure_gemini(GOOGLE_API_KEY)
|
| 55 |
|
| 56 |
def is_valid_png(file_path):
|
| 57 |
"""Check if the PNG file at `file_path` is valid."""
|
|
|
|
| 187 |
headers_pexels = {
|
| 188 |
"Authorization": pexels_api_key
|
| 189 |
}
|
| 190 |
+
new_prompt = model_g.generate_content(f"Generate keywords or a phrase to search for an appropriate image on the pexels API based on this prompt: {prompt_text}")
|
| 191 |
pexel_prompt = str(new_prompt.text)
|
| 192 |
params = {
|
| 193 |
"query": pexel_prompt,
|