Spaces:
Paused
Paused
Update AB/index.html
Browse files- AB/index.html +58 -92
AB/index.html
CHANGED
|
@@ -219,30 +219,32 @@ h1 {
|
|
| 219 |
</style>
|
| 220 |
</head>
|
| 221 |
<body>
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
<input type="file" id="image_file" name="image_file" accept="image/*" required onchange="previewImage(event, 'sourceImage')"><br>
|
| 226 |
-
<div id="sourceImageContainer">
|
| 227 |
-
|
| 228 |
-
</div><br>
|
| 229 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 230 |
</form>
|
| 231 |
<div id="resultImage">
|
| 232 |
-
|
| 233 |
-
<div id="loadingSpinner" style="display: none;">
|
| 234 |
-
<!-- Replace this with your loading spinner HTML/CSS -->
|
| 235 |
-
</div>
|
| 236 |
-
<div id="resultContainer">
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
<a id="download-link" href="#" download="colorized_image.jpg" style="display:none;">Download Colorized Image</a>
|
| 242 |
-
</div>
|
| 243 |
</div>
|
| 244 |
<script>
|
| 245 |
-
|
| 246 |
const fileInput = event.target;
|
| 247 |
const file = fileInput.files[0];
|
| 248 |
const reader = new FileReader();
|
|
@@ -255,80 +257,44 @@ h1 {
|
|
| 255 |
reader.readAsDataURL(file);
|
| 256 |
}
|
| 257 |
|
| 258 |
-
|
| 259 |
-
// Function to display the processed image
|
| 260 |
-
function displayResultImage(url) {
|
| 261 |
-
const resultContainer = document.getElementById('resultContainer');
|
| 262 |
-
// Create an image element
|
| 263 |
-
const img = document.createElement('img');
|
| 264 |
-
// Set the source attribute to the processed image URL
|
| 265 |
-
img.src = url;
|
| 266 |
-
// Append the image element to the result container
|
| 267 |
-
resultContainer.appendChild(img);
|
| 268 |
-
}
|
| 269 |
-
|
| 270 |
-
|
| 271 |
async function uploadFile() {
|
| 272 |
const image_fileInput = document.getElementById('image_file');
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
}
|
| 308 |
-
|
| 309 |
-
const errorMessage = await response.text();
|
| 310 |
-
resultContainer.innerHTML = `<p>Oops! Something went wrong. Please try again later. </p>`;
|
| 311 |
-
}
|
| 312 |
-
|
| 313 |
-
// Hide loading spinner after result (or error message) is displayed
|
| 314 |
-
loadingSpinner.style.display = 'none';
|
| 315 |
-
estimatedTime.style.display = 'none';
|
| 316 |
-
} catch (error) {
|
| 317 |
-
console.error('Error swapping faces:', error);
|
| 318 |
-
// Hide loading spinner if there's an error
|
| 319 |
-
const loadingSpinner = document.getElementById('loadingSpinner');
|
| 320 |
-
loadingSpinner.style.display = 'none';
|
| 321 |
-
estimatedTime.style.display = 'none';
|
| 322 |
-
}
|
| 323 |
-
}
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
</script>
|
| 332 |
</body>
|
| 333 |
</html>
|
| 334 |
-
|
|
|
|
| 219 |
</style>
|
| 220 |
</head>
|
| 221 |
<body>
|
| 222 |
+
<h1>Aiconvert.online</h1>
|
| 223 |
+
<form id="uploadForm" action="/upload/" method="post" enctype="multipart/form-data">
|
| 224 |
+
<label for="sourceFile" class="uploadLabel">Choose image</label>
|
| 225 |
+
<input type="file" id="image_file" name="image_file" accept="image/*" required onchange="previewImage(event, 'sourceImage')"><br>
|
| 226 |
+
<div id="sourceImageContainer">
|
| 227 |
+
<img id="sourceImage">
|
| 228 |
+
</div><br>
|
| 229 |
+
<label for="top">Top:</label>
|
| 230 |
+
<input type="number" id="top" name="top" required><br>
|
| 231 |
+
|
| 232 |
+
<label for="bottom">Bottom:</label>
|
| 233 |
+
<input type="number" id="bottom" name="bottom" required><br>
|
| 234 |
+
|
| 235 |
+
<label for="left">Left:</label>
|
| 236 |
+
<input type="number" id="left" name="left" required><br>
|
| 237 |
+
|
| 238 |
+
<label for="right">Right:</label>
|
| 239 |
+
<input type="number" id="right" name="right" required><br>
|
| 240 |
+
|
| 241 |
+
<button type="button" onclick="uploadFile()">Generate</button>
|
| 242 |
</form>
|
| 243 |
<div id="resultImage">
|
| 244 |
+
<!-- Add the result image container and loading spinner here -->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 245 |
</div>
|
| 246 |
<script>
|
| 247 |
+
function previewImage(event, imageId) {
|
| 248 |
const fileInput = event.target;
|
| 249 |
const file = fileInput.files[0];
|
| 250 |
const reader = new FileReader();
|
|
|
|
| 257 |
reader.readAsDataURL(file);
|
| 258 |
}
|
| 259 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 260 |
async function uploadFile() {
|
| 261 |
const image_fileInput = document.getElementById('image_file');
|
| 262 |
+
const top = document.getElementById('top').value;
|
| 263 |
+
const bottom = document.getElementById('bottom').value;
|
| 264 |
+
const left = document.getElementById('left').value;
|
| 265 |
+
const right = document.getElementById('right').value;
|
| 266 |
+
const formData = new FormData();
|
| 267 |
+
|
| 268 |
+
// Append the uploaded image and other form data
|
| 269 |
+
formData.append('image_file', image_fileInput.files[0]);
|
| 270 |
+
formData.append('top', top);
|
| 271 |
+
formData.append('bottom', bottom);
|
| 272 |
+
formData.append('left', left);
|
| 273 |
+
formData.append('right', right);
|
| 274 |
+
|
| 275 |
+
try {
|
| 276 |
+
const response = await fetch('/upload/', {
|
| 277 |
+
method: 'POST',
|
| 278 |
+
body: formData
|
| 279 |
+
});
|
| 280 |
+
|
| 281 |
+
if (response.ok) {
|
| 282 |
+
// If successful response, display the result image
|
| 283 |
+
const resultImageContainer = document.getElementById('resultImage');
|
| 284 |
+
const resultData = await response.json();
|
| 285 |
+
const resultImage = new Image();
|
| 286 |
+
resultImage.src = 'data:image/jpeg;base64,' + resultData.result_image;
|
| 287 |
+
resultImageContainer.innerHTML = '';
|
| 288 |
+
resultImageContainer.appendChild(resultImage);
|
| 289 |
+
} else {
|
| 290 |
+
// If server error, display the error message
|
| 291 |
+
const errorMessage = await response.text();
|
| 292 |
+
console.error('Error:', errorMessage);
|
| 293 |
+
}
|
| 294 |
+
} catch (error) {
|
| 295 |
+
console.error('Error:', error);
|
| 296 |
+
}
|
| 297 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 298 |
</script>
|
| 299 |
</body>
|
| 300 |
</html>
|
|
|