Skip to content

Commit 584a446

Browse files
committed
Update StableDiffusion.vue
1 parent 06e3e1a commit 584a446

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

electron_app/src/StableDiffusion.vue

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
66
import { send_to_py } from "./py_vue_bridge.js"
77
import {get_tokens} from './clip_tokeniser/clip_encoder.js'
8+
const moment = require('moment')
89
910
let notification_sound = new Audio(require('@/assets/notification.mp3'))
1011
@@ -144,28 +145,27 @@ export default {
144145
this.generation_state_msg = iter_time/1000 + " s/it";
145146
this.times.push(iter_time);
146147
let median = this.times.sort((a, b) => a - b)[Math.floor(this.times.length / 2)];
147-
148-
let time_remaining = Math.floor(median*((100-p)*this.nb_its/100) / 1000);
149-
150-
let minutes = Math.floor(time_remaining / 60);
151-
let seconds = time_remaining - minutes * 60;
148+
let time_remaining = moment.duration(median*((100-p)*this.nb_its/100));
152149
153150
if(time_remaining > 1){
154-
this.remaining_times = `(${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')} left)`;
151+
if (time_remaining.hours() > 0) {
152+
this.remaining_times = `(${time_remaining.hours()}h${time_remaining.minutes()}m left)`;
153+
} else {
154+
this.remaining_times = `(${time_remaining.minutes()}m${time_remaining.seconds()}s left)`;
155+
}
155156
if (this.generation_loop) {
156157
clearInterval(this.generation_loop);
157158
}
158-
this.generation_loop = setInterval(() => {
159-
seconds--;
160-
if (seconds < 0) {
161-
seconds = 59;
162-
minutes--;
159+
this.generation_loop = setInterval(() => {
160+
time_remaining.subtract(1, 'seconds');
161+
if (time_remaining.hours() > 0) {
162+
this.remaining_times = `(${time_remaining.hours()}h${time_remaining.minutes()}m left)`;
163+
} else {
164+
this.remaining_times = `(${time_remaining.minutes()}m${time_remaining.seconds()}s left)`;
163165
}
164-
if (minutes == 0 && seconds == 0) {
166+
if (time_remaining < 1) {
165167
clearInterval(this.generation_loop);
166168
this.remaining_times = "";
167-
} else{
168-
this.remaining_times = `(${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')} left)`;
169169
}
170170
}, 1000);
171171
}

0 commit comments

Comments
 (0)