tonyassi commited on
Commit
5a977e7
·
verified ·
1 Parent(s): 8805703

Upload 2 files

Browse files
Files changed (2) hide show
  1. static/styles.css +275 -0
  2. templates/index.html +181 -0
static/styles.css ADDED
@@ -0,0 +1,275 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* General Reset */
2
+ * {
3
+ margin: 0;
4
+ padding: 0;
5
+ box-sizing: border-box;
6
+ }
7
+
8
+ body {
9
+ font-family: Arial, sans-serif;
10
+ background-color: #f8f8f8;
11
+ color: #333;
12
+ margin: 0;
13
+ display: flex;
14
+ justify-content: center;
15
+ align-items: flex-start;
16
+ min-height: 100vh;
17
+ }
18
+
19
+ .container {
20
+ display: flex;
21
+ flex-direction: column;
22
+ align-items: center; /* Center horizontally */
23
+ width: 100%;
24
+ max-width: 1000px;
25
+ padding: 20px;
26
+ gap: 20px;
27
+ }
28
+
29
+ /* Title */
30
+ .title {
31
+ font-size: 2.5rem;
32
+ font-weight: bold;
33
+ color: #333;
34
+ text-align: center;
35
+ width: 100%;
36
+ }
37
+
38
+ /* Key Input and Get Key Button */
39
+ .key-container {
40
+ display: flex;
41
+ align-items: center;
42
+ gap: 10px;
43
+ /* margin-bottom: 20px; */
44
+ }
45
+
46
+ .key-input {
47
+ width: 300px;
48
+ padding: 10px;
49
+ border: 2px solid #ccc;
50
+ border-radius: 5px;
51
+ font-size: 1rem;
52
+ text-align: center;
53
+ }
54
+
55
+ .get-key-btn {
56
+ padding: 10px 20px;
57
+ background-color: #28a745;
58
+ color: #fff;
59
+ border: none;
60
+ border-radius: 5px;
61
+ cursor: pointer;
62
+ }
63
+
64
+ .get-key-btn:hover {
65
+ background-color: #218838;
66
+ }
67
+
68
+ /* Form Layout */
69
+ form {
70
+ width: 100%;
71
+ }
72
+
73
+ .input-container {
74
+ display: flex;
75
+ flex-wrap: wrap;
76
+ justify-content: flex-start;
77
+ align-items: flex-start;
78
+ gap: 20px;
79
+ width: 100%;
80
+ }
81
+
82
+ /* Drag and Drop Box */
83
+ .drag-drop-box {
84
+ border: 2px dashed #aaa;
85
+ border-radius: 10px;
86
+ width: 300px;
87
+ height: 400px;
88
+ position: relative;
89
+ background-color: #f9f9f9;
90
+ overflow: hidden;
91
+ cursor: pointer;
92
+ transition: background-color 0.3s ease, border-color 0.3s ease;
93
+ display: flex;
94
+ align-items: center;
95
+ justify-content: center;
96
+ }
97
+
98
+ .drag-drop-box p {
99
+ position: absolute;
100
+ margin: 0;
101
+ color: #666;
102
+ pointer-events: none;
103
+ text-align: center;
104
+ width: 80%;
105
+ }
106
+
107
+ .drag-drop-box input[type="file"] {
108
+ position: absolute;
109
+ opacity: 0;
110
+ width: 100%;
111
+ height: 100%;
112
+ cursor: pointer;
113
+ }
114
+
115
+ .drag-drop-box.drag-over {
116
+ background-color: #e8f4ff;
117
+ border-color: #007bff;
118
+ }
119
+
120
+ /* Image Preview */
121
+ .preview {
122
+ max-width: 100%;
123
+ max-height: 100%;
124
+ object-fit: contain;
125
+ position: absolute;
126
+ border-radius: 5px;
127
+ }
128
+
129
+ /* Output Container */
130
+ .output-container {
131
+ display: flex;
132
+ flex-direction: column;
133
+ align-items: center;
134
+ gap: 10px;
135
+ width: 300px;
136
+ }
137
+
138
+ .output-box {
139
+ border: 2px solid #ccc;
140
+ border-radius: 10px;
141
+ width: 300px;
142
+ height: 400px;
143
+ background-color: #fff;
144
+ overflow: hidden;
145
+ position: relative;
146
+ display: flex;
147
+ align-items: center;
148
+ justify-content: center;
149
+ }
150
+
151
+ .output-box img {
152
+ max-width: 100%;
153
+ max-height: 100%;
154
+ object-fit: contain;
155
+ border-radius: 5px;
156
+ }
157
+
158
+ /* Generate Button */
159
+ .generate-btn {
160
+ width: 100%;
161
+ padding: 10px;
162
+ background-color: #007bff;
163
+ color: #fff;
164
+ border: none;
165
+ border-radius: 5px;
166
+ font-size: 16px;
167
+ cursor: pointer;
168
+ }
169
+
170
+ .generate-btn:hover {
171
+ background-color: #0056b3;
172
+ }
173
+
174
+ /* Popup Styles */
175
+ .popup {
176
+ display: none;
177
+ position: fixed;
178
+ z-index: 1000;
179
+ left: 0;
180
+ top: 0;
181
+ width: 100%;
182
+ height: 100%;
183
+ overflow: auto;
184
+ background-color: rgba(0,0,0,0.5);
185
+ }
186
+
187
+ .popup-content {
188
+ background-color: #fff;
189
+ margin: 10% auto;
190
+ padding: 20px;
191
+ border: 1px solid #888;
192
+ width: 90%;
193
+ max-width: 400px;
194
+ text-align: center;
195
+ position: relative;
196
+ border-radius: 10px;
197
+
198
+ display: flex;
199
+ flex-direction: column;
200
+ align-items: center; /* Center content horizontally */
201
+ justify-content: center; /* Center content vertically (optional) */
202
+ }
203
+
204
+ .close-btn {
205
+ position: absolute;
206
+ top: 10px;
207
+ right: 15px;
208
+ color: #aaa;
209
+ font-size: 28px;
210
+ font-weight: bold;
211
+ cursor: pointer;
212
+ }
213
+
214
+ .close-btn:hover,
215
+ .close-btn:focus {
216
+ color: black;
217
+ text-decoration: none;
218
+ cursor: pointer;
219
+ }
220
+
221
+ .popup-input {
222
+ width: 80%;
223
+ padding: 10px;
224
+ margin-top: 15px;
225
+ margin-bottom: 15px;
226
+ border: 2px solid #ccc;
227
+ border-radius: 5px;
228
+ font-size: 1rem;
229
+ }
230
+
231
+ .submit-btn {
232
+ padding: 10px 20px;
233
+ background-color: #28a745;
234
+ color: #fff;
235
+ border: none;
236
+ border-radius: 5px;
237
+ cursor: pointer;
238
+ }
239
+
240
+ .submit-btn:hover {
241
+ background-color: #218838;
242
+ }
243
+ .remove-btn {
244
+ position: absolute;
245
+ top: 5px;
246
+ right: 5px;
247
+ background-color: gray;
248
+ color: white;
249
+ border: none;
250
+ border-radius: 50%;
251
+ width: 20px;
252
+ height: 20px;
253
+ text-align: center;
254
+ font-size: 16px;
255
+ cursor: pointer;
256
+ line-height: 20px;
257
+ display: flex;
258
+ align-items: center;
259
+ justify-content: center;
260
+ }
261
+
262
+
263
+ /* Responsive Layout */
264
+ @media (max-width: 768px) {
265
+ .input-container {
266
+ flex-direction: column;
267
+ align-items: center;
268
+ gap: 20px;
269
+ }
270
+
271
+ .drag-drop-box,
272
+ .output-box {
273
+ width: 100%;
274
+ }
275
+ }
templates/index.html ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>Virtual Try-On</title>
6
+ <link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
7
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
8
+ <script>
9
+ // Handle the popup window
10
+ function openPopup() {
11
+ document.getElementById("popup").style.display = "block";
12
+ document.getElementById("emailInput").style.display = "block";
13
+ document.getElementById("submitBtn").style.display = "block";
14
+ document.getElementById("popupMessage").innerText = "Get a free trial key sent to your email";
15
+ }
16
+
17
+ function closePopup() {
18
+ document.getElementById("popup").style.display = "none";
19
+ document.getElementById("emailInput").value = "";
20
+ document.getElementById("popupMessage").innerText = "Get a free trial key sent to your email";
21
+ }
22
+
23
+ // Handle email submission
24
+ function submitEmail() {
25
+ const emailInput = document.getElementById("emailInput").value;
26
+
27
+ fetch("/send_key", {
28
+ method: "POST",
29
+ headers: { "Content-Type": "application/json" },
30
+ body: JSON.stringify({ email: emailInput })
31
+ })
32
+ .then(response => response.json())
33
+ .then(data => {
34
+ document.getElementById("popupMessage").innerText = data.message;
35
+ document.getElementById("emailInput").style.display = "none";
36
+ document.getElementById("submitBtn").style.display = "none";
37
+ })
38
+ .catch(err => alert("Error: " + err));
39
+ }
40
+
41
+ // Handle drag-and-drop and previews
42
+ function enableImagePreview(boxId, inputId, previewId, textId, removeButtonId) {
43
+ const box = document.getElementById(boxId);
44
+ const input = document.getElementById(inputId);
45
+ const preview = document.getElementById(previewId);
46
+ const text = document.getElementById(textId);
47
+
48
+ box.addEventListener("dragover", (e) => {
49
+ e.preventDefault();
50
+ box.classList.add("drag-over");
51
+ });
52
+
53
+ box.addEventListener("dragleave", () => box.classList.remove("drag-over"));
54
+
55
+ box.addEventListener("drop", (e) => {
56
+ e.preventDefault();
57
+ box.classList.remove("drag-over");
58
+ const file = e.dataTransfer.files[0];
59
+ input.files = e.dataTransfer.files;
60
+ showPreview(file, preview, text, removeButtonId);
61
+ });
62
+
63
+ input.addEventListener("change", () => {
64
+ if (input.files.length > 0) {
65
+ showPreview(input.files[0], preview, text, removeButtonId);
66
+ }
67
+ });
68
+ }
69
+
70
+ function showPreview(file, previewElement, textElement, removeButton) {
71
+ const reader = new FileReader();
72
+ reader.onload = (e) => {
73
+ previewElement.src = e.target.result;
74
+ previewElement.style.display = "block";
75
+ textElement.style.display = "none";
76
+ document.getElementById(removeButton).style.display = "flex";
77
+ };
78
+ reader.readAsDataURL(file);
79
+ }
80
+
81
+ function removeImage(inputId, previewId, textId, removeButtonId) {
82
+ const input = document.getElementById(inputId);
83
+ const preview = document.getElementById(previewId);
84
+ const text = document.getElementById(textId);
85
+ const removeButton = document.getElementById(removeButtonId);
86
+
87
+ input.value = ""; // Clear the file input
88
+ preview.src = ""; // Clear the preview image
89
+ preview.style.display = "none";
90
+ text.style.display = "block";
91
+ removeButton.style.display = "none";
92
+ }
93
+
94
+ // Submit form with AJAX
95
+ function submitForm(event) {
96
+ event.preventDefault();
97
+ const formData = new FormData(document.getElementById("imageForm"));
98
+
99
+ // Get the key input value and add it to the form data
100
+ const keyInput = document.querySelector('.key-input').value;
101
+ formData.append('key', keyInput);
102
+
103
+ fetch("/process", {
104
+ method: "POST",
105
+ body: formData
106
+ })
107
+ .then(response => response.json())
108
+ .then(data => {
109
+ if (data.output_image) {
110
+ document.getElementById("outputImage").src = data.output_image;
111
+ document.getElementById("outputImage").style.display = "block";
112
+ } else if (data.error) {
113
+ alert(data.error);
114
+ }
115
+ })
116
+ .catch(err => alert("Error: " + err));
117
+ }
118
+
119
+
120
+ window.onload = () => {
121
+ enableImagePreview("box1", "input1", "preview1", "text1", "remove1");
122
+ enableImagePreview("box2", "input2", "preview2", "text2", "remove2");
123
+ document.getElementById("imageForm").addEventListener("submit", submitForm);
124
+ };
125
+ </script>
126
+ </head>
127
+ <body>
128
+ <div class="container">
129
+ <!-- Title -->
130
+ <h1 class="title">Virtual Try-On</h1>
131
+
132
+ <!-- Key Input -->
133
+ <div class="key-container">
134
+ <input type="text" class="key-input" placeholder="Input your key here">
135
+ </div>
136
+ <button type="button" class="get-key-btn" onclick="openPopup()">Get a free key</button>
137
+
138
+
139
+ <!-- Form -->
140
+ <form id="imageForm">
141
+ <div class="input-container">
142
+ <!-- Input Box 1 -->
143
+ <div class="drag-drop-box" id="box1">
144
+ <p id="text1">Person/Model Image</p>
145
+ <input type="file" id="input1" name="image1" accept="image/*" required>
146
+ <img id="preview1" class="preview" style="display: none;">
147
+ <span class="remove-btn" id="remove1" style="display: none;" onclick="removeImage('input1', 'preview1', 'text1', 'remove1')">×</span>
148
+ </div>
149
+
150
+ <!-- Input Box 2 -->
151
+ <div class="drag-drop-box" id="box2">
152
+ <p id="text2">Garment Image</p>
153
+ <input type="file" id="input2" name="image2" accept="image/*" required>
154
+ <img id="preview2" class="preview" style="display: none;">
155
+ <span class="remove-btn" id="remove2" style="display: none;" onclick="removeImage('input2', 'preview2', 'text2', 'remove2')">×</span>
156
+ </div>
157
+
158
+
159
+ <!-- Output Container -->
160
+ <div class="output-container">
161
+ <div class="output-box">
162
+ <img id="outputImage" style="display: none;" alt="Output Image">
163
+ </div>
164
+ <!-- Generate Button -->
165
+ <button type="submit" class="generate-btn">Generate (~20 sec)</button>
166
+ </div>
167
+ </div>
168
+ </form>
169
+ </div>
170
+
171
+ <!-- Popup Window -->
172
+ <div id="popup" class="popup">
173
+ <div class="popup-content">
174
+ <span class="close-btn" onclick="closePopup()">×</span>
175
+ <p id="popupMessage">Get a free trial key sent to your email</p>
176
+ <input type="email" id="emailInput" class="popup-input" placeholder="Email">
177
+ <button id="submitBtn" type="button" class="submit-btn" onclick="submitEmail()">Submit</button>
178
+ </div>
179
+ </div>
180
+ </body>
181
+ </html>