gg3554 commited on
Commit
95b88a5
Β·
verified Β·
1 Parent(s): abd74e7

Upload 4 files

Browse files
Files changed (4) hide show
  1. README.md +111 -13
  2. gemini_logo.gif +0 -0
  3. index.html +548 -0
  4. requirements.txt +28 -0
README.md CHANGED
@@ -1,13 +1,111 @@
1
- ---
2
- title: ImageGenerator
3
- emoji: πŸ“Š
4
- colorFrom: yellow
5
- colorTo: red
6
- sdk: gradio
7
- sdk_version: 6.0.1
8
- app_file: app.py
9
- pinned: false
10
- license: apache-2.0
11
- ---
12
-
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ImageGenerator
2
+
3
+ ```
4
+ GEMINI 2.5 PRO PROMPT ENHANCEMENT
5
+ Original prompt: a dog in front of a desk
6
+ Enhanced prompt: A photorealistic, eye-level shot of a Golden Retriever sitting by a wooden desk. Soft, warm morning light streams from a window, creating gentle highlights and deep shadows. The background is softly blurred, focusing on the dog's detailed fur. A cozy, cinematic atmosphere with an earthy color palette.
7
+ Word count: 47
8
+ Processing sample 1/1: A photorealistic, eye-level shot of a Golden Retriever sitting by a wooden desk. Soft, warm morning light streams from a window, creating gentle highlights and deep shadows. The background is softly blurred, focusing on the dog's detailed fur. A cozy, cinematic atmosphere with an earthy color palette.
9
+ 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 30/30 [00:05<00:00, 5.08it/s]
10
+ Saved as: generated_image_0.png
11
+ ============================================================
12
+ DETAILED SAMPLE SCORES
13
+ ============================================================
14
+ Average CLIPScore: 0.2753
15
+ Average GenEval Score: 0.6883
16
+ Inception Score: 1.0000 Β± 0.0000
17
+ Inception Entropy: 7.5517
18
+
19
+ ```
20
+ <img width="475" height="500" alt="image" src="https://github.com/user-attachments/assets/f1921bc4-5068-4373-8192-f2034af5416d" />
21
+
22
+ # Text to Image Generation Web App
23
+
24
+ A Flask-based web application that generates images from text prompts using Stable Diffusion and evaluates them using CLIP scores.
25
+
26
+ ## Features
27
+
28
+ - 🎨 Generate images from text descriptions
29
+ - πŸ“Š CLIP score evaluation for image-text alignment
30
+ - πŸ’¬ Chat-style interface
31
+ - πŸŒ™ Modern dark theme UI
32
+
33
+ ## Requirements
34
+
35
+ - Python 3.8+
36
+ - CUDA-capable GPU (recommended) or CPU
37
+ - ~10GB disk space for models
38
+
39
+ ## Installation
40
+
41
+ 1. **Clone or download the project files**
42
+
43
+ 2. **Create a virtual environment (recommended)**
44
+ ```bash
45
+ python -m venv venv
46
+ source venv/bin/activate # Linux/Mac
47
+ # or
48
+ venv\Scripts\activate # Windows
49
+ ```
50
+
51
+ 3. **Install dependencies**
52
+ ```bash
53
+ pip install -r requirements.txt
54
+ ```
55
+
56
+ ## Running the Application
57
+
58
+ 1. **Start the Flask server**
59
+ ```bash
60
+ python app.py
61
+ ```
62
+
63
+ 2. **Open your browser** and go to:
64
+ ```
65
+ http://localhost:5000
66
+ ```
67
+
68
+ 3. **Enter a prompt** and click "Generate" to create an image!
69
+
70
+ ## Project Structure
71
+
72
+ ```
73
+ project/
74
+ β”œβ”€β”€ app.py # Main Flask application
75
+ β”œβ”€β”€ templates/
76
+ β”‚ └── index.html # Web interface
77
+ β”œβ”€β”€ static/
78
+ β”‚ └── images/ # Static assets (optional)
79
+ β”œβ”€β”€ requirements.txt # Python dependencies
80
+ └── README.md # This file
81
+ ```
82
+
83
+ ## Notes
84
+
85
+ - **First run**: The application will download required AI models (~5-7GB). This happens only once.
86
+ - **Generation time**: Each image takes 30-60 seconds on GPU, longer on CPU.
87
+ - **Memory**: Requires ~8GB VRAM (GPU) or ~16GB RAM (CPU).
88
+
89
+ ## Troubleshooting
90
+
91
+ ### Out of Memory
92
+ If you get CUDA out of memory errors, try:
93
+ - Closing other GPU applications
94
+ - Reducing `num_inference_steps` in `app.py`
95
+ - Using CPU mode (slower but works with less memory)
96
+
97
+ ### Slow Generation
98
+ - CPU mode is significantly slower than GPU
99
+ - Consider using a cloud GPU service for better performance
100
+
101
+ ## API Endpoints
102
+
103
+ - `GET /` - Web interface
104
+ - `POST /` - Generate image (form data: `prompt`)
105
+ - `GET /health` - Health check
106
+
107
+ ## Scores Explained
108
+
109
+ - **CLIP Score**: Measures how well the image matches the text (0-1, higher is better)
110
+ - **GenEval Score**: Derived metric (CLIP Γ— 2.5) for easier interpretation
111
+
gemini_logo.gif ADDED
index.html ADDED
@@ -0,0 +1,548 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="x-ua-compatible" content="ie=edge">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1">
7
+ <meta name="description" content="Text to Image Generation using Stable Diffusion with CLIP evaluation">
8
+
9
+ <title>Text to Image Generation</title>
10
+ <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
11
+ integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
12
+ <link rel="preconnect" href="https://fonts.googleapis.com">
13
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
14
+ <link href="https://fonts.googleapis.com/css2?family=Manrope:wght@300;400;600;700&display=swap" rel="stylesheet">
15
+
16
+ <style>
17
+ * {
18
+ box-sizing: border-box;
19
+ }
20
+
21
+ body {
22
+ font-family: 'Manrope', sans-serif;
23
+ margin: 0;
24
+ min-height: 100vh;
25
+ background: linear-gradient(135deg, #0a0f1a 0%, #1a1f3a 50%, #0d1229 100%);
26
+ color: #fff;
27
+ }
28
+
29
+ .container-main {
30
+ max-width: 900px;
31
+ margin: 0 auto;
32
+ padding: 20px;
33
+ }
34
+
35
+ .header {
36
+ text-align: center;
37
+ padding: 40px 20px;
38
+ background: linear-gradient(180deg, rgba(99, 102, 241, 0.1) 0%, transparent 100%);
39
+ border-radius: 20px;
40
+ margin-bottom: 30px;
41
+ }
42
+
43
+ .header h1 {
44
+ font-size: 2.5rem;
45
+ font-weight: 700;
46
+ background: linear-gradient(135deg, #818cf8 0%, #c084fc 50%, #f472b6 100%);
47
+ -webkit-background-clip: text;
48
+ -webkit-text-fill-color: transparent;
49
+ background-clip: text;
50
+ margin-bottom: 10px;
51
+ }
52
+
53
+ .header p {
54
+ color: #94a3b8;
55
+ font-size: 1rem;
56
+ max-width: 600px;
57
+ margin: 0 auto;
58
+ }
59
+
60
+ .input-section {
61
+ background: rgba(30, 41, 59, 0.5);
62
+ border: 1px solid rgba(99, 102, 241, 0.2);
63
+ border-radius: 16px;
64
+ padding: 24px;
65
+ margin-bottom: 30px;
66
+ backdrop-filter: blur(10px);
67
+ }
68
+
69
+ .input-wrapper {
70
+ display: flex;
71
+ gap: 12px;
72
+ }
73
+
74
+ .prompt-input {
75
+ flex: 1;
76
+ background: rgba(15, 23, 42, 0.8);
77
+ border: 1px solid rgba(99, 102, 241, 0.3);
78
+ border-radius: 12px;
79
+ padding: 16px 20px;
80
+ color: #fff;
81
+ font-size: 1rem;
82
+ font-family: 'Manrope', sans-serif;
83
+ transition: all 0.3s ease;
84
+ }
85
+
86
+ .prompt-input:focus {
87
+ outline: none;
88
+ border-color: #818cf8;
89
+ box-shadow: 0 0 20px rgba(129, 140, 248, 0.2);
90
+ }
91
+
92
+ .prompt-input::placeholder {
93
+ color: #64748b;
94
+ }
95
+
96
+ .generate-btn {
97
+ background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
98
+ border: none;
99
+ border-radius: 12px;
100
+ padding: 16px 32px;
101
+ color: #fff;
102
+ font-weight: 600;
103
+ font-size: 1rem;
104
+ cursor: pointer;
105
+ transition: all 0.3s ease;
106
+ white-space: nowrap;
107
+ }
108
+
109
+ .generate-btn:hover:not(:disabled) {
110
+ transform: translateY(-2px);
111
+ box-shadow: 0 10px 30px rgba(99, 102, 241, 0.4);
112
+ }
113
+
114
+ .generate-btn:disabled {
115
+ opacity: 0.6;
116
+ cursor: not-allowed;
117
+ }
118
+
119
+ .chat-history {
120
+ display: flex;
121
+ flex-direction: column;
122
+ gap: 16px;
123
+ margin-bottom: 30px;
124
+ }
125
+
126
+ .chat-message {
127
+ display: flex;
128
+ gap: 16px;
129
+ padding: 20px;
130
+ border-radius: 16px;
131
+ animation: fadeIn 0.3s ease;
132
+ }
133
+
134
+ @keyframes fadeIn {
135
+ from { opacity: 0; transform: translateY(10px); }
136
+ to { opacity: 1; transform: translateY(0); }
137
+ }
138
+
139
+ .user-message {
140
+ background: rgba(99, 102, 241, 0.1);
141
+ border: 1px solid rgba(99, 102, 241, 0.2);
142
+ }
143
+
144
+ .bot-message {
145
+ background: rgba(30, 41, 59, 0.6);
146
+ border: 1px solid rgba(148, 163, 184, 0.1);
147
+ }
148
+
149
+ .avatar {
150
+ width: 40px;
151
+ height: 40px;
152
+ border-radius: 50%;
153
+ flex-shrink: 0;
154
+ display: flex;
155
+ align-items: center;
156
+ justify-content: center;
157
+ font-size: 1.2rem;
158
+ }
159
+
160
+ .user-avatar {
161
+ background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
162
+ }
163
+
164
+ .bot-avatar {
165
+ background: linear-gradient(135deg, #10b981 0%, #059669 100%);
166
+ }
167
+
168
+ .message-content {
169
+ flex: 1;
170
+ }
171
+
172
+ .message-content p {
173
+ margin: 0;
174
+ color: #e2e8f0;
175
+ line-height: 1.6;
176
+ }
177
+
178
+ .image-container {
179
+ margin-top: 16px;
180
+ }
181
+
182
+ .generated-image {
183
+ max-width: 100%;
184
+ width: 512px;
185
+ height: auto;
186
+ border-radius: 12px;
187
+ box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
188
+ }
189
+
190
+ .scores-container {
191
+ display: flex;
192
+ gap: 16px;
193
+ margin-top: 16px;
194
+ flex-wrap: wrap;
195
+ }
196
+
197
+ .score-badge {
198
+ background: rgba(15, 23, 42, 0.8);
199
+ border: 1px solid rgba(99, 102, 241, 0.3);
200
+ border-radius: 10px;
201
+ padding: 12px 20px;
202
+ display: flex;
203
+ flex-direction: column;
204
+ gap: 4px;
205
+ }
206
+
207
+ .score-label {
208
+ font-size: 0.75rem;
209
+ color: #94a3b8;
210
+ text-transform: uppercase;
211
+ letter-spacing: 0.5px;
212
+ }
213
+
214
+ .score-value {
215
+ font-size: 1.25rem;
216
+ font-weight: 700;
217
+ background: linear-gradient(135deg, #818cf8 0%, #c084fc 100%);
218
+ -webkit-background-clip: text;
219
+ -webkit-text-fill-color: transparent;
220
+ background-clip: text;
221
+ }
222
+
223
+ .loading-container {
224
+ display: flex;
225
+ flex-direction: column;
226
+ align-items: center;
227
+ gap: 16px;
228
+ padding: 40px;
229
+ }
230
+
231
+ .loading-spinner {
232
+ width: 60px;
233
+ height: 60px;
234
+ border: 3px solid rgba(99, 102, 241, 0.2);
235
+ border-top-color: #818cf8;
236
+ border-radius: 50%;
237
+ animation: spin 1s linear infinite;
238
+ }
239
+
240
+ @keyframes spin {
241
+ to { transform: rotate(360deg); }
242
+ }
243
+
244
+ .loading-text {
245
+ color: #94a3b8;
246
+ font-size: 0.9rem;
247
+ }
248
+
249
+ .loading-steps {
250
+ display: flex;
251
+ flex-direction: column;
252
+ gap: 8px;
253
+ margin-top: 10px;
254
+ }
255
+
256
+ .loading-step {
257
+ display: flex;
258
+ align-items: center;
259
+ gap: 10px;
260
+ color: #64748b;
261
+ font-size: 0.85rem;
262
+ }
263
+
264
+ .loading-step.active {
265
+ color: #818cf8;
266
+ }
267
+
268
+ .loading-step.done {
269
+ color: #10b981;
270
+ }
271
+
272
+ .step-icon {
273
+ width: 20px;
274
+ height: 20px;
275
+ border-radius: 50%;
276
+ border: 2px solid currentColor;
277
+ display: flex;
278
+ align-items: center;
279
+ justify-content: center;
280
+ font-size: 0.7rem;
281
+ }
282
+
283
+ .placeholder-container {
284
+ text-align: center;
285
+ padding: 60px 20px;
286
+ background: rgba(30, 41, 59, 0.3);
287
+ border: 2px dashed rgba(99, 102, 241, 0.3);
288
+ border-radius: 20px;
289
+ }
290
+
291
+ .placeholder-icon {
292
+ font-size: 4rem;
293
+ margin-bottom: 16px;
294
+ opacity: 0.5;
295
+ }
296
+
297
+ .placeholder-text {
298
+ color: #64748b;
299
+ font-size: 1.1rem;
300
+ }
301
+
302
+ .error-message {
303
+ background: rgba(239, 68, 68, 0.1);
304
+ border: 1px solid rgba(239, 68, 68, 0.3);
305
+ border-radius: 12px;
306
+ padding: 16px;
307
+ color: #fca5a5;
308
+ margin-top: 16px;
309
+ }
310
+
311
+ @media (max-width: 640px) {
312
+ .header h1 {
313
+ font-size: 1.75rem;
314
+ }
315
+
316
+ .input-wrapper {
317
+ flex-direction: column;
318
+ }
319
+
320
+ .generate-btn {
321
+ width: 100%;
322
+ }
323
+
324
+ .scores-container {
325
+ flex-direction: column;
326
+ }
327
+
328
+ .score-badge {
329
+ width: 100%;
330
+ }
331
+ }
332
+ </style>
333
+ </head>
334
+
335
+ <body>
336
+ <div class="container-main">
337
+ <div class="header">
338
+ <h1>✨ Text to Image Generator</h1>
339
+ <p>Transform your imagination into stunning visuals using AI-powered image generation with quality evaluation</p>
340
+ </div>
341
+ <div align="center" style="margin-bottom: 20px; color: #fbbf24;">
342
+ ⚑ <strong>Note:</strong> Image generation may take 30-60 seconds depending on your hardware. Please be patient!
343
+ </div>
344
+ <div class="input-section">
345
+ <div class="input-wrapper">
346
+ <input
347
+ type="text"
348
+ class="prompt-input"
349
+ id="chat-input"
350
+ placeholder="Describe the image you want to create... (e.g., A majestic dragon flying over a crystal castle at sunset)"
351
+ >
352
+ <button id="generate-btn" class="generate-btn">Generate
353
+ </button>
354
+ </div>
355
+ </div>
356
+
357
+ <div id="chat-history" class="chat-history">
358
+ <!-- Chat messages will appear here -->
359
+ </div>
360
+
361
+ <div id="placeholder" class="placeholder-container">
362
+ <div class="placeholder-icon">πŸ–ΌοΈ</div>
363
+ <p class="placeholder-text">Enter a prompt above to generate your first image</p>
364
+ </div>
365
+ </div>
366
+
367
+ <script src="https://code.jquery.com/jquery-3.6.3.min.js"
368
+ integrity="sha256-pvPw+upLPUjgMXY0G+8O0xUf+/Im1MZjXxxgOcBQBXU=" crossorigin="anonymous"></script>
369
+
370
+ <script>
371
+ $(document).ready(function() {
372
+ const $chatHistory = $('#chat-history');
373
+ const $placeholder = $('#placeholder');
374
+ const $input = $('#chat-input');
375
+ const $btn = $('#generate-btn');
376
+
377
+ function generateImage() {
378
+ const prompt = $input.val().trim();
379
+
380
+ if (!prompt) {
381
+ alert('Please enter a prompt!');
382
+ return;
383
+ }
384
+
385
+ // Hide placeholder
386
+ $placeholder.hide();
387
+
388
+ // Disable input
389
+ $btn.prop('disabled', true).html('⏳ Generating...');
390
+ $input.prop('disabled', true);
391
+
392
+ // Add user message
393
+ const userMessage = `
394
+ <div class="chat-message user-message">
395
+ <div class="avatar user-avatar">πŸ‘€</div>
396
+ <div class="message-content">
397
+ <p>${escapeHtml(prompt)}</p>
398
+ </div>
399
+ </div>
400
+ `;
401
+ $chatHistory.append(userMessage);
402
+
403
+ // Add loading message
404
+ const loadingId = 'loading-' + Date.now();
405
+ const loadingMessage = `
406
+ <div class="chat-message bot-message" id="${loadingId}">
407
+ <div class="avatar bot-avatar">πŸ€–</div>
408
+ <div class="message-content">
409
+ <div class="loading-container">
410
+ <div class="loading-spinner"></div>
411
+ <div class="loading-text">Creating your masterpiece...</div>
412
+ <div class="loading-steps">
413
+ <div class="loading-step active" id="step1">
414
+ <span class="step-icon">1</span>
415
+ <span>Processing prompt...</span>
416
+ </div>
417
+ <div class="loading-step" id="step2">
418
+ <span class="step-icon">2</span>
419
+ <span>Generating image...</span>
420
+ </div>
421
+ <div class="loading-step" id="step3">
422
+ <span class="step-icon">3</span>
423
+ <span>Evaluating quality...</span>
424
+ </div>
425
+ </div>
426
+ </div>
427
+ </div>
428
+ </div>
429
+ `;
430
+ $chatHistory.append(loadingMessage);
431
+
432
+ // Scroll to loading
433
+ $('html, body').animate({
434
+ scrollTop: $(`#${loadingId}`).offset().top - 100
435
+ }, 300);
436
+
437
+ // Simulate step progression
438
+ setTimeout(() => {
439
+ $('#step1').removeClass('active').addClass('done');
440
+ $('#step2').addClass('active');
441
+ }, 2000);
442
+
443
+ setTimeout(() => {
444
+ $('#step2').removeClass('active').addClass('done');
445
+ $('#step3').addClass('active');
446
+ }, 15000);
447
+
448
+ // Clear input
449
+ $input.val('');
450
+
451
+ // Make API call
452
+ $.ajax({
453
+ type: "POST",
454
+ url: "/",
455
+ data: { 'prompt': prompt },
456
+ timeout: 300000, // 5 minute timeout
457
+ success: function(data) {
458
+ // Remove loading message
459
+ $(`#${loadingId}`).remove();
460
+
461
+ if (data.error) {
462
+ showError(data.error);
463
+ return;
464
+ }
465
+
466
+ // Add result message
467
+ const resultMessage = `
468
+ <div class="chat-message bot-message">
469
+ <div class="avatar bot-avatar">πŸ€–</div>
470
+ <div class="message-content">
471
+ <p>Here's your generated image! πŸŽ‰</p>
472
+ <div class="image-container">
473
+ <img src="data:image/png;base64,${data.image_base64}" alt="Generated image" class="generated-image">
474
+ </div>
475
+ <div class="scores-container">
476
+ <div class="score-badge">
477
+ <span class="score-label">CLIP Score</span>
478
+ <span class="score-value">${data.clip_score}</span>
479
+ </div>
480
+ <div class="score-badge">
481
+ <span class="score-label">GenEval Score</span>
482
+ <span class="score-value">${data.geneval_score}</span>
483
+ </div>
484
+ </div>
485
+ </div>
486
+ </div>
487
+ `;
488
+ $chatHistory.append(resultMessage);
489
+
490
+ // Scroll to result
491
+ $('html, body').animate({
492
+ scrollTop: $(document).height()
493
+ }, 300);
494
+ },
495
+ error: function(xhr, status, error) {
496
+ $(`#${loadingId}`).remove();
497
+
498
+ let errorMsg = 'An error occurred while generating the image.';
499
+ if (status === 'timeout') {
500
+ errorMsg = xhr.responseJSON.error + 'Request timed out. The server might be overloaded.';
501
+ } else if (xhr.responseJSON && xhr.responseJSON.error) {
502
+ errorMsg = xhr.responseJSON.error;
503
+ }
504
+ showError(errorMsg);
505
+ },
506
+ complete: function() {
507
+ // Re-enable input
508
+ $btn.prop('disabled', false).html('Generate');
509
+ $input.prop('disabled', false).focus();
510
+ }
511
+ });
512
+ }
513
+
514
+ function showError(message) {
515
+ const errorMessage = `
516
+ <div class="chat-message bot-message">
517
+ <div class="avatar bot-avatar">πŸ€–</div>
518
+ <div class="message-content">
519
+ <div class="error-message">
520
+ ❌ ${escapeHtml(message)}
521
+ </div>
522
+ </div>
523
+ </div>
524
+ `;
525
+ $chatHistory.append(errorMessage);
526
+ }
527
+
528
+ function escapeHtml(text) {
529
+ const div = document.createElement('div');
530
+ div.textContent = text;
531
+ return div.innerHTML;
532
+ }
533
+
534
+ // Event listeners
535
+ $btn.click(generateImage);
536
+
537
+ $input.keypress(function(e) {
538
+ if (e.which === 13) {
539
+ generateImage();
540
+ }
541
+ });
542
+
543
+ // Focus input on page load
544
+ $input.focus();
545
+ });
546
+ </script>
547
+ </body>
548
+ </html>
requirements.txt ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ torch>=2.2.2
2
+ torchvision>=0.17.2
3
+ torchaudio>=2.2.2
4
+ datasets>=2.14.0
5
+ transformers>=4.33.0
6
+ diffusers>=0.35.1
7
+ scikit-learn>=1.3.0
8
+ Pillow>=10.0.0
9
+ matplotlib>=3.7.0
10
+ seaborn>=0.12.2
11
+ numpy>=1.24.0
12
+ accelerate>=0.21.0
13
+ bitsandbytes>=0.40.0
14
+ tensorflow>=2.13.0
15
+ streamlit>=1.28.0
16
+ google-generativeai>=0.3.0
17
+ requests>=2.31.0
18
+ flask-socketio==5.3.6
19
+ python-socketio==5.10.0
20
+ eventlet==0.33.3
21
+ scipy>=1.12.0
22
+ tqdm>=4.66.0
23
+ safetensors==0.4.5
24
+ xformers==0.0.32.post2
25
+ flask>=3.0.3
26
+ flask-cors==4.0.1
27
+ pyopenssl==24.2.1
28
+ cryptography==43.0.0