summaryrefslogtreecommitdiff
path: root/app/relay
diff options
context:
space:
mode:
Diffstat (limited to 'app/relay')
-rw-r--r--app/relay/modules/pix2pixhd.js1
-rw-r--r--app/relay/queue.js3
-rw-r--r--app/relay/runner.js19
3 files changed, 19 insertions, 4 deletions
diff --git a/app/relay/modules/pix2pixhd.js b/app/relay/modules/pix2pixhd.js
index ebfebf2..42c88d6 100644
--- a/app/relay/modules/pix2pixhd.js
+++ b/app/relay/modules/pix2pixhd.js
@@ -120,6 +120,7 @@ const live = {
'--just-copy', '--poll_delay', opt.poll_delay || 0.09,
'--which_epoch', 'latest',
'--norm', 'batch',
+ '--store_b', // comment this line to store all live output
]
},
listen: (task, res, i) => {
diff --git a/app/relay/queue.js b/app/relay/queue.js
index 8cd6f61..5e5a8a6 100644
--- a/app/relay/queue.js
+++ b/app/relay/queue.js
@@ -32,6 +32,9 @@ export class Queue {
remove_task(task){
this.a = this.a.filter(t => t.id !== task.id)
}
+ add_next_task(){
+ return this.a.unshift()
+ }
get_next_task(){
return this.a.shift()
}
diff --git a/app/relay/runner.js b/app/relay/runner.js
index 994dcd4..dbfcb4b 100644
--- a/app/relay/runner.js
+++ b/app/relay/runner.js
@@ -299,7 +299,8 @@ export function run_task(task, preempt=false, watch=false){
if (! task) return null
const module = modules[task.module]
if (! module) return { type: 'error', error: "No such module: " + task.module }
- const activity = module.activities[task.activity]
+ const activity = task.activity_object || module.activities[task.activity]
+ delete task.activity_object
if (! activity) return { type: 'error', error: 'No such activity in module: ' + task.module + ' ' + task.activity }
return run_task_with_activity(task, module, activity, preempt, watch)
}
@@ -314,7 +315,7 @@ export function run_task_with_activity(task, module, activity, preempt=false, wa
terminate(state.current_gpu_task)
} else {
console.log('already running GPU task :(', state.current_gpu_task.pid)
- return { type: 'error', preempt: false, error: 'task already running on gpu' }
+ return { type: 'error', busy: true, preempt: false, error: 'task already running on gpu' }
}
} else if (!interpreter.gpu && state.current_cpu_task.status !== 'IDLE') {
if (preempt) {
@@ -322,7 +323,7 @@ export function run_task_with_activity(task, module, activity, preempt=false, wa
terminate(state.current_cpu_task)
} else {
console.log('already running CPU task :(')
- return { type: 'error', preempt: false, error: 'task already running on cpu' }
+ return { type: 'error', busy: true, preempt: false, error: 'task already running on cpu' }
}
}
@@ -405,7 +406,17 @@ export function run_task_with_activity(task, module, activity, preempt=false, wa
if (task.success && activity.after) {
if (activity.after in modules[task.module].activities) {
const after_activity = modules[task.module].activities[activity.after]
- return run_task_with_activity(task, module, after_activity, preempt, watch)
+ const task_result = run_task_with_activity(task, module, after_activity, preempt, watch)
+ if (task_result.busy) {
+ task.activity_object = after_activity
+ const interpreter = interpreters[activity.type]
+ if (interpreter.gpu) {
+ q.gpu.add_next_task(task)
+ } else {
+ q.cpu.add_next_task(task)
+ }
+ }
+ return task_result
} else {
console.warn('no such after activity:', task.module, activity.after)
}