Felguk commited on
Commit
0663721
·
verified ·
1 Parent(s): 169e558

Add 2 files

Browse files
Files changed (2) hide show
  1. README.md +6 -4
  2. index.html +283 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Imageai
3
- emoji: 🏢
4
- colorFrom: pink
5
  colorTo: gray
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: imageai
3
+ emoji: 🐳
4
+ colorFrom: gray
5
  colorTo: gray
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,283 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>ImaginAI - AI Image Generator</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
+ @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');
11
+
12
+ body {
13
+ font-family: 'Poppins', sans-serif;
14
+ background-color: #f8fafc;
15
+ }
16
+
17
+ .gradient-bg {
18
+ background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%);
19
+ }
20
+
21
+ .image-card {
22
+ transition: all 0.3s ease;
23
+ box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
24
+ }
25
+
26
+ .image-card:hover {
27
+ transform: translateY(-5px);
28
+ box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
29
+ }
30
+
31
+ .loading-spinner {
32
+ animation: spin 1s linear infinite;
33
+ }
34
+
35
+ @keyframes spin {
36
+ 0% { transform: rotate(0deg); }
37
+ 100% { transform: rotate(360deg); }
38
+ }
39
+
40
+ .prompt-input:focus {
41
+ outline: none;
42
+ box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.3);
43
+ }
44
+ </style>
45
+ </head>
46
+ <body class="min-h-screen">
47
+ <div class="gradient-bg text-white py-6 px-4 shadow-lg">
48
+ <div class="container mx-auto">
49
+ <div class="flex flex-col md:flex-row justify-between items-center">
50
+ <div class="flex items-center mb-4 md:mb-0">
51
+ <i class="fas fa-palette text-3xl mr-3"></i>
52
+ <h1 class="text-2xl md:text-3xl font-bold">ImaginAI</h1>
53
+ </div>
54
+ <div class="flex items-center space-x-2">
55
+ <span class="hidden md:inline-block text-sm">Powered by</span>
56
+ <span class="bg-white text-indigo-600 px-3 py-1 rounded-full text-sm font-semibold">Pollinations.ai</span>
57
+ </div>
58
+ </div>
59
+ </div>
60
+ </div>
61
+
62
+ <div class="container mx-auto px-4 py-8">
63
+ <div class="max-w-3xl mx-auto mb-12">
64
+ <div class="bg-white rounded-xl shadow-lg p-6">
65
+ <h2 class="text-xl font-semibold mb-4 text-gray-800">Describe your imagination</h2>
66
+ <div class="flex">
67
+ <input
68
+ type="text"
69
+ id="promptInput"
70
+ placeholder="e.g. A futuristic cityscape at sunset with flying cars"
71
+ class="flex-grow prompt-input border-2 border-gray-200 rounded-l-lg px-4 py-3 focus:border-indigo-500 transition"
72
+ >
73
+ <button
74
+ id="generateBtn"
75
+ class="bg-indigo-600 hover:bg-indigo-700 text-white px-6 py-3 rounded-r-lg font-medium transition flex items-center"
76
+ >
77
+ <span id="btnText">Generate</span>
78
+ <i id="btnIcon" class="fas fa-magic ml-2"></i>
79
+ </button>
80
+ </div>
81
+ <div class="mt-4 flex flex-wrap gap-2">
82
+ <button class="quick-prompt bg-gray-100 hover:bg-gray-200 text-gray-700 px-3 py-1 rounded-full text-sm transition" data-prompt="A majestic lion in the savannah at golden hour">Lion</button>
83
+ <button class="quick-prompt bg-gray-100 hover:bg-gray-200 text-gray-700 px-3 py-1 rounded-full text-sm transition" data-prompt="Cyberpunk neon cityscape with rain reflections">Cyberpunk</button>
84
+ <button class="quick-prompt bg-gray-100 hover:bg-gray-200 text-gray-700 px-3 py-1 rounded-full text-sm transition" data-prompt="Surreal landscape with floating islands and waterfalls">Surreal</button>
85
+ <button class="quick-prompt bg-gray-100 hover:bg-gray-200 text-gray-700 px-3 py-1 rounded-full text-sm transition" data-prompt="Portrait of a steampunk inventor with intricate mechanical details">Steampunk</button>
86
+ <button class="quick-prompt bg-gray-100 hover:bg-gray-200 text-gray-700 px-3 py-1 rounded-full text-sm transition" data-prompt="Futuristic space station orbiting a gas giant planet">Space</button>
87
+ </div>
88
+ </div>
89
+ </div>
90
+
91
+ <div id="loadingIndicator" class="hidden text-center py-12">
92
+ <div class="inline-block loading-spinner text-indigo-600 text-4xl mb-4">
93
+ <i class="fas fa-spinner"></i>
94
+ </div>
95
+ <p class="text-gray-600">Generating your image... This may take a moment</p>
96
+ </div>
97
+
98
+ <div id="resultsContainer" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
99
+ <div class="text-center text-gray-500 py-12">
100
+ <i class="fas fa-image text-4xl mb-4 opacity-30"></i>
101
+ <p>Your generated images will appear here</p>
102
+ </div>
103
+ </div>
104
+
105
+ <div id="errorMessage" class="hidden max-w-3xl mx-auto bg-red-50 border-l-4 border-red-500 p-4 mb-8">
106
+ <div class="flex">
107
+ <div class="flex-shrink-0">
108
+ <i class="fas fa-exclamation-circle text-red-500 mt-1"></i>
109
+ </div>
110
+ <div class="ml-3">
111
+ <p class="text-sm text-red-700" id="errorText">There was an error generating your image. Please try again.</p>
112
+ </div>
113
+ </div>
114
+ </div>
115
+ </div>
116
+
117
+ <footer class="bg-gray-100 py-6 mt-12">
118
+ <div class="container mx-auto px-4 text-center text-gray-500 text-sm">
119
+ <p>© 2023 ImaginAI. All images are generated by AI using Pollinations.ai API.</p>
120
+ <p class="mt-2">For entertainment purposes only.</p>
121
+ </div>
122
+ </footer>
123
+
124
+ <script>
125
+ document.addEventListener('DOMContentLoaded', function() {
126
+ const promptInput = document.getElementById('promptInput');
127
+ const generateBtn = document.getElementById('generateBtn');
128
+ const btnText = document.getElementById('btnText');
129
+ const btnIcon = document.getElementById('btnIcon');
130
+ const loadingIndicator = document.getElementById('loadingIndicator');
131
+ const resultsContainer = document.getElementById('resultsContainer');
132
+ const errorMessage = document.getElementById('errorMessage');
133
+ const quickPrompts = document.querySelectorAll('.quick-prompt');
134
+
135
+ // Quick prompt buttons
136
+ quickPrompts.forEach(button => {
137
+ button.addEventListener('click', function() {
138
+ promptInput.value = this.getAttribute('data-prompt');
139
+ });
140
+ });
141
+
142
+ // Generate image
143
+ generateBtn.addEventListener('click', generateImage);
144
+ promptInput.addEventListener('keypress', function(e) {
145
+ if (e.key === 'Enter') {
146
+ generateImage();
147
+ }
148
+ });
149
+
150
+ function generateImage() {
151
+ const prompt = promptInput.value.trim();
152
+
153
+ if (!prompt) {
154
+ showError("Please enter a description for your image");
155
+ return;
156
+ }
157
+
158
+ // UI updates
159
+ btnText.textContent = "Generating...";
160
+ btnIcon.className = "fas fa-spinner loading-spinner ml-2";
161
+ generateBtn.disabled = true;
162
+ loadingIndicator.classList.remove('hidden');
163
+ errorMessage.classList.add('hidden');
164
+
165
+ // Encode the prompt for URL
166
+ const encodedPrompt = encodeURIComponent(prompt);
167
+ const apiUrl = `https://image.pollinations.ai/prompt/${encodedPrompt}?nologo=true&seed=${Math.floor(Math.random() * 1000000)}`;
168
+
169
+ // Create image element
170
+ const img = new Image();
171
+ img.crossOrigin = "anonymous";
172
+
173
+ img.onload = function() {
174
+ // Add the new image to the results
175
+ addImageToResults(img.src, prompt);
176
+
177
+ // Reset UI
178
+ resetUI();
179
+ };
180
+
181
+ img.onerror = function() {
182
+ showError("Failed to generate image. The service might be unavailable or your prompt might be blocked.");
183
+ resetUI();
184
+ };
185
+
186
+ img.src = apiUrl;
187
+ }
188
+
189
+ function addImageToResults(imageUrl, prompt) {
190
+ // Remove the placeholder if it exists
191
+ if (resultsContainer.querySelector('.text-center.text-gray-500')) {
192
+ resultsContainer.innerHTML = '';
193
+ }
194
+
195
+ const imageCard = document.createElement('div');
196
+ imageCard.className = 'image-card bg-white rounded-xl overflow-hidden hover:shadow-xl transition';
197
+
198
+ imageCard.innerHTML = `
199
+ <div class="relative">
200
+ <img src="${imageUrl}" alt="${prompt}" class="w-full h-64 object-cover">
201
+ <div class="absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/70 to-transparent p-4">
202
+ <p class="text-white text-sm truncate">${prompt}</p>
203
+ </div>
204
+ <div class="absolute top-2 right-2">
205
+ <button class="download-btn bg-white/90 hover:bg-white text-gray-800 p-2 rounded-full shadow">
206
+ <i class="fas fa-download"></i>
207
+ </button>
208
+ </div>
209
+ </div>
210
+ <div class="p-4">
211
+ <div class="flex justify-between items-center">
212
+ <button class="like-btn text-gray-400 hover:text-red-500 transition">
213
+ <i class="far fa-heart"></i>
214
+ </button>
215
+ <button class="share-btn text-gray-400 hover:text-indigo-500 transition">
216
+ <i class="fas fa-share-alt"></i>
217
+ </button>
218
+ </div>
219
+ </div>
220
+ `;
221
+
222
+ // Add to beginning of results
223
+ resultsContainer.insertBefore(imageCard, resultsContainer.firstChild);
224
+
225
+ // Add event listeners for the new buttons
226
+ imageCard.querySelector('.download-btn').addEventListener('click', () => {
227
+ downloadImage(imageUrl, prompt);
228
+ });
229
+
230
+ imageCard.querySelector('.like-btn').addEventListener('click', (e) => {
231
+ const icon = e.currentTarget.querySelector('i');
232
+ if (icon.classList.contains('far')) {
233
+ icon.className = 'fas fa-heart text-red-500';
234
+ } else {
235
+ icon.className = 'far fa-heart';
236
+ }
237
+ });
238
+
239
+ imageCard.querySelector('.share-btn').addEventListener('click', () => {
240
+ shareImage(imageUrl, prompt);
241
+ });
242
+ }
243
+
244
+ function downloadImage(url, prompt) {
245
+ const link = document.createElement('a');
246
+ link.href = url;
247
+ link.download = `imagenai-${prompt.substring(0, 20).replace(/\s+/g, '-').toLowerCase()}-${Date.now()}.jpg`;
248
+ document.body.appendChild(link);
249
+ link.click();
250
+ document.body.removeChild(link);
251
+ }
252
+
253
+ function shareImage(url, prompt) {
254
+ if (navigator.share) {
255
+ navigator.share({
256
+ title: 'Check out this AI generated image',
257
+ text: `I created this image with ImaginAI: "${prompt}"`,
258
+ url: url
259
+ }).catch(err => {
260
+ console.log('Error sharing:', err);
261
+ });
262
+ } else {
263
+ // Fallback for browsers that don't support Web Share API
264
+ const shareUrl = `https://twitter.com/intent/tweet?text=${encodeURIComponent(`Check out this AI generated image: "${prompt}"`)}&url=${encodeURIComponent(url)}`;
265
+ window.open(shareUrl, '_blank');
266
+ }
267
+ }
268
+
269
+ function showError(message) {
270
+ errorText.textContent = message;
271
+ errorMessage.classList.remove('hidden');
272
+ }
273
+
274
+ function resetUI() {
275
+ btnText.textContent = "Generate";
276
+ btnIcon.className = "fas fa-magic ml-2";
277
+ generateBtn.disabled = false;
278
+ loadingIndicator.classList.add('hidden');
279
+ }
280
+ });
281
+ </script>
282
+ <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=Felguk/imageai" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
283
+ </html>