diff --git a/agdss/settings/common.py b/agdss/settings/common.py index 7172878..bcbe164 100644 --- a/agdss/settings/common.py +++ b/agdss/settings/common.py @@ -57,7 +57,7 @@ TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [], + 'DIRS': [BASE_DIR + '/templates'], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ @@ -123,9 +123,15 @@ USE_TZ = False +#Login +LOGIN_REDIRECT_URL = '/webclient' + + + # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.9/howto/static-files/ STATIC_URL = '/static/' #STATIC_ROOT = "C:/Users/Sandeep/Dropbox/kumar-prec-ag" #STATIC_ROOT = "/home/sdcunha/Dropbox/kumar-prec-ag" + diff --git a/agdss/templates/registration/login.html b/agdss/templates/registration/login.html new file mode 100644 index 0000000..c27e7a1 --- /dev/null +++ b/agdss/templates/registration/login.html @@ -0,0 +1,14 @@ +{#% extends 'base.html' %#} + +{% block title %}Login{% endblock %} + +{% block content %} +

Login

+
+ {% csrf_token %} + {{ form.as_p }} + +
+{% endblock %} + +Register \ No newline at end of file diff --git a/agdss/templates/registration/logout.html b/agdss/templates/registration/logout.html new file mode 100644 index 0000000..b4a64ed --- /dev/null +++ b/agdss/templates/registration/logout.html @@ -0,0 +1,9 @@ +{#% extends 'base.html' %#} + +{% block title %}Logout{% endblock %} + +{% block content %} +

Logged out

+

You have been successfully logged out.

+

Log in again.

+{% endblock %} diff --git a/agdss/templates/registration/register.html b/agdss/templates/registration/register.html new file mode 100644 index 0000000..8eec918 --- /dev/null +++ b/agdss/templates/registration/register.html @@ -0,0 +1,12 @@ +{#% extends 'base.html' %#} + +{% block title %}Register{% endblock %} + +{% block content %} + +
+ {% csrf_token %} + {{ form.as_p }} + +
+{% endblock %} \ No newline at end of file diff --git a/agdss/urls.py b/agdss/urls.py index 467ac59..81fb60c 100644 --- a/agdss/urls.py +++ b/agdss/urls.py @@ -16,9 +16,25 @@ from django.conf.urls import include, url from django.contrib import admin +from django.views.generic.edit import CreateView +from django.contrib.auth.forms import UserCreationForm +from django.views.generic import RedirectView +from django.conf import settings urlpatterns = [ url(r'^grappelli/', include('grappelli.urls')), # grappelli URLS url(r'^webclient/', include('webclient.urls')), url(r'^admin/', admin.site.urls), + + url('^', include('django.contrib.auth.urls')), + + url('^register/', CreateView.as_view( + template_name='registration/register.html', + form_class=UserCreationForm, + success_url= '/login' + )), + url(r'^accounts/', include('django.contrib.auth.urls')), + + url(r'^$', RedirectView.as_view(url='/webclient/')), + ] diff --git a/image_ops/crop_images.py b/image_ops/crop_images.py index 1b554b2..f92c7e5 100644 --- a/image_ops/crop_images.py +++ b/image_ops/crop_images.py @@ -5,6 +5,12 @@ #import scipy import random + +NUM_WINDOW_ROWS = 4 +NUM_WINDOW_COLS = 4 +WINDOW_PADDING = 20 +NUM_LABELS_PER_WINDOW = 3 + def calculate_entropy_map(image, category): images = ImageLabel.objects.all().filter(categoryType=category) #aggregrate_array = numpy.full((241,386, len(images)), 255, dtype=numpy.uint8) @@ -38,8 +44,8 @@ def calculateEntropy(arr): return #[[scipy.stats.entropy(y) for y in x] for x in probArr] -def getImageWindow(image): - return getGeometricImageWindow(image) +def getImageWindow(image, user): + return getPaddedWindow(image, user) def getRandomImageWindow(image): retDict = {'width':300, 'height': 300} @@ -57,4 +63,22 @@ def getGeometricImageWindow(image): numLabels = len(ImageLabel.objects.all().filter(parentImage=image)) topLeft = topLeftArr[numLabels % len(topLeftArr)] windowDict['x'], windowDict['y'] = topLeft - return windowDict \ No newline at end of file + return windowDict + + +def getPaddedWindow(image, user): + #Crop out sidemost pixels + windowWidth = (image.width - 2* WINDOW_PADDING)/NUM_WINDOW_COLS + windowHeight = (image.height - 2* WINDOW_PADDING)/NUM_WINDOW_ROWS + windowDict = {'width': windowWidth, 'height': windowHeight, + 'padding': WINDOW_PADDING} + + for x in range(WINDOW_PADDING, image.width - WINDOW_PADDING, windowWidth): + for y in range(WINDOW_PADDING, image.height - WINDOW_PADDING, windowWidth): + labels = image.imagelabel_set.all().filter(imageWindow__x=x, imageWindow__y=y) + print labels + if len(labels) < NUM_LABELS_PER_WINDOW and all(label.labeler.user != user for label in labels): + windowDict['x'], windowDict['y'] = (x,y) + print windowDict + return windowDict + return None \ No newline at end of file diff --git a/webclient/migrations/0001_initial.py b/webclient/migrations/0001_initial.py index 4e459e1..69d7db3 100644 --- a/webclient/migrations/0001_initial.py +++ b/webclient/migrations/0001_initial.py @@ -1,14 +1,124 @@ # -*- coding: utf-8 -*- -# Generated by Django 1.9.7 on 2016-07-26 20:37 +# Generated by Django 1.9.6 on 2016-07-29 20:56 from __future__ import unicode_literals -from django.db import migrations +import datetime +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion +import webclient.models class Migration(migrations.Migration): + initial = True + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] operations = [ + migrations.CreateModel( + name='CategoryType', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('category_name', models.CharField(default='unknown', max_length=100, unique=True)), + ('pub_date', models.DateTimeField(blank=True, default=datetime.datetime.now)), + ], + ), + migrations.CreateModel( + name='Image', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=200)), + ('path', models.CharField(max_length=500)), + ('description', models.CharField(max_length=500)), + ('pub_date', models.DateTimeField(blank=True, default=datetime.datetime.now)), + ('width', models.PositiveSmallIntegerField(default=1920)), + ('height', models.PositiveSmallIntegerField(default=1080)), + ('categoryType', models.ManyToManyField(to='webclient.CategoryType')), + ], + ), + migrations.CreateModel( + name='ImageFilter', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('brightness', models.DecimalField(decimal_places=1, default=1, max_digits=3)), + ('contrast', models.DecimalField(decimal_places=1, default=1, max_digits=3)), + ('saturation', models.DecimalField(decimal_places=1, default=1, max_digits=3)), + ], + ), + migrations.CreateModel( + name='ImageLabel', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('labelShapes', models.TextField(max_length=10000)), + ('pub_date', models.DateTimeField(blank=True, default=datetime.datetime.now)), + ('ip_address', models.GenericIPAddressField(blank=True, default=None, null=True)), + ('categoryType', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='webclient.CategoryType')), + ], + ), + migrations.CreateModel( + name='ImageSourceType', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('description', models.CharField(default='unknown', max_length=200, unique=True)), + ('pub_date', models.DateTimeField(blank=True, default=datetime.datetime.now)), + ], + ), + migrations.CreateModel( + name='ImageWindow', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('x', models.PositiveSmallIntegerField()), + ('y', models.PositiveSmallIntegerField()), + ('width', models.PositiveSmallIntegerField()), + ('height', models.PositiveSmallIntegerField()), + ], + ), + migrations.CreateModel( + name='Labeler', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ], + ), + migrations.AlterUniqueTogether( + name='imagewindow', + unique_together=set([('x', 'y', 'width', 'height')]), + ), + migrations.AddField( + model_name='imagelabel', + name='imageWindow', + field=models.ForeignKey(default=webclient.models.getDefaultImageWindowId, on_delete=django.db.models.deletion.CASCADE, to='webclient.ImageWindow'), + ), + migrations.AddField( + model_name='imagelabel', + name='labeler', + field=models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.CASCADE, to='webclient.Labeler'), + ), + migrations.AddField( + model_name='imagelabel', + name='parentImage', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='webclient.Image'), + ), + migrations.AddField( + model_name='imagefilter', + name='imageLabel', + field=models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.CASCADE, to='webclient.ImageLabel'), + ), + migrations.AddField( + model_name='imagefilter', + name='labeler', + field=models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.CASCADE, to='webclient.Labeler'), + ), + migrations.AddField( + model_name='image', + name='source', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='webclient.ImageSourceType'), + ), + migrations.AlterUniqueTogether( + name='image', + unique_together=set([('name', 'path')]), + ), ] diff --git a/webclient/migrations/0002_auto_20160726_2037.py b/webclient/migrations/0002_auto_20160726_2037.py deleted file mode 100644 index b9bedcf..0000000 --- a/webclient/migrations/0002_auto_20160726_2037.py +++ /dev/null @@ -1,125 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.9.7 on 2016-07-26 20:37 -from __future__ import unicode_literals - -import datetime -from django.conf import settings -from django.db import migrations, models -import django.db.models.deletion -import webclient.models - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('webclient', '0001_initial'), - ] - - operations = [ - migrations.CreateModel( - name='CategoryType', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('category_name', models.CharField(default='unknown', max_length=100, unique=True)), - ('pub_date', models.DateTimeField(blank=True, default=datetime.datetime.now)), - ], - ), - migrations.CreateModel( - name='Image', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=200)), - ('path', models.CharField(max_length=500)), - ('description', models.CharField(max_length=500)), - ('pub_date', models.DateTimeField(blank=True, default=datetime.datetime.now)), - ('width', models.PositiveSmallIntegerField(default=1920)), - ('height', models.PositiveSmallIntegerField(default=1080)), - ('categoryType', models.ManyToManyField(to='webclient.CategoryType')), - ], - ), - migrations.CreateModel( - name='ImageFilter', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('brightness', models.DecimalField(decimal_places=1, default=1, max_digits=3)), - ('contrast', models.DecimalField(decimal_places=1, default=1, max_digits=3)), - ('saturation', models.DecimalField(decimal_places=1, default=1, max_digits=3)), - ], - ), - migrations.CreateModel( - name='ImageLabel', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('labelShapes', models.TextField(max_length=10000)), - ('pub_date', models.DateTimeField(blank=True, default=datetime.datetime.now)), - ('ip_address', models.GenericIPAddressField(blank=True, default=None, null=True)), - ('categoryType', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='webclient.CategoryType')), - ], - ), - migrations.CreateModel( - name='ImageSourceType', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('description', models.CharField(default='unknown', max_length=200, unique=True)), - ('pub_date', models.DateTimeField(blank=True, default=datetime.datetime.now)), - ], - ), - migrations.CreateModel( - name='ImageWindow', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('x', models.PositiveSmallIntegerField()), - ('y', models.PositiveSmallIntegerField()), - ('width', models.PositiveSmallIntegerField()), - ('height', models.PositiveSmallIntegerField()), - ], - ), - migrations.CreateModel( - name='Labeler', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), - ], - ), - migrations.AlterUniqueTogether( - name='imagewindow', - unique_together=set([('x', 'y', 'width', 'height')]), - ), - migrations.AddField( - model_name='imagelabel', - name='imageWindow', - field=models.ForeignKey(default=webclient.models.getDefaultImageWindowId, on_delete=django.db.models.deletion.CASCADE, to='webclient.ImageWindow'), - ), - migrations.AddField( - model_name='imagelabel', - name='labeler', - field=models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.CASCADE, to='webclient.Labeler'), - ), - migrations.AddField( - model_name='imagelabel', - name='parentImage', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='webclient.Image'), - ), - migrations.AddField( - model_name='imagefilter', - name='imageLabel', - field=models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.CASCADE, to='webclient.ImageLabel'), - ), - migrations.AddField( - model_name='imagefilter', - name='labeler', - field=models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.CASCADE, to='webclient.Labeler'), - ), - migrations.AddField( - model_name='image', - name='source', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='webclient.ImageSourceType'), - ), - migrations.AlterUniqueTogether( - name='image', - unique_together=set([('name', 'path')]), - ), - ] diff --git a/webclient/models.py b/webclient/models.py index fc6f090..6e100a3 100644 --- a/webclient/models.py +++ b/webclient/models.py @@ -43,7 +43,7 @@ class Labeler(models.Model): user = models.OneToOneField(User) def __unicode__(self): - return 'labeler' + return str(self.user) class ImageWindow(models.Model): x = models.PositiveSmallIntegerField() y = models.PositiveSmallIntegerField() @@ -72,7 +72,7 @@ class ImageLabel(models.Model): pub_date = models.DateTimeField(default=datetime.now, blank=True) labeler = models.ForeignKey(Labeler, on_delete=models.CASCADE, null=True, blank=True, default=None) imageWindow = models.ForeignKey(ImageWindow, on_delete=models.CASCADE, default=getDefaultImageWindowId) - ip_address = models.GenericIPAddressField(default=None, blank=True, null=True) + #ip_address = models.GenericIPAddressField(default=None, blank=True, null=True) def __unicode__(self): return 'Image: ' + self.parentImage.name + ' | Category: ' + self.categoryType.category_name diff --git a/webclient/static/css/style.css b/webclient/static/css/style.css index d6da16b..e63ed43 100644 --- a/webclient/static/css/style.css +++ b/webclient/static/css/style.css @@ -21,11 +21,22 @@ button #next { div #canvasDiv { } +div #canvasWrapper { + + /* border: 20px inset rgba(0,0,0, 0.5);*/ + width: 1920px; + height: 1080px; +} + #canvas { border: 3px solid black; + /*box-shadow: inset 0 0 20px 20px rgba(255,0,0,0.5); */ + + } + div #imageControlContainer { padding-top: 75%; diff --git a/webclient/templates/webclient/label.html b/webclient/templates/webclient/label.html index fe1c1c5..4a85443 100644 --- a/webclient/templates/webclient/label.html +++ b/webclient/templates/webclient/label.html @@ -219,8 +219,13 @@ imageY = response.subimage.y; imageWidth = response.subimage.width; imageHeight = response.subimage.height; + imagePadding = response.subimage.padding; + if(typeof padding == 'undefined') { + padding = 0; + } displayImage(response.image_name, response.path, response.categories, - new paper.Point(response.subimage.x,response.subimage.y), new paper.Size(imageWidth,imageHeight)); + new paper.Point(response.subimage.x,response.subimage.y), + imageWidth, imageHeight, imagePadding); currentImage = response }, @@ -230,8 +235,9 @@ }); } //TODO: Input validation and error checking - function displayImage(image_name, image_path, categories, point, size) { + function displayImage(image_name, image_path, categories, point, width, height, padding) { + size = new paper.Size(width + 2*padding, height + 2*padding); //Add new image and resize canvas to fit image img = new Image(); img.crossOrigin = "Anonymous"; @@ -245,11 +251,15 @@ function setup_images() { //paper.view.setViewSize(img.naturalWidth, img.naturalHeight); paper.view.setViewSize(size); - paper.view.getViewSize(); + //paper.view.getViewSize(); + $('#canvasWrapper').css('width', size.width).css('height', size.height) + //$('#canvas').css('box-shadow', " -20 -20 20px" + imagePadding + "px rgba(255,0,0,0.5)"); + point = new paper.Point(point.x - padding, point.y - padding); raster = new paper.Raster(img).getSubRaster(new paper.Rectangle(point, size)); raster.position = paper.view.center; paper.view.update(); - }; + + } if(img.complete) { setup_images(); }else { @@ -346,13 +356,15 @@
No labels in image + logout

- - +
+ +

diff --git a/webclient/urls.py b/webclient/urls.py index 59fe959..84802c9 100644 --- a/webclient/urls.py +++ b/webclient/urls.py @@ -5,7 +5,7 @@ urlpatterns = [ #Page URLs - url(r'^$', views.index, name='index'), + url(r'^$', views.index, name='label_index'), url(r'^label$', views.label, name='label'), url(r'^results$', views.results, name='results'), url(r'^view_label$', views.view_label, name='view_label'), @@ -13,7 +13,7 @@ #GET/POST URLs url(r'^applyLabels$', 'webclient.views.applyLabels'), url(r'^loadLabels$', 'webclient.views.loadLabels'), - url(r'^purge$', 'webclient.views.purge'), + #url(r'^purge$', 'webclient.views.purge'), url(r'^addImage$', 'webclient.views.addImage'), url(r'^cleanUpAndFixImages$', 'webclient.views.cleanUpAndFixImages'), url(r'^updateImage$', 'webclient.views.updateImage'), diff --git a/webclient/views.py b/webclient/views.py index fc6fe0a..6903f38 100644 --- a/webclient/views.py +++ b/webclient/views.py @@ -2,7 +2,7 @@ import os.path from django.conf import settings -from django.core.exceptions import ValidationError +from django.core.exceptions import ValidationError, MultipleObjectsReturned from django.core.validators import URLValidator from django.db.models import Count from django.http import * @@ -10,25 +10,35 @@ from django.template import loader from django.views.decorators.csrf import csrf_exempt from django.views.decorators.http import require_POST, require_GET +from django.contrib.auth.decorators import login_required import urllib from cStringIO import StringIO +import sys import helper_ops from image_ops import crop_images from .models import * from PIL import Image as PILImage + +###### +#PAGES +###### + +@login_required def index(request): template = loader.get_template('webclient/index.html') context = {} return HttpResponse(template.render(context, request)) + +@login_required def view_label(request): template = loader.get_template('webclient/view_label.html') context = {} return HttpResponse(template.render(context, request)) - +@login_required def label(request): #latest_image_list = os.listdir('C:/Users/Sandeep/Dropbox/kumar-prec-ag/tag_images') # '/Users/jdas/Dropbox/Research/agriculture/agdss/image-store/') latest_image_list = Image.objects.all() @@ -42,12 +52,17 @@ def label(request): context = {} return HttpResponse(template.render(context, request)) - +@login_required def results(request): template = loader.get_template('webclient/results.html') context = {} return HttpResponse(template.render(context, request)) + +################## +#POST/GET REQUESTS +################## + @csrf_exempt def applyLabels(request): dict = json.load(request) @@ -57,7 +72,17 @@ def applyLabels(request): category_name = dict['category_name'] image_filters = dict['image_filters'] subimage = dict['subimage'] - + user = request.user + if not user.is_authenticated(): + return HttpResponseBadRequest("Requires logged in user") + try: + labeler = Labeler.objects.get(user=user) + except Labeler.DoesNotExist: + labeler = Labeler(user=user) + labeler.save() + except MultipleObjectsReturned: + print >> sys.stderr, "Multiple labelers for user object" + return sourceType = '' categoryType = '' parentImage_ = Image.objects.all().filter(name=image_name, path=path) @@ -83,11 +108,10 @@ def applyLabels(request): x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR') - if x_forwarded_for: - ipaddress = x_forwarded_for.split(',')[-1].strip() - else: - ipaddress = request.META.get('REMOTE_ADDR') - print subimage + # if x_forwarded_for: + # #ipaddress = x_forwarded_for.split(',')[-1].strip() + # else: + # #ipaddress = request.META.get('REMOTE_ADDR') imageWindowList = ImageWindow.objects.all().filter( x=subimage['x'], y=subimage['y'], width=subimage['width'], height=subimage['height']) if imageWindowList: @@ -99,7 +123,7 @@ def applyLabels(request): labelObject = ImageLabel(parentImage = parentImage_[0], labelShapes=label_list_, pub_date=datetime.now(),categoryType=categoryType, - ip_address=ipaddress, imageWindow=imageWindow) + labeler=labeler, imageWindow=imageWindow) labelObject.save() image_filter_obj = ImageFilter(brightness=image_filters['brightness'], contrast=image_filters['contrast'], @@ -180,11 +204,11 @@ def getInfo(request): @require_GET def getNewImage(request): - if not 'image_name' in request.GET or not 'path' in request.GET: - hasPrior = False - else: - hasPrior = True - #return HttpResponseBadRequest("Missing image name or path") + # if not 'image_name' in request.GET or not 'path' in request.GET: + # hasPrior = False + # else: + # hasPrior = True + # #return HttpResponseBadRequest("Missing image name or path") if len(Image.objects.all()) == 0: return HttpResponseBadRequest("No images in database") @@ -202,18 +226,27 @@ def getNewImage(request): #Least number of labels which was not just seen img = Image.objects.all() - if hasPrior and len(Image.objects.all()) > 1: - img = img.exclude(name=request.GET['image_name'], path=request.GET['path']) - img = img.annotate(count=Count('imagelabel')).order_by('count')[0] + # if hasPrior and len(Image.objects.all()) > 1: + # img = img.exclude(name=request.GET['image_name'], path=request.GET['path']) + labelsPerImage = crop_images.NUM_WINDOW_COLS * \ + crop_images.NUM_WINDOW_ROWS * crop_images.NUM_LABELS_PER_WINDOW + images = img.annotate(count=Count('imagelabel')) \ + .filter(count__lt=labelsPerImage).order_by('count').reverse() + subimage = None + for i in images: + subimage = crop_images.getImageWindow(i, request.user) + if subimage is not None: + img = i + break label_list = ImageLabel.objects.all().filter(parentImage=img).order_by('pub_date').last() response = { 'path': img.path, 'image_name': img.name, 'categories': [c.category_name for c in img.categoryType.all()], - 'subimage': crop_images.getImageWindow(img), + 'subimage': subimage, } if label_list: response['labels'] = label_list.labelShapes @@ -223,14 +256,14 @@ def getNewImage(request): return JsonResponse(response) -#TODO: Remove csrf_exempt -@csrf_exempt -def purge(request): - Image.objects.all().delete() - ImageLabel.objects.all().delete() - ImageSourceType.objects.all().delete() - CategoryType.objects.all().delete() - return HttpResponse("PURGED TABLES!") +# #TODO: Remove csrf_exempt +# @csrf_exempt +# def purge(request): +# Image.objects.all().delete() +# ImageLabel.objects.all().delete() +# ImageSourceType.objects.all().delete() +# CategoryType.objects.all().delete() +# return HttpResponse("PURGED TABLES!")