|
@@ -32,6 +32,29 @@
|
|
|
export default {
|
|
|
name: "cropped-image",
|
|
|
props: ['labels', 'file', 'box'],
|
|
|
+ created: function () {
|
|
|
+ // get data
|
|
|
+ this.getJobs();
|
|
|
+
|
|
|
+ // subscribe to changes
|
|
|
+ this.$root.socket.on('connect', this.getJobs);
|
|
|
+ this.$root.socket.on('create-job', this.addJob);
|
|
|
+ this.$root.socket.on('remove-job', this.removeJob);
|
|
|
+ this.$root.socket.on('edit-job', this.editJob);
|
|
|
+ },
|
|
|
+ destroyed: function () {
|
|
|
+ this.$root.socket.off('connect', this.getJobs);
|
|
|
+ this.$root.socket.off('create-job', this.addJob);
|
|
|
+ this.$root.socket.off('remove-job', this.removeJob);
|
|
|
+ this.$root.socket.off('edit-job', this.editJob);
|
|
|
+ },
|
|
|
+ data: function () {
|
|
|
+ return {
|
|
|
+ jobs: [],
|
|
|
+ labelSelector: false,
|
|
|
+ model: null
|
|
|
+ }
|
|
|
+ },
|
|
|
computed: {
|
|
|
src: function () {
|
|
|
if (!this.box)
|
|
@@ -57,9 +80,43 @@ export default {
|
|
|
return label.name;
|
|
|
|
|
|
return 'Not found';
|
|
|
+ },
|
|
|
+ isPredictionRunning: function () {
|
|
|
+ return this.jobs.filter(j => !j.finished && j.type === 'Model Interaction').length > 0;
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ getJobs: function () {
|
|
|
+ this.$root.socket.get('/jobs')
|
|
|
+ .then(response => response.json())
|
|
|
+ .then(jobs => {
|
|
|
+ this.jobs = [];
|
|
|
+ jobs.forEach(this.addJob)
|
|
|
+ });
|
|
|
+ },
|
|
|
+ addJob: function (job) {
|
|
|
+ for (let j of this.jobs)
|
|
|
+ if (j.identifier === job.identifier)
|
|
|
+ return;
|
|
|
+
|
|
|
+ this.jobs.push(job);
|
|
|
+ },
|
|
|
+ removeJob: function (job) {
|
|
|
+ for (let i = 0; i < this.jobs.length; i++) {
|
|
|
+ if (this.jobs[i].identifier === job.identifier) {
|
|
|
+ this.jobs.splice(i, 1);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ editJob: function (job) {
|
|
|
+ for (let i = 0; i < this.jobs.length; i++) {
|
|
|
+ if (this.jobs[i].identifier === job.identifier) {
|
|
|
+ this.$set(this.jobs, i, job);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
predict_cropped_image: function () {
|
|
|
// This shouldn't happen, since the icon is only shown if a bounding box
|
|
|
// was selected.
|
|
@@ -68,7 +125,6 @@ export default {
|
|
|
|
|
|
if (!this.isPredictionRunning) {
|
|
|
// TODO then / error
|
|
|
- // this should become this.box.identifier...
|
|
|
this.$root.socket.post(`/data/${this.file.identifier}/${this.box.identifier}/predict_bounding_box`, {
|
|
|
predict: true
|
|
|
});
|