Skip to content

Commit

Permalink
Added dataset tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
jsbroks committed Apr 6, 2019
1 parent a85deb9 commit 5d8f99a
Show file tree
Hide file tree
Showing 16 changed files with 154 additions and 81 deletions.
37 changes: 8 additions & 29 deletions backend/database/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import os


class DatasetModel(DynamicDocument):

id = SequenceField(primary_key=True)
Expand Down Expand Up @@ -40,36 +41,14 @@ def save(self, *args, **kwargs):
self.owner = 'system'

return super(DatasetModel, self).save(*args, **kwargs)

def get_users(self):
from .users import UserModel

# def download_images(self, keywords, limit=100):

# task = TaskModel(
# name="Downloading {} images to {} with keywords {}".format(limit, self.name, keywords),
# dataset_id=self.id,
# group="Downloading Images"
# )

# def download_images(task, dataset, keywords, limit):
# def custom_print(string):
# __builtins__.print("%f -- %s" % (time.time(), string))

# print = dprint
# task.log()
# for keyword in args['keywords']:
# response = gid.googleimagesdownload()
# response.download({
# "keywords": keyword,
# "limit": args['limit'],
# "output_directory": output_dir,
# "no_numbering": True,
# "format": "jpg",
# "type": "photo",
# "print_urls": False,
# "print_paths": False,
# "print_size": False
# })

# return task
members = self.users
members.append(self.owner)

return UserModel.objects(username__in=members).exclude('password', 'id', 'preferences')

def import_coco(self, coco_json):

Expand Down
3 changes: 2 additions & 1 deletion backend/database/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ def can_edit(self, model):
return model.can_edit(self)

def _update_last_seen(self):
self.update(last_seen=datetime.datetime.now())
self.update(last_seen=datetime.datetime.utcnow())



__all__ = ["UserModel"]
1 change: 0 additions & 1 deletion backend/webserver/api/annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def post(self):
metadata = args.get('metadata', {})
segmentation = args.get('segmentation', [])
keypoints = args.get('keypoints', [])
color = args.get('color')

logger.info(f'{current_user.username} has created an annotation for image {image_id}')

Expand Down
1 change: 0 additions & 1 deletion backend/webserver/api/annotator.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from config import Config
from database import (
ImageModel,
DatasetModel,
CategoryModel,
AnnotationModel,
SessionEvent
Expand Down
16 changes: 16 additions & 0 deletions backend/webserver/api/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,22 @@ def post(self, dataset_id):
return {"success": True}


@api.route('/<int:dataset_id>/users')
class DatasetMembers(Resource):

@login_required
def get(self, dataset_id):
""" All users in the dataset """
args = dataset_generate.parse_args()

dataset = current_user.datasets.filter(id=dataset_id, deleted=False).first()
if dataset is None:
return {"message": "Invalid dataset id"}, 400

users = dataset.get_users()
return query_util.fix_ids(users)


@api.route('/<int:dataset_id>')
class DatasetId(Resource):
@login_required
Expand Down
1 change: 0 additions & 1 deletion backend/webserver/api/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from database import (
ImageModel,
DatasetModel,
CategoryModel,
AnnotationModel
)

Expand Down
2 changes: 1 addition & 1 deletion backend/webserver/api/undo.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from flask_restplus import Namespace, Resource, reqparse
from flask_login import login_required, current_user
from flask_login import login_required

import os
import shutil
Expand Down
1 change: 0 additions & 1 deletion backend/webserver/sockets.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def wrapped(*args, **kwargs):
@socketio.on('annotation')
@authenticated_only
def annotation(data):
image_id = data.get('image_id')
emit('annotation', data, broadcast=True)


Expand Down
2 changes: 0 additions & 2 deletions backend/webserver/watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
from database import ImageModel

import re
import time
import threading


class ImageFolderHandler(FileSystemEventHandler):
Expand Down
9 changes: 8 additions & 1 deletion client/src/components/Pagination.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="row justify-content-md-center bg-light">
<div class="row align-items-center justify-content-center bg-light">
<ul class="pagination text-center">
<li class="page-item" @click="previousPage">
<a class="page-link" aria-label="Previous">
Expand Down Expand Up @@ -92,3 +92,10 @@ export default {
}
};
</script>

<style>
.page {
display:block;
margin:0 auto;
}
</style>
2 changes: 1 addition & 1 deletion client/src/components/cards/ImageCard.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div class="col-md-3">
<div
class="card mb-4 box-shadow"
class="card mb-4 shadow-sm"
:class="{'border': annotated, 'border-danger': annotated}"
@mouseover="hover = true"
@mouseleave="hover = false"
Expand Down
Empty file.
Empty file.
2 changes: 1 addition & 1 deletion client/src/components/tasks/TaskGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div style="margin: 10px">
<div class="card">

<div class="card-header text-left" @click="showTasks = !showTasks">
<div class="card-header text-left" @click="showTasks = !showTasks">
{{ name }}

<span style="float: right; color: light-gray">
Expand Down
23 changes: 13 additions & 10 deletions client/src/models/datasets.js
Original file line number Diff line number Diff line change
@@ -1,52 +1,55 @@
import axios from "axios";

const baseURL = "/api/dataset/";
const baseURL = "/api/dataset";

export default {
allData(params) {
return axios.get(baseURL + "data", {
return axios.get(`${baseURL}/data`, {
params: {
...params
}
});
},
getData(id, params) {
return axios.get(baseURL + `${id}/data`, {
return axios.get(`${baseURL}/${id}/data`, {
params: {
...params
}
});
},
create(name, categories) {
return axios.post(baseURL + `?name=${name}`, {
return axios.post(`${baseURL}/?name=${name}`, {
categories: categories
});
},
generate(id, body) {
return axios.post(baseURL + `${id}/generate`, {
return axios.post(`${baseURL}/${id}/generate`, {
...body
});
},
scan(id) {
return axios.get(baseURL + `${id}/scan`);
return axios.get(`${baseURL}/${id}/scan`);
},
exportingCOCO(id) {
return axios.get(baseURL + `${id}/export`);
return axios.get(`${baseURL}/${id}/export`);
},
getCoco(id) {
return axios.get(baseURL + `${id}/coco`);
return axios.get(`${baseURL}/${id}/coco`);
},
uploadCoco(id, file) {
let form = new FormData();
form.append("coco", file);

return axios.post(baseURL + `${id}/coco`, form, {
return axios.post(`${baseURL}/${id}/coco`, form, {
headers: {
"Content-Type": "multipart/form-data"
}
});
},
export(id, format) {
return axios.get(baseURL + `${id}/${format}`);
return axios.get(`${baseURL}/${id}/${format}`);
},
getUsers(id) {
return axios.get(`${baseURL}/${id}/users`);
}
};
Loading

0 comments on commit 5d8f99a

Please sign in to comment.