File size: 10,738 Bytes
bc4b939
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<!-- 
  SPDX-FileCopyrightText: Hadad <[email protected]>
  SPDX-License-Identifier: Apache-2.0
-->

<div class="gradient-bg"></div>
<div class="gradient-mesh"></div>

<div id="welcomeModal" class="modal-overlay" style="display: none;">
    <div class="modal-content">
        <div class="modal-inner">
            <h2 class="header-gradient animate__animated 
                      animate__fadeInDown modal-title">
                Hi there!
            </h2>
            <div class="animate__animated animate__fadeInUp modal-text">
                Welcome to the <b>Image Generation Playground</b>, 
                where imagination transforms into visual creations.
                <br><br>
                For your information, <b>image generation</b> and 
                <b>OpenAI Audio TTS</b> is already built-in natively 
                in the primary spaces.
                <br><br>
                For more advanced capabilities, please visit the 
                <b><a href='https://umint-openwebui.hf.space' 
                target='_blank' style="color: var(--accent); 
                text-decoration: underline;">
                UltimaX Intelligence</a></b> primary spaces.
                <br><br>
                Please consider reading the 
                <b><a href='https://huggingface.co/spaces/umint/ai/discussions/37' 
                target='_blank' style="color: var(--accent); 
                text-decoration: underline;">
                Terms of Use and Consequences of Violation</a></b> 
                if you wish to proceed to the main Spaces.
                <br><br>
                <b>Like this project? Feel free to buy me a 
                <a href='https://ko-fi.com/hadad' target='_blank' 
                style="color: var(--accent); 
                text-decoration: underline;">coffee</a></b>.
            </div>
            <button onclick="closeWelcomeModal()" 
                    class="btn btn-primary w-full animate__animated 
                           animate__fadeInUp animate__delay-1s">
                Get Started
            </button>
        </div>
    </div>
</div>

<% if (error) { %>
<div id="errorModal" class="modal-overlay">
    <div class="modal-content modal-error-content">
        <div class="modal-inner">
            <h3 class="modal-error-title">Error</h3>
            <p class="modal-error-text"><%= error %></p>
            <button onclick="closeErrorModal()" 
                    class="btn btn-primary w-full">OK</button>
        </div>
    </div>
</div>
<% } %>

<header class="header-main">
    <div class="container mx-auto px-4">
        <h1 class="header-gradient animate__animated 
                  animate__fadeInDown header-title">
            Image Generation Playground
        </h1>
    </div>
</header>

<main class="container mx-auto px-4 main-content">
    
    <div class="image-output-section 
                <%= images && images.length > 0 ? 'has-images' : '' %> 
                animate__animated animate__fadeIn">
        <% if (isGenerating) { %>
            <div class="loading-container">
                <div class="loading-spinner" 
                     style="margin: 0 auto 20px;"></div>
                <p class="loading-text">Generating your image...</p>
                <div class="progress-bar">
                    <div class="progress-fill" 
                         style="width: <%= progress %>%;"></div>
                </div>
                <p class="progress-text">
                    <%= progress.toFixed(0) %>% Complete
                </p>
            </div>
        <% } else if (images && images.length > 0) { %>
            <div class="image-grid">
                <% images.forEach((image, index) => { %>
                <div class="image-card">
                    <img src="data:image/png;base64,<%= image.base64 %>" 
                         alt="<%= image.prompt %>">
                    <div class="image-actions">
                        <a href="data:image/png;base64,<%= image.base64 %>" 
                           download="generated-<%= image.id %>.png" 
                           class="action-btn">
                            <svg class="action-icon" viewBox="0 0 24 24" 
                                 fill="none">
                                <path d="M12 16L7 11L8.4 9.55L11 
                                         12.15V4H13V12.15L15.6 9.55L17 
                                         11L12 16Z" 
                                      fill="currentColor"/>
                                <path d="M4 20C3.45 20 2.98 19.8 2.59 19.41C2.2 
                                         19.02 2 18.55 2 18V15H4V18H20V15H22V18C22 
                                         18.55 21.8 19.02 21.41 19.41C21.02 19.8 
                                         20.55 20 20 20H4Z" 
                                      fill="currentColor"/>
                            </svg>
                        </a>
                        <button type="button" 
                                onclick="deleteImage(<%= index %>)" 
                                class="action-btn">
                            <svg class="action-icon" viewBox="0 0 24 24" 
                                 fill="none">
                                <path d="M18.3 5.71C17.91 5.32 17.28 5.32 16.89 
                                         5.71L12 10.59L7.11 5.7C6.72 5.31 6.09 
                                         5.31 5.7 5.7C5.31 6.09 5.31 6.72 5.7 
                                         7.11L10.59 12L5.7 16.89C5.31 17.28 5.31 
                                         17.91 5.7 18.3C6.09 18.69 6.72 18.69 
                                         7.11 18.3L12 13.41L16.89 18.3C17.28 
                                         18.69 17.91 18.69 18.3 18.3C18.69 17.91 
                                         18.69 17.28 18.3 16.89L13.41 12L18.3 
                                         7.11C18.68 6.73 18.68 6.09 18.3 5.71Z" 
                                      fill="currentColor"/>
                            </svg>
                        </button>
                    </div>
                    <div class="image-info">
                        <p class="image-prompt"><%= image.prompt %></p>
                        <p class="image-meta">
                            <span class="image-model">
                                <%= image.model.toUpperCase() %>
                            </span> 
                            | <%= image.size %>
                        </p>
                    </div>
                </div>
                <% }); %>
            </div>
        <% } else { %>
            <svg class="placeholder-icon" width="80" height="80" 
                 viewBox="0 0 24 24" fill="none">
                <path d="M21 3H3C2 3 1 4 1 5V19C1 20 2 21 3 21H21C22 
                         21 23 20 23 19V5C23 4 22 3 21 3ZM21 19H3V5H21V19Z" 
                      fill="currentColor"/>
                <path d="M4.5 16.5L9 12L11.5 14.5L16 10L19.5 13.5" 
                      stroke="currentColor" stroke-width="1.5" 
                      stroke-linecap="round"/>
                <circle cx="8" cy="8.5" r="1.5" fill="currentColor"/>
            </svg>
            <p class="placeholder-text">
                No images generated yet. Start creating amazing visuals!
            </p>
        <% } %>
    </div>
    
    <section class="card animate__animated animate__fadeIn 
                    animate__delay-1s form-section">
        <form method="POST" action="/" id="generateForm">
            <input type="hidden" name="action" value="generate" 
                   id="formAction">
            <input type="hidden" name="sessionId" 
                   value="<%= sessionId %>" />
            
            <div class="grid md:grid-cols-2 gap-6 form-grid">
                <div>
                    <label class="form-label">Model</label>
                    <select name="model" id="modelSelect" required 
                            class="input-field select-field" 
                            <%= isGenerating ? 'disabled' : '' %>>
                        <option value="">Select a model</option>
                    </select>
                </div>
                
                <div>
                    <label class="form-label">Size</label>
                    <select name="size" id="sizeSelect" required 
                            class="input-field select-field" 
                            <%= isGenerating ? 'disabled' : '' %>>
                        <option value="">Select size</option>
                    </select>
                </div>
            </div>
            
            <div class="form-group">
                <label class="form-label">Prompt</label>
                <textarea name="prompt" id="promptInput" required
                          placeholder="Describe the image you want to generate..." 
                          class="input-field textarea-field" 
                          maxlength="300" 
                          <%= isGenerating ? 'disabled' : '' %>></textarea>
            </div>
            
            <div class="flex justify-center gap-4">
                <% if (!isGenerating) { %>
                <button type="submit" id="submitBtn" disabled 
                        class="btn btn-primary">
                    <svg class="button-icon" viewBox="0 0 24 24" 
                         fill="none">
                        <path d="M3 20V4L22 12L3 20ZM5 17L16.85 12L5 7V10.5L11 
                                 12L5 13.5V17Z" 
                              fill="currentColor"/>
                    </svg>
                    Generate Image
                </button>
                <% } else { %>
                <button type="button" onclick="cancelGeneration()" 
                        class="btn btn-danger">
                    <svg class="button-icon" viewBox="0 0 24 24" 
                         fill="none">
                        <rect x="4" y="4" width="16" height="16" rx="3" 
                              fill="currentColor"/>
                    </svg>
                    Stop Generation
                </button>
                <% } %>
            </div>
        </form>
    </section>
    
    <section class="card animate__animated animate__fadeIn 
                    animate__delay-1s examples-section">
        <h3 class="examples-title">Example Prompts</h3>
        <div class="grid lg:grid-cols-3 md:grid-cols-2 gap-4" 
             id="examplesGrid"></div>
    </section>
</main>

<script src="/__public__/assets/plugins/loadParameter.js"></script>
<script defer src="/__public__/assets/plugins/imageGenerator.js"></script>
<script defer src="/__public__/assets/plugins/webLoader.js"></script>