Update index.html
Browse files- index.html +82 -13
index.html
CHANGED
|
@@ -1,16 +1,85 @@
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html lang="en">
|
| 3 |
-
|
| 4 |
-
<meta charset="
|
| 5 |
-
<meta name="
|
| 6 |
-
<
|
| 7 |
-
<
|
| 8 |
-
<
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
</html>
|
|
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Image Generation with Flask</title>
|
| 7 |
+
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
| 8 |
+
<style>
|
| 9 |
+
body {
|
| 10 |
+
font-family: Arial, sans-serif;
|
| 11 |
+
text-align: center;
|
| 12 |
+
padding: 20px;
|
| 13 |
+
}
|
| 14 |
+
input, button {
|
| 15 |
+
margin: 10px 0;
|
| 16 |
+
padding: 10px;
|
| 17 |
+
font-size: 16px;
|
| 18 |
+
}
|
| 19 |
+
#result {
|
| 20 |
+
margin-top: 20px;
|
| 21 |
+
}
|
| 22 |
+
img {
|
| 23 |
+
max-width: 100%;
|
| 24 |
+
height: auto;
|
| 25 |
+
}
|
| 26 |
+
#generated-image {
|
| 27 |
+
display: none;
|
| 28 |
+
}
|
| 29 |
+
</style>
|
| 30 |
+
</head>
|
| 31 |
+
<body>
|
| 32 |
+
<h1>Generate an Image from Text</h1>
|
| 33 |
+
<form id="generate-form">
|
| 34 |
+
<label for="model">Model Name:</label>
|
| 35 |
+
<input type="text" id="model" name="model" value="prompthero/openjourney-v4"><br>
|
| 36 |
+
|
| 37 |
+
<label for="prompt">Prompt:</label>
|
| 38 |
+
<input type="text" id="prompt" name="prompt" required><br>
|
| 39 |
+
|
| 40 |
+
<label for="seed">Seed:</label>
|
| 41 |
+
<input type="number" id="seed" name="seed" min="0" max="3999999999" value="1"><br>
|
| 42 |
+
|
| 43 |
+
<button type="submit" id="generate-button">Generate Image</button>
|
| 44 |
+
</form>
|
| 45 |
+
|
| 46 |
+
<div id="result">
|
| 47 |
+
<h2>Generated Image:</h2>
|
| 48 |
+
<img id="generated-image" src="" alt="Generated Image">
|
| 49 |
+
<a id="download-button" href="#" download style="display:none;">Download Image</a>
|
| 50 |
+
<p id="error-message" style="color:red;"></p>
|
| 51 |
+
</div>
|
| 52 |
+
|
| 53 |
+
<script>
|
| 54 |
+
$(document).ready(function() {
|
| 55 |
+
$('#generate-form').on('submit', function(event) {
|
| 56 |
+
event.preventDefault();
|
| 57 |
+
|
| 58 |
+
const model = $('#model').val();
|
| 59 |
+
const prompt = $('#prompt').val();
|
| 60 |
+
const seed = $('#seed').val();
|
| 61 |
+
|
| 62 |
+
// Clear previous results
|
| 63 |
+
$('#error-message').text('');
|
| 64 |
+
$('#generated-image').hide();
|
| 65 |
+
$('#download-button').hide();
|
| 66 |
+
|
| 67 |
+
$.ajax({
|
| 68 |
+
url: '/generate_image',
|
| 69 |
+
method: 'POST',
|
| 70 |
+
contentType: 'application/json',
|
| 71 |
+
data: JSON.stringify({ model, prompt, seed }),
|
| 72 |
+
success: function(response) {
|
| 73 |
+
$('#generated-image').attr('src', response.image_path).show();
|
| 74 |
+
$('#download-button').attr('href', response.image_path).show();
|
| 75 |
+
},
|
| 76 |
+
error: function(jqXHR) {
|
| 77 |
+
const errorMessage = jqXHR.responseJSON?.error || 'An error occurred while generating the image.';
|
| 78 |
+
$('#error-message').text(errorMessage);
|
| 79 |
+
}
|
| 80 |
+
});
|
| 81 |
+
});
|
| 82 |
+
});
|
| 83 |
+
</script>
|
| 84 |
+
</body>
|
| 85 |
</html>
|