module: shapes.models

class shapes.models.MaterialShape(*args, **kwargs)

Bases: shapes.models.Shape

Complex polygon containing a single material. This is created after a SubmittedShape has been triangulated.

DEFAULT_FILTERS = {'synthetic': False, 'photo__nonperspective': False, 'photo__rotated': False, 'photo__scene_category_correct_score__isnull': False, 'photo__inappropriate': False, 'photo__stylized': False, 'photo__scene_category_correct': True, 'pixel_area__gt': 4096, 'invalid': False, 'correct': True}

Default filters for views

bsdf_wd

Best reflectance for this shape

bsdfs_mf
bsdfs_wd
get_absolute_url(*moreargs, **morekwargs)
get_planar_method_display(*moreargs, **morekwargs)
get_quality_method_display(*moreargs, **morekwargs)
get_thumb_template()
has_substance()
image_bbox

Just like the FileDescriptor, but for ImageFields. The only difference is assigning the width/height to the width_field/height_field, if appropriate.

image_crop

Just like the FileDescriptor, but for ImageFields. The only difference is assigning the width/height to the width_field/height_field, if appropriate.

image_pbox

Just like the FileDescriptor, but for ImageFields. The only difference is assigning the width/height to the width_field/height_field, if appropriate.

mturk_assignment
name

majority vote name

name_entropy = None

disagreement about name

name_score = None

CUBAM score for name

names
num_bad_votes()

mturk votes that the shape is a bad segmentation

num_material_votes()

mturk votes that the shape is a good material segmentation

num_nonplanar_votes()
num_planar_votes()
num_planarity_votes()
num_votes()

mturk vote count

photo
planarities
qualities
rectified_normal

Best rectified normal for this shape

rectified_normals
save(*args, **kwargs)
shapename_set
shapesubstance_set
submitted_shapes

the submitted shapes that contain this shape

substance

majority vote substance

substance_entropy = None

disagreement about substance

substance_score = None

CUBAM score for substance

substances
update_entropy(save=True)

Update best label for each type of data

user
votes_dict()

mturk votes as a python dictionary

class shapes.models.MaterialShapeLabelBase(*args, **kwargs)

Bases: common.models.ResultBase

Abstract parent for labels attached to material shapes

class Meta
abstract = False
ordering = ['shape', '-time_ms']
MaterialShapeLabelBase.admin_score = None

vote from admin -2: reject -1: can’t really tell what’s going on 0: un-voted 1: good, but missed something (not rotated) 2: correct 3: correct exemplar

MaterialShapeLabelBase.get_quality_method_display(*moreargs, **morekwargs)
MaterialShapeLabelBase.get_thumb_template()
MaterialShapeLabelBase.mturk_assignment
MaterialShapeLabelBase.publishable()
MaterialShapeLabelBase.user
class shapes.models.MaterialShapeNameLabel(*args, **kwargs)

Bases: shapes.models.MaterialShapeLabelBase

Object common name, e.g. “chair”, “door”

get_quality_method_display(*moreargs, **morekwargs)
get_thumb_overlay()
mturk_assignment
static mturk_submit(user, hit_contents, results, time_ms, time_active_ms, version, mturk_assignment=None, **kwargs)

Add new instances from a mturk HIT after the user clicks [submit]

name

Object name chosen for the shape

shape

Shape being labeled

user
class shapes.models.MaterialShapeQuality(*args, **kwargs)

Bases: shapes.models.MaterialShapeLabelBase

Vote on whether or not a shape is indeed a material or oject segmentation

get_quality_method_display(*moreargs, **morekwargs)
mturk_assignment
static mturk_submit(user, hit_contents, results, time_ms, time_active_ms, version, mturk_assignment=None, **kwargs)

Add new instances from a mturk HIT after the user clicks [submit]

shape
user
class shapes.models.Shape(*args, **kwargs)

Bases: common.models.ResultBase

Abstract parent describing a complex polygon. Shapes are represented as a bag of vertices, triangles, and line segments. Users submit instances of SubmittedShapes, which are then intersected and triangulated to form subclasses of Shape.

MIN_PIXEL_AREA = 4096

min size of a shape

MIN_PLANAR_AREA = 16384

min size of a shape for rectification

class Meta
abstract = False
ordering = ['-num_vertices', '-time_ms']
Shape.PLANAR_METHODS = (('A', 'admin'), ('C', 'CUBAM'), ('M', 'majority vote'))

method by which the planar field was set

Shape.area = None

Area in normalized units. To get the pixel area, multiply this by the total photo area.

Shape.area_pixels()
Shape.correct = None

if true, enough users voted this to be the correct type of segmentation

Shape.correct_score = None

further from 0: more confident in assignment of correct

Shape.get_entry_dict()

Return a dictionary of this model containing just the fields needed for javascript rendering.

Shape.get_planar_method_display(*moreargs, **morekwargs)
Shape.get_quality_method_display(*moreargs, **morekwargs)
Shape.has_fov()
Shape.image_bbox

bbox: photo cropped out to the bounding box of this shape

Shape.image_bbox_1024 = <imagekit.models.fields.ImageSpecField object at 0x49984d0>

bbox resized to fit in 1024x1024 (used by opengl widget in rectify task)

Shape.image_bbox_512 = <imagekit.models.fields.ImageSpecField object at 0x4998390>

bbox resized to fit in 512x512

Shape.image_crop

Photo masked by the shape and cropped to the bounding box, and then expanded to a square. The masked (excluded) region has pixels that are white with no opacity (ARGB value (0, 255, 255, 255)).

Shape.image_pbox

padded bounding box image. this is the bounding box, expanded by 25% on each side (as a fraction of the bbox width,height), and then the smaller dimension is expanded to as quare.

Shape.image_pbox_1024 = <imagekit.models.fields.ImageSpecField object at 0x4998950>
Shape.image_pbox_300 = <imagekit.models.fields.ImageSpecField object at 0x49986d0>
Shape.image_pbox_512 = <imagekit.models.fields.ImageSpecField object at 0x4998810>
Shape.image_pbox_height(width)

Returns the height of image_pbox_<width>

Shape.image_pbox_height_1024()
Shape.image_pbox_height_512()
Shape.image_square_300 = <imagekit.models.fields.ImageSpecField object at 0x49982d0>

square thumbnail with whitebackground

Shape.is_kitchen()
Shape.is_living_room()
Shape.label_pos_2_y_512()
Shape.label_pos_x = None

position to show a label (normalized coordinates)

Shape.label_pos_x_scaled()

Returns the label position normalized by height instead of width

Shape.mark_invalid(*args, **kwargs)
Shape.mturk_assignment
Shape.num_segments = None

num_segments should be equal to len(segments.split(‘,’))//2

Shape.num_triangles = None

num_triangles should be equal to len(triangles.split(‘,’))//3

Shape.num_vertices = None

num_vertices should be equal to len(points.split(‘,’))//2

Shape.pbox_svg_transform()
Shape.pbox_view_box()

Returns the padded box as the tuple (min_x, min_y, width, height)

Shape.pixel_area = None

Area in pixels

Shape.planar = None

if true, enough users voted this to be flat

Shape.planar_method_to_str = {'A': 'admin', 'C': 'CUBAM', 'M': 'majority vote'}
Shape.planar_score = None

CUBAM score for the planar field. further from 0: more confident in assignment of planar.

Shape.publishable()
Shape.render_full_complex_polygon_mask(width=None, height=None, inverted=False)

Returns a black-and-white PIL image (mode 1) the same size as the original photo (unless width and height are specified. Pixels inside the polygon are 1 and pixels outside are 0 (unless inverted=True).

Parameters:
  • width – width in pixels, or if None, use self.photo.orig_width.
  • height – width in pixels, or if None, use self.photo.orig_height.
  • inverted – if True, swap 0 and 1 in the output.
Shape.save(*args, **kwargs)
Shape.segments = None

Segments format: “p1,p2,p2,p3,...”, where p_i is an index into vertices, and p1-p2, p2-p3, ... are the line segments. The segments are unordered. Each line segment is two indices into points; all segments are listed together. This format allows easy embedding into javascript.

Shape.segments_svg_path()

Returns all line segments as SVG path data

Shape.synthetic = None

flag to separate out this shape

Shape.triangles = None

Triangles format: p1,p2,p3,p2,p3,p4..., where p_i is an index into vertices, and p1-p2-p3 is a triangle. Each triangle is three indices into points; all triangles are listed together. This format allows easy embedding into javascript.

Shape.triangles_svg_path()

Returns all triangles as SVG path data

Shape.user
Shape.vertices = None

Vertices format: x1,y1,x2,y2,x3,y3,... (coords are fractions of width/height) (this format allows easy embedding into javascript)

class shapes.models.ShapeName(*args, **kwargs)

Bases: common.models.EmptyModelBase

Object category, e.g. “Kettle”, “Cat”, ...

FAIL_NAMES = ('Not on list', 'More than one object', "I can't tell")

values of name that are considered “fail”

description = None

text description of this object category

fail = None

if True, this is actually a special failure case category

material_shape_count()
materialshape_set
materialshapenamelabel_set
name = None

name of the category, e.g. “Kettle”, “Cat”, ...

parent

(currently not used) an optional parent category, if caregories are arranged in a tree

representative_shape

a shape that can be shown as an example

save(*args, **kwargs)
shapename_set
substance_groups
class shapes.models.ShapePlanarityLabel(*args, **kwargs)

Bases: shapes.models.MaterialShapeLabelBase

Vote for whether or not a material shape is flat

get_quality_method_display(*moreargs, **morekwargs)
mturk_assignment
static mturk_submit(user, hit_contents, results, time_ms, time_active_ms, version, mturk_assignment=None, **kwargs)

Add new instances from a mturk HIT after the user clicks [submit]

shape
user
class shapes.models.ShapeSubstance(*args, **kwargs)

Bases: common.models.EmptyModelBase

Material category, e.g. “wood”, “brick”, ...

FAIL_NAMES = ('Not on list', 'More than one material', "I can't tell")

values of name that are considered “fail”

group
material_shape_count()
materialshape_set
parent
representative_shape
save(*args, **kwargs)
shapesubstance_set
shapesubstancelabel_set
class shapes.models.ShapeSubstanceGroup(*args, **kwargs)

Bases: common.models.EmptyModelBase

Grouping of substances; each substance group is assigned a list of names that can be used

names
substances
class shapes.models.ShapeSubstanceLabel(*args, **kwargs)

Bases: shapes.models.MaterialShapeLabelBase

Material common name, e.g. “Wood”, “Brick”

get_quality_method_display(*moreargs, **morekwargs)
get_thumb_overlay()
mturk_assignment
static mturk_submit(user, hit_contents, results, time_ms, time_active_ms, version, mturk_assignment=None, **kwargs)

Add new instances from a mturk HIT after the user clicks [submit]

shape
substance
user
class shapes.models.SubmittedShape(*args, **kwargs)

Bases: common.models.ResultBase

Simple polygon submitted by a user (described by a single closed poly-line, no holes)

SHAPE_TYPES = (('M', 'material'), ('O', 'object'))
get_quality_method_display(*moreargs, **morekwargs)
get_shape_type_display(*moreargs, **morekwargs)
get_thumb_template()
material_shapes
mturk_assignment
static mturk_submit(user, hit_contents, results, time_ms, time_active_ms, experiment, version, mturk_assignment=None, **kwargs)

Add new instances from a mturk HIT after the user clicks [submit]

photo
publishable()
shape_type_to_str = {'M': 'material', 'O': 'object'}
str_to_shape_type = {'material': 'M', 'object': 'O'}
user