GavinKing
commited on
Add 2 files
Browse files- README.md +7 -5
- index.html +408 -19
README.md
CHANGED
@@ -1,10 +1,12 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: static
|
7 |
pinned: false
|
|
|
|
|
8 |
---
|
9 |
|
10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
title: ai-image-prompt-optimizer
|
3 |
+
emoji: 🐳
|
4 |
+
colorFrom: red
|
5 |
+
colorTo: pink
|
6 |
sdk: static
|
7 |
pinned: false
|
8 |
+
tags:
|
9 |
+
- deepsite
|
10 |
---
|
11 |
|
12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
@@ -1,19 +1,408 @@
|
|
1 |
-
<!
|
2 |
-
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>AI Image Prompt Optimizer</title>
|
7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
9 |
+
<style>
|
10 |
+
.gradient-bg {
|
11 |
+
background: linear-gradient(135deg, #6e8efb 0%, #a777e3 100%);
|
12 |
+
}
|
13 |
+
.prompt-card {
|
14 |
+
transition: all 0.3s ease;
|
15 |
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
16 |
+
}
|
17 |
+
.prompt-card:hover {
|
18 |
+
transform: translateY(-5px);
|
19 |
+
box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
|
20 |
+
}
|
21 |
+
.keyword-chip {
|
22 |
+
transition: all 0.2s ease;
|
23 |
+
}
|
24 |
+
.keyword-chip:hover {
|
25 |
+
transform: scale(1.05);
|
26 |
+
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
|
27 |
+
}
|
28 |
+
.fade-in {
|
29 |
+
animation: fadeIn 0.5s ease-in-out;
|
30 |
+
}
|
31 |
+
@keyframes fadeIn {
|
32 |
+
from { opacity: 0; transform: translateY(10px); }
|
33 |
+
to { opacity: 1; transform: translateY(0); }
|
34 |
+
}
|
35 |
+
textarea {
|
36 |
+
min-height: 120px;
|
37 |
+
resize: none;
|
38 |
+
}
|
39 |
+
</style>
|
40 |
+
</head>
|
41 |
+
<body class="bg-gray-50 min-h-screen">
|
42 |
+
<div class="gradient-bg text-white py-12 px-4">
|
43 |
+
<div class="max-w-4xl mx-auto text-center">
|
44 |
+
<h1 class="text-4xl md:text-5xl font-bold mb-4">AI Image Prompt Optimizer</h1>
|
45 |
+
<p class="text-xl md:text-2xl mb-8">Transform your simple ideas into professional-grade AI image generation prompts</p>
|
46 |
+
<div class="bg-white bg-opacity-20 backdrop-blur-md rounded-xl p-6 shadow-lg">
|
47 |
+
<textarea id="promptInput" class="w-full p-4 rounded-lg text-gray-800 focus:outline-none focus:ring-2 focus:ring-purple-300" placeholder="Enter your initial prompt, e.g. 'a cute cat in a garden'"></textarea>
|
48 |
+
<div class="flex flex-wrap justify-center gap-4 mt-6">
|
49 |
+
<button id="optimizeBtn" class="bg-white text-purple-600 hover:bg-purple-50 px-6 py-3 rounded-full font-semibold flex items-center gap-2 transition-all">
|
50 |
+
<i class="fas fa-magic"></i> Optimize Prompt
|
51 |
+
</button>
|
52 |
+
<button id="clearBtn" class="bg-transparent border-2 border-white hover:bg-white hover:text-purple-600 px-6 py-3 rounded-full font-semibold flex items-center gap-2 transition-all">
|
53 |
+
<i class="fas fa-trash-alt"></i> Clear
|
54 |
+
</button>
|
55 |
+
</div>
|
56 |
+
</div>
|
57 |
+
</div>
|
58 |
+
</div>
|
59 |
+
|
60 |
+
<div class="max-w-6xl mx-auto px-4 py-12">
|
61 |
+
<div id="optimizedSection" class="hidden fade-in">
|
62 |
+
<div class="flex flex-col md:flex-row gap-8 mb-12">
|
63 |
+
<div class="md:w-1/2">
|
64 |
+
<h2 class="text-2xl font-bold mb-4 text-gray-800">Optimized Prompt</h2>
|
65 |
+
<div id="optimizedPrompt" class="bg-white p-6 rounded-xl shadow-md border-l-4 border-purple-500">
|
66 |
+
<!-- Optimized prompt will appear here -->
|
67 |
+
</div>
|
68 |
+
<div class="mt-4 flex gap-3">
|
69 |
+
<button id="copyBtn" class="bg-purple-600 hover:bg-purple-700 text-white px-4 py-2 rounded-lg flex items-center gap-2">
|
70 |
+
<i class="fas fa-copy"></i> Copy
|
71 |
+
</button>
|
72 |
+
<button id="regenerateBtn" class="bg-gray-200 hover:bg-gray-300 text-gray-800 px-4 py-2 rounded-lg flex items-center gap-2">
|
73 |
+
<i class="fas fa-sync-alt"></i> Regenerate
|
74 |
+
</button>
|
75 |
+
</div>
|
76 |
+
</div>
|
77 |
+
<div class="md:w-1/2">
|
78 |
+
<h2 class="text-2xl font-bold mb-4 text-gray-800">Optimization Suggestions</h2>
|
79 |
+
<div id="suggestions" class="bg-white p-6 rounded-xl shadow-md">
|
80 |
+
<!-- Suggestions will appear here -->
|
81 |
+
</div>
|
82 |
+
</div>
|
83 |
+
</div>
|
84 |
+
|
85 |
+
<div class="mb-12">
|
86 |
+
<h2 class="text-2xl font-bold mb-6 text-gray-800">Keyword Enhancements</h2>
|
87 |
+
<div class="bg-white p-6 rounded-xl shadow-md">
|
88 |
+
<div class="flex flex-wrap gap-3 mb-6" id="keywordChips">
|
89 |
+
<!-- Keyword chips will appear here -->
|
90 |
+
</div>
|
91 |
+
<div class="flex gap-3">
|
92 |
+
<button id="addAllKeywordsBtn" class="bg-purple-600 hover:bg-purple-700 text-white px-4 py-2 rounded-lg flex items-center gap-2">
|
93 |
+
<i class="fas fa-plus-circle"></i> Add All Keywords
|
94 |
+
</button>
|
95 |
+
<button id="refreshKeywordsBtn" class="bg-gray-200 hover:bg-gray-300 text-gray-800 px-4 py-2 rounded-lg flex items-center gap-2">
|
96 |
+
<i class="fas fa-random"></i> Refresh Keywords
|
97 |
+
</button>
|
98 |
+
</div>
|
99 |
+
</div>
|
100 |
+
</div>
|
101 |
+
|
102 |
+
<div>
|
103 |
+
<h2 class="text-2xl font-bold mb-6 text-gray-800">Example Showcase</h2>
|
104 |
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
105 |
+
<div class="prompt-card bg-white p-6 rounded-xl shadow-md hover:shadow-lg">
|
106 |
+
<h3 class="font-semibold text-lg text-purple-600 mb-3">Original Prompt</h3>
|
107 |
+
<p class="text-gray-600 mb-4">"a cat in a garden"</p>
|
108 |
+
<h3 class="font-semibold text-lg text-purple-600 mb-3">Optimized Prompt</h3>
|
109 |
+
<p class="text-gray-800">"A fluffy orange tabby cat sitting in a sunny English garden surrounded by vibrant tulips and roses, soft afternoon lighting, ultra HD 8K resolution, highly detailed, shallow depth of field"</p>
|
110 |
+
</div>
|
111 |
+
<div class="prompt-card bg-white p-6 rounded-xl shadow-md hover:shadow-lg">
|
112 |
+
<h3 class="font-semibold text-lg text-purple-600 mb-3">Original Prompt</h3>
|
113 |
+
<p class="text-gray-600 mb-4">"futuristic city"</p>
|
114 |
+
<h3 class="font-semibold text-lg text-purple-600 mb-3">Optimized Prompt</h3>
|
115 |
+
<p class="text-gray-800">"Cyberpunk-style futuristic metropolis, neon lights illuminating a rainy night, towering glass skyscrapers with holographic advertisements, flying cars zooming between buildings, streets filled with people wearing high-tech clothing, predominantly blue-purple color scheme, cinematic lighting effects, hyper-realistic details"</p>
|
116 |
+
</div>
|
117 |
+
</div>
|
118 |
+
</div>
|
119 |
+
</div>
|
120 |
+
|
121 |
+
<div id="tipsSection" class="mt-16 bg-white rounded-xl shadow-md p-8">
|
122 |
+
<h2 class="text-2xl font-bold mb-6 text-center text-gray-800">How to Write Better AI Image Generation Prompts</h2>
|
123 |
+
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
|
124 |
+
<div class="bg-purple-50 p-6 rounded-lg">
|
125 |
+
<div class="text-purple-600 text-3xl mb-4">
|
126 |
+
<i class="fas fa-layer-group"></i>
|
127 |
+
</div>
|
128 |
+
<h3 class="font-bold text-lg mb-2">Clear Structure</h3>
|
129 |
+
<p class="text-gray-700">Organize prompts with "subject + environment + style + details" structure. First describe the main subject, then the background, followed by artistic style, and finally technical details.</p>
|
130 |
+
</div>
|
131 |
+
<div class="bg-purple-50 p-6 rounded-lg">
|
132 |
+
<div class="text-purple-600 text-3xl mb-4">
|
133 |
+
<i class="fas fa-adjust"></i>
|
134 |
+
</div>
|
135 |
+
<h3 class="font-bold text-lg mb-2">Be Specific</h3>
|
136 |
+
<p class="text-gray-700">Avoid vague terms, use concrete descriptions. For example, use "a fluffy orange tabby cat" instead of "a cat", or "a sunny English garden" instead of "garden".</p>
|
137 |
+
</div>
|
138 |
+
<div class="bg-purple-50 p-6 rounded-lg">
|
139 |
+
<div class="text-purple-600 text-3xl mb-4">
|
140 |
+
<i class="fas fa-palette"></i>
|
141 |
+
</div>
|
142 |
+
<h3 class="font-bold text-lg mb-2">Style References</h3>
|
143 |
+
<p class="text-gray-700">Include artistic styles or photographer references like "cyberpunk style", "Ansel Adams-style photography" or "Studio Ghibli animation style".</p>
|
144 |
+
</div>
|
145 |
+
<div class="bg-purple-50 p-6 rounded-lg">
|
146 |
+
<div class="text-purple-600 text-3xl mb-4">
|
147 |
+
<i class="fas fa-lightbulb"></i>
|
148 |
+
</div>
|
149 |
+
<h3 class="font-bold text-lg mb-2">Lighting Descriptions</h3>
|
150 |
+
<p class="text-gray-700">Describing lighting conditions can dramatically change image mood. Examples: "soft afternoon light", "dramatic sidelighting" or "neon-lit rainy night".</p>
|
151 |
+
</div>
|
152 |
+
<div class="bg-purple-50 p-6 rounded-lg">
|
153 |
+
<div class="text-purple-600 text-3xl mb-4">
|
154 |
+
<i class="fas fa-camera"></i>
|
155 |
+
</div>
|
156 |
+
<h3 class="font-bold text-lg mb-2">Technical Details</h3>
|
157 |
+
<p class="text-gray-700">Include technical terms like "8K ultra HD", "shallow depth of field", "film grain" or "cinematic lighting" to enhance image quality.</p>
|
158 |
+
</div>
|
159 |
+
<div class="bg-purple-50 p-6 rounded-lg">
|
160 |
+
<div class="text-purple-600 text-3xl mb-4">
|
161 |
+
<i class="fas fa-balance-scale"></i>
|
162 |
+
</div>
|
163 |
+
<h3 class="font-bold text-lg mb-2">Balance Creativity</h3>
|
164 |
+
<p class="text-gray-700">Strike a balance between specific guidance and creative freedom. Provide enough direction without overly restricting the AI's creativity.</p>
|
165 |
+
</div>
|
166 |
+
</div>
|
167 |
+
</div>
|
168 |
+
</div>
|
169 |
+
|
170 |
+
<footer class="bg-gray-800 text-white py-8">
|
171 |
+
<div class="max-w-6xl mx-auto px-4 text-center">
|
172 |
+
<p>AI Image Prompt Optimizer © 2023 - Helping you create better AI-generated images</p>
|
173 |
+
<div class="flex justify-center gap-4 mt-4">
|
174 |
+
<a href="#" class="hover:text-purple-300 transition-colors"><i class="fab fa-twitter"></i></a>
|
175 |
+
<a href="#" class="hover:text-purple-300 transition-colors"><i class="fab fa-github"></i></a>
|
176 |
+
<a href="#" class="hover:text-purple-300 transition-colors"><i class="fab fa-discord"></i></a>
|
177 |
+
</div>
|
178 |
+
<div class="mt-4">
|
179 |
+
<a href="https://flux1.ai/?utm_source=hf_ipo_space" class="text-purple-300 hover:text-purple-100 transition-colors">Flux AI Image Generator</a>
|
180 |
+
</div>
|
181 |
+
</div>
|
182 |
+
</footer>
|
183 |
+
|
184 |
+
<script>
|
185 |
+
document.addEventListener('DOMContentLoaded', function() {
|
186 |
+
const promptInput = document.getElementById('promptInput');
|
187 |
+
const optimizeBtn = document.getElementById('optimizeBtn');
|
188 |
+
const clearBtn = document.getElementById('clearBtn');
|
189 |
+
const optimizedSection = document.getElementById('optimizedSection');
|
190 |
+
const optimizedPrompt = document.getElementById('optimizedPrompt');
|
191 |
+
const suggestions = document.getElementById('suggestions');
|
192 |
+
const keywordChips = document.getElementById('keywordChips');
|
193 |
+
const copyBtn = document.getElementById('copyBtn');
|
194 |
+
const regenerateBtn = document.getElementById('regenerateBtn');
|
195 |
+
const addAllKeywordsBtn = document.getElementById('addAllKeywordsBtn');
|
196 |
+
const refreshKeywordsBtn = document.getElementById('refreshKeywordsBtn');
|
197 |
+
|
198 |
+
// Keyword database
|
199 |
+
const keywordCategories = {
|
200 |
+
'Style': ['Cyberpunk', 'Minimalist', 'Surrealism', 'Impressionist', 'Steampunk', 'Futurism', 'Vintage', 'Watercolor'],
|
201 |
+
'Lighting': ['Soft natural light', 'Dramatic sidelight', 'Neon lighting', 'Golden hour sunlight', 'Moonlight', 'Studio lighting', 'Candlelight'],
|
202 |
+
'Details': ['8K ultra HD', 'Highly detailed', 'Shallow depth of field', 'Film grain', 'Cinematic lighting', 'HDR effect', 'Macro photography'],
|
203 |
+
'Texture': ['Metallic', 'Furry', 'Glossy', 'Rough', 'Translucent', 'Reflective', 'Matte'],
|
204 |
+
'Perspective': ['Aerial view', 'Macro view', 'Isometric view', 'Low-angle shot', 'First-person view', 'Wide-angle lens'],
|
205 |
+
'Artists': ['Studio Ghibli style', 'Van Gogh style', 'Monet style', 'Ansel Adams style', 'Greg Rutkowski style']
|
206 |
+
};
|
207 |
+
|
208 |
+
// Optimize prompt
|
209 |
+
optimizeBtn.addEventListener('click', function() {
|
210 |
+
const originalPrompt = promptInput.value.trim();
|
211 |
+
if (!originalPrompt) {
|
212 |
+
alert('Please enter a prompt');
|
213 |
+
return;
|
214 |
+
}
|
215 |
+
|
216 |
+
const optimized = optimizePrompt(originalPrompt);
|
217 |
+
const suggestionList = generateSuggestions(originalPrompt);
|
218 |
+
|
219 |
+
optimizedPrompt.innerHTML = `<p class="text-gray-800">${optimized}</p>`;
|
220 |
+
suggestions.innerHTML = suggestionList;
|
221 |
+
|
222 |
+
generateKeywordChips();
|
223 |
+
|
224 |
+
optimizedSection.classList.remove('hidden');
|
225 |
+
optimizedSection.scrollIntoView({ behavior: 'smooth' });
|
226 |
+
});
|
227 |
+
|
228 |
+
// Clear input
|
229 |
+
clearBtn.addEventListener('click', function() {
|
230 |
+
promptInput.value = '';
|
231 |
+
optimizedSection.classList.add('hidden');
|
232 |
+
});
|
233 |
+
|
234 |
+
// Copy optimized prompt
|
235 |
+
copyBtn.addEventListener('click', function() {
|
236 |
+
const text = optimizedPrompt.textContent;
|
237 |
+
navigator.clipboard.writeText(text).then(() => {
|
238 |
+
const originalText = copyBtn.innerHTML;
|
239 |
+
copyBtn.innerHTML = '<i class="fas fa-check"></i> Copied';
|
240 |
+
setTimeout(() => {
|
241 |
+
copyBtn.innerHTML = originalText;
|
242 |
+
}, 2000);
|
243 |
+
});
|
244 |
+
});
|
245 |
+
|
246 |
+
// Regenerate
|
247 |
+
regenerateBtn.addEventListener('click', function() {
|
248 |
+
const originalPrompt = promptInput.value.trim();
|
249 |
+
if (!originalPrompt) return;
|
250 |
+
|
251 |
+
const optimized = optimizePrompt(originalPrompt);
|
252 |
+
optimizedPrompt.innerHTML = `<p class="text-gray-800">${optimized}</p>`;
|
253 |
+
generateKeywordChips();
|
254 |
+
|
255 |
+
// Add animation
|
256 |
+
optimizedPrompt.classList.add('animate-pulse');
|
257 |
+
setTimeout(() => {
|
258 |
+
optimizedPrompt.classList.remove('animate-pulse');
|
259 |
+
}, 500);
|
260 |
+
});
|
261 |
+
|
262 |
+
// Add all keywords
|
263 |
+
addAllKeywordsBtn.addEventListener('click', function() {
|
264 |
+
const currentPrompt = optimizedPrompt.textContent;
|
265 |
+
const chips = keywordChips.querySelectorAll('.keyword-chip');
|
266 |
+
let newPrompt = currentPrompt;
|
267 |
+
|
268 |
+
chips.forEach(chip => {
|
269 |
+
const keyword = chip.textContent.trim();
|
270 |
+
if (!currentPrompt.includes(keyword)) {
|
271 |
+
newPrompt += `, ${keyword}`;
|
272 |
+
}
|
273 |
+
});
|
274 |
+
|
275 |
+
optimizedPrompt.innerHTML = `<p class="text-gray-800">${newPrompt}</p>`;
|
276 |
+
|
277 |
+
// Add animation
|
278 |
+
keywordChips.querySelectorAll('.keyword-chip').forEach(chip => {
|
279 |
+
chip.classList.add('bg-green-100', 'border-green-400');
|
280 |
+
setTimeout(() => {
|
281 |
+
chip.classList.remove('bg-green-100', 'border-green-400');
|
282 |
+
}, 1000);
|
283 |
+
});
|
284 |
+
});
|
285 |
+
|
286 |
+
// Refresh keywords
|
287 |
+
refreshKeywordsBtn.addEventListener('click', function() {
|
288 |
+
generateKeywordChips();
|
289 |
+
});
|
290 |
+
|
291 |
+
// Prompt optimization logic
|
292 |
+
function optimizePrompt(prompt) {
|
293 |
+
// Simple optimization logic - in practice you'd use more complex algorithms
|
294 |
+
let optimized = prompt;
|
295 |
+
|
296 |
+
// Add detail descriptions
|
297 |
+
if (!optimized.includes('fluffy') && (optimized.includes('cat') || optimized.includes('dog'))) {
|
298 |
+
optimized = optimized.replace(/(cat|dog)/, 'fluffy $1');
|
299 |
+
}
|
300 |
+
|
301 |
+
if (optimized.includes('city') && !optimized.includes('style')) {
|
302 |
+
optimized += ', cyberpunk style';
|
303 |
+
}
|
304 |
+
|
305 |
+
if (optimized.includes('person') && !optimized.includes('wearing')) {
|
306 |
+
optimized = optimized.replace(/person/g, 'person wearing stylish clothes');
|
307 |
+
}
|
308 |
+
|
309 |
+
// Ensure lighting description
|
310 |
+
if (!optimized.match(/(light|lighting|sunlight|illumination)/i)) {
|
311 |
+
const lightOptions = ['soft natural light', 'dramatic sidelight', 'golden hour sunlight'];
|
312 |
+
optimized += `, ${lightOptions[Math.floor(Math.random() * lightOptions.length)]}`;
|
313 |
+
}
|
314 |
+
|
315 |
+
// Add quality description
|
316 |
+
if (!optimized.match(/(HD|ultra HD|4K|8K|detailed)/i)) {
|
317 |
+
optimized += ', 8K ultra HD, highly detailed';
|
318 |
+
}
|
319 |
+
|
320 |
+
// Add style description
|
321 |
+
if (!optimized.match(/(style|ism|art)/i)) {
|
322 |
+
const styleOptions = ['surrealism', 'minimalist', 'impressionist style'];
|
323 |
+
optimized += `, ${styleOptions[Math.floor(Math.random() * styleOptions.length)]}`;
|
324 |
+
}
|
325 |
+
|
326 |
+
return optimized;
|
327 |
+
}
|
328 |
+
|
329 |
+
// Generate optimization suggestions
|
330 |
+
function generateSuggestions(prompt) {
|
331 |
+
const suggestions = [];
|
332 |
+
|
333 |
+
if (prompt.length < 20) {
|
334 |
+
suggestions.push('Your prompt is quite short, consider adding more descriptive details');
|
335 |
+
}
|
336 |
+
|
337 |
+
if (!prompt.match(/(light|lighting|sunlight|illumination)/i)) {
|
338 |
+
suggestions.push('Consider adding lighting conditions like "soft natural light" or "dramatic sidelight"');
|
339 |
+
}
|
340 |
+
|
341 |
+
if (!prompt.match(/(style|ism|art)/i)) {
|
342 |
+
suggestions.push('Adding artistic style references can significantly change the image, like "cyberpunk style" or "impressionist"');
|
343 |
+
}
|
344 |
+
|
345 |
+
if (!prompt.match(/(HD|ultra HD|4K|8K|detailed)/i)) {
|
346 |
+
suggestions.push('Include quality descriptors like "8K ultra HD" or "highly detailed" to improve image clarity');
|
347 |
+
}
|
348 |
+
|
349 |
+
if (prompt.split(' ').length < 5) {
|
350 |
+
suggestions.push('Try using more specific terms instead of generic ones, like "fluffy orange tabby cat" instead of "a cat"');
|
351 |
+
}
|
352 |
+
|
353 |
+
let html = '<ul class="space-y-3">';
|
354 |
+
suggestions.forEach(suggestion => {
|
355 |
+
html += `<li class="flex items-start">
|
356 |
+
<i class="fas fa-check-circle text-purple-500 mt-1 mr-2"></i>
|
357 |
+
<span class="text-gray-700">${suggestion}</span>
|
358 |
+
</li>`;
|
359 |
+
});
|
360 |
+
html += '</ul>';
|
361 |
+
|
362 |
+
return html;
|
363 |
+
}
|
364 |
+
|
365 |
+
// Generate keyword chips
|
366 |
+
function generateKeywordChips() {
|
367 |
+
keywordChips.innerHTML = '';
|
368 |
+
|
369 |
+
// Select 1-2 random keywords from each category
|
370 |
+
Object.keys(keywordCategories).forEach(category => {
|
371 |
+
const keywords = keywordCategories[category];
|
372 |
+
const randomCount = Math.random() > 0.5 ? 2 : 1;
|
373 |
+
const selected = shuffleArray(keywords).slice(0, randomCount);
|
374 |
+
|
375 |
+
selected.forEach(keyword => {
|
376 |
+
const chip = document.createElement('div');
|
377 |
+
chip.className = 'keyword-chip bg-gray-100 border border-gray-200 px-3 py-1 rounded-full text-sm cursor-pointer hover:bg-purple-100 hover:border-purple-300 flex items-center gap-1';
|
378 |
+
chip.innerHTML = `<span class="text-purple-600">+</span> ${keyword}`;
|
379 |
+
|
380 |
+
chip.addEventListener('click', function() {
|
381 |
+
const currentPrompt = optimizedPrompt.textContent;
|
382 |
+
if (!currentPrompt.includes(keyword)) {
|
383 |
+
optimizedPrompt.innerHTML = `<p class="text-gray-800">${currentPrompt}, ${keyword}</p>`;
|
384 |
+
}
|
385 |
+
chip.classList.add('bg-purple-100', 'border-purple-400');
|
386 |
+
setTimeout(() => {
|
387 |
+
chip.classList.remove('bg-purple-100', 'border-purple-400');
|
388 |
+
}, 500);
|
389 |
+
});
|
390 |
+
|
391 |
+
keywordChips.appendChild(chip);
|
392 |
+
});
|
393 |
+
});
|
394 |
+
}
|
395 |
+
|
396 |
+
// Helper function: Shuffle array
|
397 |
+
function shuffleArray(array) {
|
398 |
+
const newArray = [...array];
|
399 |
+
for (let i = newArray.length - 1; i > 0; i--) {
|
400 |
+
const j = Math.floor(Math.random() * (i + 1));
|
401 |
+
[newArray[i], newArray[j]] = [newArray[j], newArray[i]];
|
402 |
+
}
|
403 |
+
return newArray;
|
404 |
+
}
|
405 |
+
});
|
406 |
+
</script>
|
407 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - <a href="https://enzostvs-deepsite.hf.space?remix=GavinKing/ai-image-prompt-optimizer" style="color: #fff;text-decoration: underline;" target="_blank" >🧬 Remix</a></p></body>
|
408 |
+
</html>
|