tonyassi commited on
Commit
c40da60
·
verified ·
1 Parent(s): 4b78672

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +39 -17
templates/index.html CHANGED
@@ -96,6 +96,11 @@
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);
@@ -107,13 +112,20 @@
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
 
@@ -141,30 +153,40 @@
141
  <!-- Form -->
142
  <form id="imageForm">
143
  <div class="input-container">
144
- <!-- Input Box 1 -->
145
- <div class="drag-drop-box" id="box1">
146
- <p id="text1">Person/Model Image</p>
147
- <input type="file" id="input1" name="image1" accept="image/*" required>
148
- <img id="preview1" class="preview" style="display: none;">
149
- <span class="remove-btn" id="remove1" style="display: none;" onclick="removeImage('input1', 'preview1', 'text1', 'remove1')">×</span>
 
 
 
150
  </div>
151
 
152
  <!-- Input Box 2 -->
153
- <div class="drag-drop-box" id="box2">
154
- <p id="text2">Garment Image</p>
155
- <input type="file" id="input2" name="image2" accept="image/*" required>
156
- <img id="preview2" class="preview" style="display: none;">
157
- <span class="remove-btn" id="remove2" style="display: none;" onclick="removeImage('input2', 'preview2', 'text2', 'remove2')">×</span>
 
 
 
158
  </div>
159
 
160
 
161
  <!-- Output Container -->
162
- <div class="output-container">
163
- <div class="output-box">
164
- <img id="outputImage" style="display: none;" alt="Output Image">
 
 
 
 
 
 
165
  </div>
166
- <!-- Generate Button -->
167
- <button type="submit" class="generate-btn">Generate (~20 sec)</button>
168
  </div>
169
  </div>
170
  </form>
 
96
  event.preventDefault();
97
  const formData = new FormData(document.getElementById("imageForm"));
98
 
99
+ document.getElementById("outputImage").style.display = "none";
100
+
101
+ const spinner = document.getElementById("spinner");
102
+ spinner.style.display = "block"; // Unhide the spinner
103
+
104
  // Get the key input value and add it to the form data
105
  const keyInput = document.querySelector('.key-input').value;
106
  formData.append('key', keyInput);
 
112
  .then(response => response.json())
113
  .then(data => {
114
  if (data.output_image) {
115
+ spinner.style.display = "none";
116
  document.getElementById("outputImage").src = data.output_image;
117
  document.getElementById("outputImage").style.display = "block";
118
  } else if (data.error) {
119
  alert(data.error);
120
  }
121
  })
122
+ .catch(err => {
123
+ spinner.style.display = "none"; // Hide the spinner on error
124
+ alert("Error: " + err);
125
+ })
126
+ .finally(() => {
127
+ spinner.style.display = "none"; // Ensure spinner hides after completion
128
+ });
129
  }
130
 
131
 
 
153
  <!-- Form -->
154
  <form id="imageForm">
155
  <div class="input-container">
156
+
157
+ <div class="box-wrapper">
158
+ <p>Person</p>
159
+ <div class="drag-drop-box" id="box1">
160
+ <p id="text1">Person/Model Image</p>
161
+ <input type="file" id="input1" name="image1" accept="image/*" required>
162
+ <img id="preview1" class="preview" style="display: none;">
163
+ <span class="remove-btn" id="remove1" style="display: none;" onclick="removeImage('input1', 'preview1', 'text1', 'remove1')">×</span>
164
+ </div>
165
  </div>
166
 
167
  <!-- Input Box 2 -->
168
+ <div class="box-wrapper">
169
+ <p>Garment</p>
170
+ <div class="drag-drop-box" id="box2">
171
+ <p id="text2">Garment Image</p>
172
+ <input type="file" id="input2" name="image2" accept="image/*" required>
173
+ <img id="preview2" class="preview" style="display: none;">
174
+ <span class="remove-btn" id="remove2" style="display: none;" onclick="removeImage('input2', 'preview2', 'text2', 'remove2')">×</span>
175
+ </div>
176
  </div>
177
 
178
 
179
  <!-- Output Container -->
180
+ <div class="box-wrapper">
181
+ <p>Result</p>
182
+ <div class="output-container">
183
+ <div class="output-box">
184
+ <img id="spinner" src="{{ url_for('static', filename='spinner.gif') }}" style="display: none;" alt="Loading...">
185
+ <img id="outputImage" style="display: none;" alt="Output Image">
186
+ </div>
187
+ <!-- Generate Button -->
188
+ <button type="submit" class="generate-btn">Generate (~20 sec)</button>
189
  </div>
 
 
190
  </div>
191
  </div>
192
  </form>