Skip to content

Commit

Permalink
Merge pull request #20 from paulu/ioerror
Browse files Browse the repository at this point in the history
2 bug fixes: MTURK_CONFIGURE_QUALIFICATIONS and open_image(django file field)
  • Loading branch information
Sean Bell committed May 18, 2018
2 parents fe2bd17 + c93287d commit 1661706
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
3 changes: 3 additions & 0 deletions server/config/settings_local_template.py
Expand Up @@ -85,6 +85,9 @@
# debugging the POST submission.
MTURK_ACCEPT_SANDBOX_HITS = False

# If True, automatically grant MTurk qualifications
MTURK_CONFIGURE_QUALIFICATIONS = False

# AWS MTurk keys
if MTURK_SANDBOX:
# Sandbox account
Expand Down
3 changes: 2 additions & 1 deletion server/normals/utils.py
Expand Up @@ -121,7 +121,8 @@ def transform(H, points):
M_ij_to_pq = linalg.inv(M_pq_to_ij)
M_ij_to_pq /= M_ij_to_pq[2, 2] # NORMALIZE!
data = M_ij_to_pq.ravel().tolist()[0]
image = open_image(shape.photo.image_orig)
photo = shape.photo.__class__.objects.get(id=shape.photo.id)
image = open_image(photo.image_orig)
rectified = image.transform(size=size, method=Image.PERSPECTIVE,
data=data, resample=Image.BICUBIC)

Expand Down
Expand Up @@ -20,7 +20,8 @@ def handle(self, *args, **options):

out = []
for label in progress.bar(qset):
pil = open_image(label.photo.image_300)
photo = label.photo.__class__.objects.get(id=label.photo.id)
pil = open_image(photo.image_300)
points_list = label.points.split(',')
for idx in xrange(label.num_points):
x = float(points_list[idx * 2]) * pil.size[0]
Expand Down
5 changes: 3 additions & 2 deletions server/shapes/tasks.py
Expand Up @@ -19,9 +19,10 @@
@shared_task
def fill_in_bbox_task(shape):
""" Helper to fill in the potentially empty image_bbox field """

.
photo = shape.photo.__class__.objects.get(id=shape.photo.id)
image_bbox = mask_complex_polygon(
image=open_image(shape.photo.image_orig),
image=open_image(photo.image_orig),
vertices=shape.vertices,
triangles=shape.triangles,
bbox_only=True)
Expand Down
9 changes: 6 additions & 3 deletions server/shapes/utils.py
Expand Up @@ -409,8 +409,9 @@ def update_shape_image_crop(shape, save=True):
""" Update the cropped image for a shape """

# compute masked image
photo = shape.photo.__class__.objects.get(id=shape.photo.id)
image_crop, image_bbox = mask_complex_polygon(
image=open_image(shape.photo.image_orig),
image=open_image(photo.image_orig),
vertices=shape.vertices,
triangles=shape.triangles)

Expand All @@ -426,7 +427,8 @@ def update_shape_image_pbox(shape, padding=0.25, save=True):
""" Update the pbox image for a shape """

# load image
image = open_image(shape.photo.image_orig)
photo = shape.photo.__class__.objects.get(id=shape.photo.id)
image = open_image(photo.image_orig)
w, h = image.size

# compute bbox
Expand Down Expand Up @@ -677,7 +679,8 @@ def create_shape_image_sample(shape, sample_width=256, sample_height=256):
if ShapeImageSample.objects.filter(shape=shape).exists():
return

image = open_image(shape.photo.image_2048)
photo = shape.photo.__class__.objects.get(id=shape.photo.id)
image = open_image(photo.image_2048)
image_width, image_height = image.size

triangles = parse_triangles(shape.triangles)
Expand Down

0 comments on commit 1661706

Please sign in to comment.