Spaces:
Sleeping
Sleeping
update
Browse files- static/images/spinner.svg +1 -0
- static/index.html +1 -0
- static/script.js +10 -2
- static/style.css +5 -2
static/images/spinner.svg
ADDED
static/index.html
CHANGED
@@ -24,6 +24,7 @@
|
|
24 |
<div class="output">
|
25 |
<div id="image-container">
|
26 |
<img src="images/placeholder.png" id="placeholder" />
|
|
|
27 |
</div>
|
28 |
</div>
|
29 |
</div>
|
|
|
24 |
<div class="output">
|
25 |
<div id="image-container">
|
26 |
<img src="images/placeholder.png" id="placeholder" />
|
27 |
+
<img src="images/spinner.svg" id="spinner" style="display: none;" />
|
28 |
</div>
|
29 |
</div>
|
30 |
</div>
|
static/script.js
CHANGED
@@ -3,6 +3,10 @@ const textGenInput = document.getElementById('text-gen-input');
|
|
3 |
const inferenceSteps = document.getElementById('inference_steps');
|
4 |
const model = document.getElementById('model');
|
5 |
const textGenSubmit = document.getElementById('text-gen-submit');
|
|
|
|
|
|
|
|
|
6 |
|
7 |
[textGenInput, inferenceSteps, model].forEach(item => {
|
8 |
item.addEventListener('blur', async (event) => {
|
@@ -29,20 +33,24 @@ textGenForm.addEventListener('submit', async (event) => {
|
|
29 |
event.preventDefault();
|
30 |
|
31 |
try {
|
|
|
|
|
|
|
|
|
32 |
const resp = await generateImage(textGenInput.value, inferenceSteps.value, model.value);
|
33 |
const path = "/" + resp;
|
34 |
|
35 |
var resultsContainer = document.getElementById('image-container');
|
36 |
|
37 |
-
const element = document.getElementById("placeholder");
|
38 |
-
element.remove();
|
39 |
|
40 |
var truepicDisplay = document.createElement('truepic-display');
|
|
|
41 |
var truepic = document.createElement('img');
|
42 |
truepic.src = path;
|
43 |
|
44 |
truepicDisplay.appendChild(truepic);
|
45 |
|
|
|
46 |
resultsContainer.appendChild(truepicDisplay);
|
47 |
} catch (err) {
|
48 |
console.error(err);
|
|
|
3 |
const inferenceSteps = document.getElementById('inference_steps');
|
4 |
const model = document.getElementById('model');
|
5 |
const textGenSubmit = document.getElementById('text-gen-submit');
|
6 |
+
const spinner = document.getElementById('spinner');
|
7 |
+
const placeholder = document.getElementById('placeholder');
|
8 |
+
|
9 |
+
|
10 |
|
11 |
[textGenInput, inferenceSteps, model].forEach(item => {
|
12 |
item.addEventListener('blur', async (event) => {
|
|
|
33 |
event.preventDefault();
|
34 |
|
35 |
try {
|
36 |
+
placeholder.remove();
|
37 |
+
document.getElementById('result').remove();
|
38 |
+
spinner.style.display = "block";
|
39 |
+
|
40 |
const resp = await generateImage(textGenInput.value, inferenceSteps.value, model.value);
|
41 |
const path = "/" + resp;
|
42 |
|
43 |
var resultsContainer = document.getElementById('image-container');
|
44 |
|
|
|
|
|
45 |
|
46 |
var truepicDisplay = document.createElement('truepic-display');
|
47 |
+
truepicDisplay.setAttribute("id", "result");
|
48 |
var truepic = document.createElement('img');
|
49 |
truepic.src = path;
|
50 |
|
51 |
truepicDisplay.appendChild(truepic);
|
52 |
|
53 |
+
spinner.style.display = "none";
|
54 |
resultsContainer.appendChild(truepicDisplay);
|
55 |
} catch (err) {
|
56 |
console.error(err);
|
static/style.css
CHANGED
@@ -65,7 +65,7 @@ select, textarea {
|
|
65 |
justify-content: center;
|
66 |
}
|
67 |
|
68 |
-
.output #image-container #placeholder {
|
69 |
width: 48px;
|
70 |
height: 48px;
|
71 |
align-self: center;
|
@@ -83,4 +83,7 @@ select, textarea {
|
|
83 |
|
84 |
#text-gen-submit.active {
|
85 |
background: rgba(26, 109, 255, 1);
|
86 |
-
}
|
|
|
|
|
|
|
|
65 |
justify-content: center;
|
66 |
}
|
67 |
|
68 |
+
.output #image-container #placeholder, .output #image-container #spinner {
|
69 |
width: 48px;
|
70 |
height: 48px;
|
71 |
align-self: center;
|
|
|
83 |
|
84 |
#text-gen-submit.active {
|
85 |
background: rgba(26, 109, 255, 1);
|
86 |
+
}
|
87 |
+
|
88 |
+
|
89 |
+
/* Spinner */
|