Files
homeracker/png_creation/create_png.py
2025-09-15 22:49:48 +02:00

26 lines
768 B
Python

import google.generativeai as genai
import os
# Configure with your API key
genai.configure(api_key="YOUR_API_KEY")
# The prompt from our refined prompt file
prompt_text = """
Analyze the attached image and generate a PNG file...
[...your full prompt text here...]
"""
# Load the image and prompt
model = genai.GenerativeModel('gemini-1.5-pro')
source_image = genai.upload_file(path="PXL_20250915_172025980.jpg")
# Make the API call
response = model.generate_content([prompt_text, source_image])
# Save the generated image data from the response
# (The exact syntax for saving the file may vary based on API response structure)
with open("output_silhouette.png", "wb") as f:
f.write(response.parts[0].blob.data)
print("Silhouette PNG created successfully!")