main
Backend Deploy 🚀 / build-and-deploy (push) Has been cancelled

This commit is contained in:
Harun CAN
2026-04-27 12:50:42 +02:00
parent 9d8c34b39d
commit 7745102584
11 changed files with 3909 additions and 23 deletions
+33
View File
@@ -0,0 +1,33 @@
require('dotenv').config();
const { GoogleGenAI } = require('@google/genai');
const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });
async function main() {
const originalPrompt = "A medium close-up shot of Elon Musk (in his late 40s to early 50s, looking thoughtful with a slight smirk, wearing a plaid dress shirt) across a polished dark wood restaurant table, looking directly at the camera.";
const rewriteInstruction = `Rewrite the following image generation prompt. Remove the names of any real-world public figures (like Elon Musk, politicians, celebrities) and replace their names with extremely detailed physical descriptions of their facial features, body type, age, and hair, so the generated image will still look exactly like them. Keep the rest of the prompt intact. Only return the rewritten prompt. \n\nPrompt: ${originalPrompt}`;
console.log("Rewriting prompt...");
const response = await ai.models.generateContent({
model: 'gemini-2.5-flash',
contents: rewriteInstruction,
});
const rewritten = response.text;
console.log("Rewritten:", rewritten);
console.log("Generating image with rewritten prompt...");
try {
const imgRes = await ai.models.generateImages({
model: 'imagen-3.0-generate-002',
prompt: `A highly detailed, premium digital illustration: ${rewritten}`,
config: { numberOfImages: 1, aspectRatio: '16:9' }
});
console.log("Image generated! Bytes:", imgRes.generatedImages[0].image.imageBytes.length);
} catch (err) {
console.error("Image generation failed:", err.message);
}
}
main().catch(console.error);