def admin_pending_content(request, experiment_slug='all', filter_key='scheduled', template='mturk/admin/pending_content_base.html', extra_context=None): if filter_key not in PENDING_CONTENT_FILTERS_LIST: raise Http404 categories = admin_pending_content_categories() filters = [] for key in PENDING_CONTENT_FILTERS_LIST: count = 0 for cat in categories[key]: if cat['slug'] == experiment_slug: count = cat['count'] break else: count = categories[key][0]['count'] filters.append( dict_union({ 'key': key, 'count': count }, PENDING_CONTENT_FILTERS[key])) entries = pending_content_entries(experiment_slug, filter_key) \ .order_by('num_outputs_completed', '-priority') return render( request, template, dict_union( { 'nav': 'mturk-admin', 'subnav': 'pending-content', 'filters': filters, 'filter_key': filter_key, 'categories': categories[filter_key], 'category_slug': experiment_slug, 'entries': entries, 'entries_per_page': 30, 'span': 'span3', 'rowsize': '3', 'thumb_template_extra': 'mturk/admin/pending_content_thumb_extra.html', }, extra_context))
def admin_feedback(request, experiment_slug='all', template="mturk/admin/feedback.html", extra_context=None): assignments = MtAssignment.objects.filter(has_feedback=True) if experiment_slug != 'all': assignments = assignments.filter( hit__hit_type__experiment__slug=experiment_slug) if 'worker_id' in request.GET: assignments = assignments.filter( worker__mturk_worker_id=request.GET['worker_id']) entries = assignments \ .defer('post_data', 'post_meta') \ .select_related('worker', 'hit__hit_type', 'hit__hit_type__experiment') \ .order_by('-added') return render(request, template, dict_union({ 'nav': 'mturk-admin', 'subnav': 'feedback', 'categories': admin_feedback_categories(), 'category_slug': experiment_slug, 'entries': entries, 'entries_per_page': 30, 'span': 'span9', 'thumb_template': 'mturk/admin/feedback_entry.html', }, extra_context))
def rectified_normal_best(request, template='endless_list.html', extra_context=None): entries = ShapeRectifiedNormalLabel.objects \ .filter(shape__photo__inappropriate=False, shape__correct=True, shape__planar=True, shape__rectified_normal_id=F('id')) \ if 'by-id' in request.GET: header_small = 'sorted by id' entries = entries.order_by('-id') else: header_small = 'sorted by complexity' entries = entries.order_by('-shape__num_vertices') if 'publishable' in request.GET: entries = entries.filter(shape__photo__license__publishable=True) context = dict_union({ 'nav': 'browse/rectified-normal', 'subnav': 'best', 'entries': entries, 'base_template': 'rectified_normal_base.html', 'thumb_template': 'rectified_normal_thumb.html', 'header': 'High quality submissions', 'header_small': header_small, }, extra_context) return render(request, template, context)
def admin_feedback(request, experiment_slug='all', template="mturk/admin/feedback.html", extra_context=None): assignments = MtAssignment.objects.filter(has_feedback=True) if experiment_slug != 'all': assignments = assignments.filter( hit__hit_type__experiment__slug=experiment_slug) if 'worker_id' in request.GET: assignments = assignments.filter( worker__mturk_worker_id=request.GET['worker_id']) entries = assignments \ .defer('post_data', 'post_meta') \ .select_related('worker', 'hit__hit_type', 'hit__hit_type__experiment') \ .order_by('-added') return render( request, template, dict_union( { 'nav': 'mturk-admin', 'subnav': 'feedback', 'categories': admin_feedback_categories(), 'category_slug': experiment_slug, 'entries': entries, 'entries_per_page': 30, 'span': 'span9', 'thumb_template': 'mturk/admin/feedback_entry.html', }, extra_context))
def bsdf_bad(request, v, template='endless_list.html', extra_context=None): if v not in BSDF_VERSIONS: raise Http404 entries = get_model('bsdfs', 'ShapeBsdfLabel_' + v).objects \ .filter(shape__photo__inappropriate=False, shape__photo__synthetic=False) \ .exclude(color_correct=True) \ .exclude(gloss_correct=True) \ .extra( select={'correct_score': 'color_correct_score + gloss_correct_score'}, order_by=('correct_score',) ) #.filter(time_ms__isnull=False, admin_score__lt=0, shape__synthetic=False) \ #.order_by('admin_score', '-shape__pixel_area') if 'publishable' in request.GET: entries = entries.filter(shape__photo__license__publishable=True) context = dict_union( { 'nav': 'browse/bsdf-%s' % v, 'subnav': 'bad', 'entries': entries, 'base_template': 'bsdf_base.html', 'thumb_template': 'bsdf_%s_shape_thumb.html' % v, 'header': 'Low quality submissions', 'header_small': 'sorted by quality', 'v': v, #'enable_voting': False, }, extra_context) return render(request, template, context)
def admin_example(request, experiment_slug='all', template='mturk/admin/example.html', extra_context=None): categories = admin_example_categories() entries = ExperimentExample.objects \ .filter(experiment__slug=experiment_slug) \ .prefetch_related('content') \ .order_by('-id') # hacky, I know if entries and hasattr(entries[0], 'shape_id'): entries = list(entries) entries.sort(key=lambda x: x.content.shape_id) return render( request, template, dict_union( { 'nav': 'mturk-admin', 'subnav': 'example', 'entries': entries, 'categories': categories, 'category_slug': experiment_slug, 'entries_per_page': 30, 'span': 'span3', 'rowsize': '3', 'thumb_template_extra': 'mturk/admin/example_thumb_extra.html' }, extra_context))
def rectified_normal_bad(request, template='endless_list.html', extra_context=None): entries = ShapeRectifiedNormalLabel.objects \ .filter(shape__planar=True, correct=False, correct_score__isnull=False) \ .order_by('correct_score') #.filter(admin_score__lt=0, shape__synthetic=False) \ #.order_by('admin_score', 'shape__num_vertices') if 'publishable' in request.GET: entries = entries.filter(shape__photo__license__publishable=True) context = dict_union( { 'nav': 'browse/rectified-normal', 'subnav': 'bad', 'entries': entries, 'base_template': 'rectified_normal_base.html', 'thumb_template': 'rectified_normal_thumb.html', 'header': 'Low quality submissions', 'header_small': 'sorted by quality', #'enable_voting': False, }, extra_context) return render(request, template, context)
def bsdf_all(request, v, template='endless_list.html', extra_context=None): if v not in BSDF_VERSIONS: raise Http404 entries = get_model('bsdfs', 'ShapeBsdfLabel_' + v).objects.all() \ .filter(time_ms__isnull=False, shape__photo__synthetic=False, shape__photo__inappropriate=False) \ .order_by('-id') context = dict_union( { 'nav': 'browse/bsdf-%s' % v, 'subnav': 'all', 'entries': entries, 'base_template': 'bsdf_base.html', 'thumb_template': 'bsdf_%s_shape_thumb.html' % v, 'header': 'All submissions', 'header_small': 'sorted by date', 'v': v, #'enable_voting': False, }, extra_context) return render(request, template, context)
def photo_by_dataset_entries(dataset_id, filter_key): """ Returns queryset for each filter """ photo_filter = PHOTO_FILTERS[filter_key]['filter'] if dataset_id != 'all': photo_filter = dict_union(photo_filter, {'dataset_id': dataset_id}) return Photo.objects.filter(**photo_filter)
def bsdf_bad(request, v, template='endless_list.html', extra_context=None): if v not in BSDF_VERSIONS: raise Http404 entries = get_model('bsdfs', 'ShapeBsdfLabel_' + v).objects \ .filter(shape__photo__inappropriate=False, shape__photo__synthetic=False) \ .exclude(color_correct=True) \ .exclude(gloss_correct=True) \ .extra( select={'correct_score': 'color_correct_score + gloss_correct_score'}, order_by=('correct_score',) ) #.filter(time_ms__isnull=False, admin_score__lt=0, shape__synthetic=False) \ #.order_by('admin_score', '-shape__pixel_area') if 'publishable' in request.GET: entries = entries.filter(shape__photo__license__publishable=True) context = dict_union({ 'nav': 'browse/bsdf-%s' % v, 'subnav': 'bad', 'entries': entries, 'base_template': 'bsdf_base.html', 'thumb_template': 'bsdf_%s_shape_thumb.html' % v, 'header': 'Low quality submissions', 'header_small': 'sorted by quality', 'v': v, #'enable_voting': False, }, extra_context) return render(request, template, context)
def admin_example(request, experiment_slug='all', template='mturk/admin/example.html', extra_context=None): categories = admin_example_categories() entries = ExperimentExample.objects \ .filter(experiment__slug=experiment_slug) \ .prefetch_related('content') \ .order_by('-id') # hacky, I know if entries and hasattr(entries[0], 'shape_id'): entries = list(entries) entries.sort(key=lambda x: x.content.shape_id) return render(request, template, dict_union({ 'nav': 'mturk-admin', 'subnav': 'example', 'entries': entries, 'categories': categories, 'category_slug': experiment_slug, 'entries_per_page': 30, 'span': 'span3', 'rowsize': '3', 'thumb_template_extra': 'mturk/admin/example_thumb_extra.html' }, extra_context))
def rectified_normal_best(request, template='endless_list.html', extra_context=None): entries = ShapeRectifiedNormalLabel.objects \ .filter(shape__photo__inappropriate=False, shape__correct=True, shape__planar=True, shape__rectified_normal_id=F('id')) \ if 'by-id' in request.GET: header_small = 'sorted by id' entries = entries.order_by('-id') else: header_small = 'sorted by complexity' entries = entries.order_by('-shape__num_vertices') if 'publishable' in request.GET: entries = entries.filter(shape__photo__license__publishable=True) context = dict_union( { 'nav': 'browse/rectified-normal', 'subnav': 'best', 'entries': entries, 'base_template': 'rectified_normal_base.html', 'thumb_template': 'rectified_normal_thumb.html', 'header': 'High quality submissions', 'header_small': header_small, }, extra_context) return render(request, template, context)
def photo_by_category_entries(category_id, filter_key): """ Returns queryset for each filter """ photo_filter = PHOTO_FILTERS[filter_key]['filter'] if category_id != 'all': photo_filter = dict_union(photo_filter, {'scene_category_id': category_id}) return Photo.objects.filter(**photo_filter)
def photo_by_category_entries(category_id, filter_key): """ Returns queryset for each filter """ photo_filter = PHOTO_FILTERS[filter_key]['filter'] if category_id != 'all': photo_filter = dict_union(photo_filter, { 'scene_category_id': category_id }) return Photo.objects.filter(**photo_filter)
def photo_by_category_filters(category_id): """ Returns the list of filters extended with the photo count """ ret = [] for k in PHOTO_FILTER_KEYS: ret.append(dict_union({ 'key': k, 'count': photo_by_category_entries(category_id, k).count(), }, PHOTO_FILTERS[k])) return ret
def admin_pending_content( request, experiment_slug='all', filter_key='scheduled', template='mturk/admin/pending_content_base.html', extra_context=None): if filter_key not in PENDING_CONTENT_FILTERS_LIST: raise Http404 categories = admin_pending_content_categories() filters = [] for key in PENDING_CONTENT_FILTERS_LIST: count = 0 for cat in categories[key]: if cat['slug'] == experiment_slug: count = cat['count'] break else: count = categories[key][0]['count'] filters.append( dict_union( {'key': key, 'count': count}, PENDING_CONTENT_FILTERS[key] ) ) entries = pending_content_entries(experiment_slug, filter_key) \ .order_by('num_outputs_completed', '-priority') return render(request, template, dict_union({ 'nav': 'mturk-admin', 'subnav': 'pending-content', 'filters': filters, 'filter_key': filter_key, 'categories': categories[filter_key], 'category_slug': experiment_slug, 'entries': entries, 'entries_per_page': 30, 'span': 'span3', 'rowsize': '3', 'thumb_template_extra': 'mturk/admin/pending_content_thumb_extra.html', }, extra_context))
def update_index_context_task(): data = { 'num_scenes_good': Photo.objects.filter(**Photo.DEFAULT_FILTERS).count(), 'num_scenes_all': Photo.objects.all().count(), 'num_whitebalanced_good': Photo.objects.filter(whitebalanced=True, scene_category_correct=True).count(), 'num_whitebalanced_all': Photo.objects.filter(whitebalanced_score__isnull=False, scene_category_correct=True).count(), 'num_shapes_good': MaterialShape.objects.filter(**MaterialShape.DEFAULT_FILTERS).count(), 'num_shapes_all': MaterialShape.objects.filter().count(), 'num_substances_good': MaterialShape.objects.filter(**dict_union({'substance__fail': False}, MaterialShape.DEFAULT_FILTERS)).count(), 'num_substances_all': MaterialShape.objects.filter(**dict_union({'substance_entropy__isnull': False}, MaterialShape.DEFAULT_FILTERS)).count(), 'num_planar_good': MaterialShape.objects.filter(**dict_union({'planar': True}, MaterialShape.DEFAULT_FILTERS)).count(), 'num_planar_all': MaterialShape.objects.filter(**MaterialShape.DEFAULT_FILTERS).count(), 'num_names_good': MaterialShape.objects.filter(**dict_union({'name__fail': False}, MaterialShape.DEFAULT_FILTERS)).count(), 'num_names_all': MaterialShape.objects.filter(**dict_union({'name_entropy__isnull': False}, MaterialShape.DEFAULT_FILTERS)).count(), 'num_textures_good': MaterialShape.objects.filter(rectified_normal__isnull=False, planar=True, correct=True).count(), 'num_textures_all': ShapeRectifiedNormalLabel.objects.distinct('shape').count(), 'num_bsdfs_good': MaterialShape.objects.filter(bsdf_wd__isnull=False).count(), 'num_bsdfs_all': ShapeBsdfLabel_wd.objects.all().distinct('shape').count(), 'num_judgements_all': IntrinsicPointComparison.objects.all().count(), 'num_assignments_good': MtAssignment.objects.filter(hit__sandbox=False, status='A').count(), 'num_assignments_all': MtAssignment.objects.filter(hit__sandbox=False, status__isnull=False).count(), 'num_submitted_all': MtSubmittedContent.objects.filter(assignment__hit__sandbox=False).count(), 'num_users_good': MtAssignment.objects.filter(hit__sandbox=False, status__isnull=False, worker__blocked=False).distinct('worker').count(), 'num_users_all': MtAssignment.objects.filter(hit__sandbox=False, status__isnull=False).distinct('worker').count(), 'num_hours_all': MtAssignment.objects.filter(hit__sandbox=False).aggregate(s=Sum('time_ms'))['s'] / 3600000, } if settings.ENABLE_CACHING: get_cache('persistent').set('home.index_context', data, timeout=None) return data
def material_shape_by_user(request, template="material_shape_by_user.html", extra_context=None): users = ( UserProfile.objects.prefetch_related("materialshape_set") .annotate(num_material_shapes=Count("materialshape")) .order_by("-num_material_shapes") ) context = dict_union({"nav": "browse/material-shape", "subnav": "by-user", "users": users}, extra_context) return render(request, template, context)
def photo_by_category_filters(category_id): """ Returns the list of filters extended with the photo count """ ret = [] for k in PHOTO_FILTER_KEYS: ret.append( dict_union( { 'key': k, 'count': photo_by_category_entries(category_id, k).count(), }, PHOTO_FILTERS[k])) return ret
def photo_by_category(request, category_id='all', filter_key='wb', template='photos/by_category.html', extra_context=None): """ List of photos, filtered by a scene and optional extra ``filter_key`` """ if filter_key not in PHOTO_FILTERS: raise Http404 if category_id != 'all': category_id = int(category_id) entries = photo_by_category_entries(category_id, filter_key) query_filter = {} for k, v in request.GET.iteritems(): if k == u'page' or k == u'querystring_key': continue elif k == u'publishable': query_filter['license__publishable'] = True else: query_filter[k] = v if query_filter: entries = entries.filter(**query_filter) if filter_key == 'vp': entries = entries.order_by('-vanishing_length') elif filter_key == 'ic': entries = entries.order_by('-num_intrinsic_comparisons') else: if filter_key == 'all': entries = entries.order_by('-added') else: entries = entries.order_by('-num_vertices', '-scene_category_correct_score') context = dict_union( { 'nav': 'browse/photo', 'subnav': 'by-category', 'filter_key': filter_key, 'category_id': category_id, 'filters': photo_by_category_filters(category_id), 'url_name': 'photo-by-category', 'entries': entries, 'entries_per_page': 30, 'span': 'span3', 'rowsize': '3', 'thumb_template': 'photos/thumb.html', }, extra_context) context.update(photo_scene_categories()) return render(request, template, context)
def photo_by_category(request, category_id='all', filter_key='wb', template='photos/by_category.html', extra_context=None): """ List of photos, filtered by a scene and optional extra ``filter_key`` """ if filter_key not in PHOTO_FILTERS: raise Http404 if category_id != 'all': category_id = int(category_id) entries = photo_by_category_entries(category_id, filter_key) query_filter = {} for k, v in request.GET.iteritems(): if k == u'page' or k == u'querystring_key': continue elif k == u'publishable': query_filter['license__publishable'] = True else: query_filter[k] = v if query_filter: entries = entries.filter(**query_filter) if filter_key == 'vp': entries = entries.order_by('-vanishing_length') elif filter_key == 'ic': entries = entries.order_by('-num_intrinsic_comparisons') else: if filter_key == 'all': entries = entries.order_by('-added') else: entries = entries.order_by('-num_vertices', '-scene_category_correct_score') context = dict_union({ 'nav': 'browse/photo', 'subnav': 'by-category', 'filter_key': filter_key, 'category_id': category_id, 'filters': photo_by_category_filters(category_id), 'url_name': 'photo-by-category', 'entries': entries, 'entries_per_page': 30, 'span': 'span3', 'rowsize': '3', 'thumb_template': 'photos/thumb.html', }, extra_context) context.update(photo_scene_categories()) return render(request, template, context)
def rectified_normal_voted_no(request, template='endless_list.html', extra_context=None): entries = ShapeRectifiedNormalLabel.objects \ .filter(admin_score__lt=0) \ .order_by('admin_score', '-shape__pixel_area') context = dict_union({ 'nav': 'browse/rectified-normal', 'subnav': 'voted-no', 'entries': entries, 'base_template': 'rectified_normal_base.html', 'thumb_template': 'rectified_normal_thumb_vote.html', 'enable_voting': True, }, extra_context) return render(request, template, context)
def rectified_normal_voted_none(request, template='endless_list.html', extra_context=None): entries = ShapeRectifiedNormalLabel.objects \ .filter(admin_score=0, time_ms__gt=500, shape__dominant_delta__isnull=False) \ .order_by('-shape__synthetic', '?') context = dict_union({ 'nav': 'browse/rectified-normal', 'subnav': 'vote', 'entries': entries, 'base_template': 'rectified_normal_base.html', 'thumb_template': 'rectified_normal_thumb_vote.html', 'enable_voting': True, }, extra_context) return render(request, template, context)
def material_shape_by_user(request, template='material_shape_by_user.html', extra_context=None): users = UserProfile.objects \ .prefetch_related('materialshape_set') \ .annotate(num_material_shapes=Count('materialshape')) \ .order_by('-num_material_shapes') context = dict_union( { 'nav': 'browse/material-shape', 'subnav': 'by-user', 'users': users, }, extra_context) return render(request, template, context)
def intrinsic_decomposition_by_algorithm( request, algorithm_id=None, order_by='mean_error', template='intrinsic/decomposition_by_algorithm.html', extra_context=None): entries = IntrinsicImagesDecomposition.objects if algorithm_id: algorithm = get_object_or_404(IntrinsicImagesAlgorithm, id=algorithm_id) entries = entries.filter(algorithm_id=algorithm_id) else: algorithm = None entries = entries.all() entries = entries \ .filter(photo__in_iiw_dataset=True) \ .select_related('algorithm') \ if order_by.endswith('mean_error'): entries = entries.order_by(order_by, '-runtime') elif order_by.endswith('runtime'): entries = entries.order_by(order_by, 'mean_error') elif order_by.endswith('photo__num_intrinsic_comparisons'): entries = entries.order_by(order_by, 'mean_error') else: raise Http404 num_photos = Photo.objects \ .filter(in_iiw_dataset=True).count() context = dict_union( { 'iiw': True, 'nav': 'browse/intrinsic-decomposition', 'entries': entries, 'algorithm': algorithm, 'thumb_template': 'intrinsic/decomposition_image.html', 'span': 'span12', 'entries_per_page': 8, 'num_photos': num_photos, 'order_by': order_by }, extra_context) return render(request, template, context)
def photo_by_dataset(request, dataset_id='all', filter_key='all', template='photos/by_dataset.html', extra_context=None): """ List of photos, filtered by a dataset and optional extra ``filter_key`` """ if filter_key not in PHOTO_FILTERS: raise Http404 if dataset_id != 'all': dataset_id = int(dataset_id) entries = photo_by_dataset_entries(dataset_id, filter_key) query_filter = {} for k, v in request.GET.iteritems(): if k == u'page' or k == u'querystring_key': continue elif k == u'publishable': query_filter['license__publishable'] = True else: query_filter[k] = v if query_filter: entries = entries.filter(**query_filter) entries = entries.order_by('-added') context = dict_union( { 'nav': 'browse/photo', 'subnav': 'by-dataset', 'filter_key': filter_key, 'dataset_id': dataset_id, 'filters': photo_by_dataset_filters(dataset_id), 'url_name': 'photo-by-dataset', 'entries': entries, 'entries_per_page': 30, 'span': 'span3', 'rowsize': '3', 'thumb_template': 'photos/thumb.html', }, extra_context) context.update(photo_datasets()) return render(request, template, context)
def material_shape_all(request, template="endless_list.html", extra_context=None): entries = MaterialShape.objects.all().select_related("photo").order_by("-added") context = dict_union( { "nav": "browse/material-shape", "subnav": "all", "entries": entries, "base_template": "material_shape_base.html", "thumb_template": "material_shape_thumb.html", "header": "All submissions", "header_small": "sorted by submission time", }, extra_context, ) return render(request, template, context)
def intrinsic_decomposition_by_algorithm( request, algorithm_id=None, order_by='mean_error', template='intrinsic/decomposition_by_algorithm.html', extra_context=None): entries = IntrinsicImagesDecomposition.objects if algorithm_id: algorithm = get_object_or_404(IntrinsicImagesAlgorithm, id=algorithm_id) entries = entries.filter(algorithm_id=algorithm_id) else: algorithm = None entries = entries.all() entries = entries \ .filter(photo__in_iiw_dataset=True) \ .select_related('algorithm') \ if order_by.endswith('mean_error'): entries = entries.order_by(order_by, '-runtime') elif order_by.endswith('runtime'): entries = entries.order_by(order_by, 'mean_error') elif order_by.endswith('photo__num_intrinsic_comparisons'): entries = entries.order_by(order_by, 'mean_error') else: raise Http404 num_photos = Photo.objects \ .filter(in_iiw_dataset=True).count() context = dict_union({ 'iiw': True, 'nav': 'browse/intrinsic-decomposition', 'entries': entries, 'algorithm': algorithm, 'thumb_template': 'intrinsic/decomposition_image.html', 'span': 'span12', 'entries_per_page': 8, 'num_photos': num_photos, 'order_by': order_by }, extra_context) return render(request, template, context)
def material_shape_by_rejected(request, template="endless_list.html", extra_context=None): entries = MaterialShape.objects.filter(mturk_assignment__status="R").select_related("photo").order_by("-time_ms") # .order_by('-mturk_assignment__updated') context = dict_union( { "nav": "browse/material-shape", "subnav": "by-rejected", "entries": entries, "base_template": "material_shape_base.html", "thumb_template": "material_shape_thumb.html", "header": "Rejected submissions", "header_small": "sorted by worker time", }, extra_context, ) return render(request, template, context)
def rectified_normal_voted_no(request, template='endless_list.html', extra_context=None): entries = ShapeRectifiedNormalLabel.objects \ .filter(admin_score__lt=0) \ .order_by('admin_score', '-shape__pixel_area') context = dict_union( { 'nav': 'browse/rectified-normal', 'subnav': 'voted-no', 'entries': entries, 'base_template': 'rectified_normal_base.html', 'thumb_template': 'rectified_normal_thumb_vote.html', 'enable_voting': True, }, extra_context) return render(request, template, context)
def rectified_normal_all(request, template='endless_list.html', extra_context=None): entries = ShapeRectifiedNormalLabel.objects.all().order_by('-id') if 'publishable' in request.GET: entries = entries.filter(shape__photo__license__publishable=True) context = dict_union({ 'nav': 'browse/rectified-normal', 'subnav': 'all', 'entries': entries, 'base_template': 'rectified_normal_base.html', 'thumb_template': 'rectified_normal_thumb.html', 'header': 'All submissions', 'header_small': 'sorted by submission time', #'enable_voting': False, }, extra_context) return render(request, template, context)
def rectified_normal_voted_none(request, template='endless_list.html', extra_context=None): entries = ShapeRectifiedNormalLabel.objects \ .filter(admin_score=0, time_ms__gt=500, shape__dominant_delta__isnull=False) \ .order_by('-shape__synthetic', '?') context = dict_union( { 'nav': 'browse/rectified-normal', 'subnav': 'vote', 'entries': entries, 'base_template': 'rectified_normal_base.html', 'thumb_template': 'rectified_normal_thumb_vote.html', 'enable_voting': True, }, extra_context) return render(request, template, context)
def rectified_normal_good(request, template='endless_list.html', extra_context=None): entries = ShapeRectifiedNormalLabel.objects \ .filter(shape__planar=True, correct=True, correct_score__isnull=False) \ .order_by('-correct_score') #.filter(admin_score__gt=0, shape__synthetic=False) \ #.order_by('-admin_score', '-shape__pixel_area') context = dict_union({ 'nav': 'browse/rectified-normal', 'subnav': 'good', 'entries': entries, 'base_template': 'rectified_normal_base.html', 'thumb_template': 'rectified_normal_thumb.html', 'header': 'High quality submissions' #'header_sub': 'These submissions were voted as high quality.' #'enable_voting': False, }, extra_context) return render(request, template, context)
def material_shape_all(request, template='endless_list.html', extra_context=None): entries = MaterialShape.objects.all() \ .select_related('photo') \ .order_by('-added') context = dict_union( { 'nav': 'browse/material-shape', 'subnav': 'all', 'entries': entries, 'base_template': 'material_shape_base.html', 'thumb_template': 'material_shape_thumb.html', 'header': 'All submissions', 'header_small': 'sorted by submission time', }, extra_context) return render(request, template, context)
def bsdf_wd_voted_no(request, template='endless_list.html', extra_context=None): v = 'wd' bsdf_model = get_model('bsdfs', 'ShapeBsdfLabel_' + v) entries = bsdf_model.objects \ .filter(admin_score__lt=0) \ .order_by('admin_score', '-shape__pixel_area', '-shape__correct_score') context = dict_union({ 'nav': 'browse/bsdf-%s' % v, 'subnav': 'voted-no', 'entries': entries, 'base_template': 'bsdf_base.html', 'thumb_template': 'bsdf_wd_thumb_vote.html', 'v': v, 'enable_voting': True, }, extra_context) return render(request, template, context)
def rectified_normal_auto(request, template='endless_list.html', extra_context=None): entries = ShapeRectifiedNormalLabel.objects \ .filter(shape__planar=True, shape__correct=True, automatic=True) \ .order_by('-shape__num_vertices') if 'publishable' in request.GET: entries = entries.filter(shape__photo__license__publishable=True) context = dict_union({ 'nav': 'browse/rectified-normal', 'subnav': 'auto', 'entries': entries, 'base_template': 'rectified_normal_base.html', 'thumb_template': 'rectified_normal_thumb.html', 'header': 'Automatically rectified shapes', 'header_small': 'using vanishing points', }, extra_context) return render(request, template, context)
def material_shape_rectified(request, template='endless_list.html', extra_context=None): entries = MaterialShape.objects \ .filter(**MaterialShape.DEFAULT_FILTERS) \ .filter(planar=True, planar_score__isnull=False) \ .exclude(image_rectified=u'') \ .select_related('photo') \ .order_by('-rectified_area') # , '-num_vertices', '-time_ms') context = dict_union( { 'nav': 'browse/material-shape', 'subnav': 'rectified', 'entries': entries, 'base_template': 'material_shape_base.html', 'thumb_template': 'material_shape_rectified_thumb.html', }, extra_context) return render(request, template, context)
def rectified_normal_curate( request, template='endless_list_curate.html', extra_context=None): entries = ShapeRectifiedNormalLabel.objects \ .filter(shape__planar=True, correct=True) \ .order_by('-shape__num_vertices') if 'publishable' in request.GET: entries = entries.filter(shape__photo__license__publishable=True) context = dict_union({ 'nav': 'browse/rectified-normal', 'subnav': 'curate', 'entries': entries, 'base_template': 'rectified_normal_base.html', 'thumb_template': 'rectified_normal_thumb.html', 'header': 'Curate rectified textures', 'curate_post_url': reverse('rectified-normal-curate-post'), 'curate': True }, extra_context) return render(request, template, context)
def material_shape_by_vertices(request, template='endless_list.html', extra_context=None): entries = MaterialShape.objects \ .filter(**MaterialShape.DEFAULT_FILTERS) \ .select_related('photo') \ .order_by('-num_vertices', '-correct_score') context = dict_union( { 'nav': 'browse/material-shape', 'subnav': 'by-vertices', 'entries': entries, 'base_template': 'material_shape_base.html', 'thumb_template': 'material_shape_thumb.html', 'header': 'Submissions', 'header_small': 'sorted by vertex count', }, extra_context) return render(request, template, context)
def material_shape_by_rejected(request, template='endless_list.html', extra_context=None): entries = MaterialShape.objects \ .filter(mturk_assignment__status='R') \ .select_related('photo') \ .order_by('-time_ms') #.order_by('-mturk_assignment__updated') context = dict_union( { 'nav': 'browse/material-shape', 'subnav': 'by-rejected', 'entries': entries, 'base_template': 'material_shape_base.html', 'thumb_template': 'material_shape_thumb.html', 'header': 'Rejected submissions', 'header_small': 'sorted by worker time', }, extra_context) return render(request, template, context)
def bsdf_wd_voted_no(request, template='endless_list.html', extra_context=None): v = 'wd' bsdf_model = get_model('bsdfs', 'ShapeBsdfLabel_' + v) entries = bsdf_model.objects \ .filter(admin_score__lt=0) \ .order_by('admin_score', '-shape__pixel_area', '-shape__correct_score') context = dict_union( { 'nav': 'browse/bsdf-%s' % v, 'subnav': 'voted-no', 'entries': entries, 'base_template': 'bsdf_base.html', 'thumb_template': 'bsdf_wd_thumb_vote.html', 'v': v, 'enable_voting': True, }, extra_context) return render(request, template, context)
def material_shape_by_synthetic(request, template='endless_list.html', extra_context=None): entries = MaterialShape.objects \ .filter(synthetic=True) \ .select_related('photo') \ .order_by('-synthetic_slug', '-num_vertices') #.order_by('-mturk_assignment__updated') context = dict_union( { 'nav': 'browse/material-shape', 'subnav': 'by-synthetic', 'entries': entries, 'base_template': 'material_shape_base.html', 'thumb_template': 'material_shape_thumb.html', 'header': 'Special submissions', 'header_small': 'sorted by worker time', }, extra_context) return render(request, template, context)
def bsdf_good(request, v, template='endless_list.html', extra_context=None): if v not in BSDF_VERSIONS: raise Http404 entries = get_model('bsdfs', 'ShapeBsdfLabel_' + v).objects.all() \ .filter(color_correct=True, gloss_correct=True, shape__photo__synthetic=False, shape__photo__inappropriate=False, shape__bsdf_wd_id=F('id')) \ if 'by-id' in request.GET: header_small = 'sorted by id' entries = entries.order_by('-id') else: header_small = 'sorted by quality' entries = entries.extra( select={'correct_score': 'color_correct_score + gloss_correct_score'}, order_by=('-correct_score',) ) \ if 'publishable' in request.GET: entries = entries.filter(shape__photo__license__publishable=True) context = dict_union( { 'nav': 'browse/bsdf-%s' % v, 'subnav': 'good', 'entries': entries, 'base_template': 'bsdf_base.html', 'thumb_template': 'bsdf_%s_shape_thumb.html' % v, 'header': 'High quality submissions', 'header_small': header_small, 'v': v, #'enable_voting': False, }, extra_context) return render(request, template, context)
def bsdf_all(request, v, template='endless_list.html', extra_context=None): if v not in BSDF_VERSIONS: raise Http404 entries = get_model('bsdfs', 'ShapeBsdfLabel_' + v).objects.all() \ .filter(time_ms__isnull=False, shape__photo__synthetic=False, shape__photo__inappropriate=False) \ .order_by('-id') context = dict_union({ 'nav': 'browse/bsdf-%s' % v, 'subnav': 'all', 'entries': entries, 'base_template': 'bsdf_base.html', 'thumb_template': 'bsdf_%s_shape_thumb.html' % v, 'header': 'All submissions', 'header_small': 'sorted by date', 'v': v, #'enable_voting': False, }, extra_context) return render(request, template, context)
def material_shape_curate_planarity(request, template='endless_list_curate.html', extra_context=None): entries = MaterialShape.objects \ .filter(planar=True, correct=True) \ .select_related('photo') \ .order_by('-num_vertices', 'planar_score') context = dict_union( { 'nav': 'browse/material-shape', 'subnav': 'curate-planarity', 'entries': entries, 'base_template': 'material_shape_base.html', 'thumb_template': 'material_shape_thumb.html', 'header': 'Submissions', 'header_small': 'sorted by planarity votes', 'curate_post_url': reverse('material-shape-curate-planarity-post'), }, extra_context) return render(request, template, context)
def material_shape_by_quality(request, template="endless_list_votes.html", extra_context=None): entries = ( MaterialShape.objects.filter(pixel_area__gt=Shape.MIN_PIXEL_AREA, correct_score__isnull=False, synthetic=False) .select_related("photo") .order_by("-correct_score", "-area") ) # '-num_vertices', '-time_ms') context = dict_union( { "nav": "browse/material-shape", "subnav": "by-quality", "entries": entries, "base_template": "material_shape_base.html", "thumb_template": "material_shape_quality_thumb.html", "header": "Submissions", "header_small": "sorted by quality votes", }, extra_context, ) return render(request, template, context)
def material_shape_by_vertices(request, template="endless_list.html", extra_context=None): entries = ( MaterialShape.objects.filter(**MaterialShape.DEFAULT_FILTERS) .select_related("photo") .order_by("-num_vertices", "-correct_score") ) context = dict_union( { "nav": "browse/material-shape", "subnav": "by-vertices", "entries": entries, "base_template": "material_shape_base.html", "thumb_template": "material_shape_thumb.html", "header": "Submissions", "header_small": "sorted by vertex count", }, extra_context, ) return render(request, template, context)
def material_shape_rectified(request, template="endless_list.html", extra_context=None): entries = ( MaterialShape.objects.filter(**MaterialShape.DEFAULT_FILTERS) .filter(planar=True, planar_score__isnull=False) .exclude(image_rectified=u"") .select_related("photo") .order_by("-rectified_area") ) # , '-num_vertices', '-time_ms') context = dict_union( { "nav": "browse/material-shape", "subnav": "rectified", "entries": entries, "base_template": "material_shape_base.html", "thumb_template": "material_shape_rectified_thumb.html", }, extra_context, ) return render(request, template, context)
def rectified_normal_auto(request, template='endless_list.html', extra_context=None): entries = ShapeRectifiedNormalLabel.objects \ .filter(shape__planar=True, shape__correct=True, automatic=True) \ .order_by('-shape__num_vertices') if 'publishable' in request.GET: entries = entries.filter(shape__photo__license__publishable=True) context = dict_union( { 'nav': 'browse/rectified-normal', 'subnav': 'auto', 'entries': entries, 'base_template': 'rectified_normal_base.html', 'thumb_template': 'rectified_normal_thumb.html', 'header': 'Automatically rectified shapes', 'header_small': 'using vanishing points', }, extra_context) return render(request, template, context)
def material_shape_curate_planarity(request, template="endless_list_curate.html", extra_context=None): entries = ( MaterialShape.objects.filter(planar=True, correct=True) .select_related("photo") .order_by("-num_vertices", "planar_score") ) context = dict_union( { "nav": "browse/material-shape", "subnav": "curate-planarity", "entries": entries, "base_template": "material_shape_base.html", "thumb_template": "material_shape_thumb.html", "header": "Submissions", "header_small": "sorted by planarity votes", "curate_post_url": reverse("material-shape-curate-planarity-post"), }, extra_context, ) return render(request, template, context)
def rectified_normal_bad(request, template='endless_list.html', extra_context=None): entries = ShapeRectifiedNormalLabel.objects \ .filter(shape__planar=True, correct=False, correct_score__isnull=False) \ .order_by('correct_score') #.filter(admin_score__lt=0, shape__synthetic=False) \ #.order_by('admin_score', 'shape__num_vertices') if 'publishable' in request.GET: entries = entries.filter(shape__photo__license__publishable=True) context = dict_union({ 'nav': 'browse/rectified-normal', 'subnav': 'bad', 'entries': entries, 'base_template': 'rectified_normal_base.html', 'thumb_template': 'rectified_normal_thumb.html', 'header': 'Low quality submissions', 'header_small': 'sorted by quality', #'enable_voting': False, }, extra_context) return render(request, template, context)
def material_shape_by_quality(request, template='endless_list_votes.html', extra_context=None): entries = MaterialShape.objects \ .filter(pixel_area__gt=Shape.MIN_PIXEL_AREA, correct_score__isnull=False, synthetic=False) \ .select_related('photo') \ .order_by('-correct_score', '-area') # '-num_vertices', '-time_ms') context = dict_union( { 'nav': 'browse/material-shape', 'subnav': 'by-quality', 'entries': entries, 'base_template': 'material_shape_base.html', 'thumb_template': 'material_shape_quality_thumb.html', 'header': 'Submissions', 'header_small': 'sorted by quality votes', }, extra_context) return render(request, template, context)
def rectified_normal_all(request, template='endless_list.html', extra_context=None): entries = ShapeRectifiedNormalLabel.objects.all().order_by('-id') if 'publishable' in request.GET: entries = entries.filter(shape__photo__license__publishable=True) context = dict_union( { 'nav': 'browse/rectified-normal', 'subnav': 'all', 'entries': entries, 'base_template': 'rectified_normal_base.html', 'thumb_template': 'rectified_normal_thumb.html', 'header': 'All submissions', 'header_small': 'sorted by submission time', #'enable_voting': False, }, extra_context) return render(request, template, context)
def material_shape_by_synthetic(request, template="endless_list.html", extra_context=None): entries = ( MaterialShape.objects.filter(synthetic=True) .select_related("photo") .order_by("-synthetic_slug", "-num_vertices") ) # .order_by('-mturk_assignment__updated') context = dict_union( { "nav": "browse/material-shape", "subnav": "by-synthetic", "entries": entries, "base_template": "material_shape_base.html", "thumb_template": "material_shape_thumb.html", "header": "Special submissions", "header_small": "sorted by worker time", }, extra_context, ) return render(request, template, context)
def bsdf_good(request, v, template='endless_list.html', extra_context=None): if v not in BSDF_VERSIONS: raise Http404 entries = get_model('bsdfs', 'ShapeBsdfLabel_' + v).objects.all() \ .filter(color_correct=True, gloss_correct=True, shape__photo__synthetic=False, shape__photo__inappropriate=False, shape__bsdf_wd_id=F('id')) \ if 'by-id' in request.GET: header_small = 'sorted by id' entries = entries.order_by('-id') else: header_small = 'sorted by quality' entries = entries.extra( select={'correct_score': 'color_correct_score + gloss_correct_score'}, order_by=('-correct_score',) ) \ if 'publishable' in request.GET: entries = entries.filter(shape__photo__license__publishable=True) context = dict_union({ 'nav': 'browse/bsdf-%s' % v, 'subnav': 'good', 'entries': entries, 'base_template': 'bsdf_base.html', 'thumb_template': 'bsdf_%s_shape_thumb.html' % v, 'header': 'High quality submissions', 'header_small': header_small, 'v': v, #'enable_voting': False, }, extra_context) return render(request, template, context)
def rectified_normal_good(request, template='endless_list.html', extra_context=None): entries = ShapeRectifiedNormalLabel.objects \ .filter(shape__planar=True, correct=True, correct_score__isnull=False) \ .order_by('-correct_score') #.filter(admin_score__gt=0, shape__synthetic=False) \ #.order_by('-admin_score', '-shape__pixel_area') context = dict_union( { 'nav': 'browse/rectified-normal', 'subnav': 'good', 'entries': entries, 'base_template': 'rectified_normal_base.html', 'thumb_template': 'rectified_normal_thumb.html', 'header': 'High quality submissions' #'header_sub': 'These submissions were voted as high quality.' #'enable_voting': False, }, extra_context) return render(request, template, context)
def material_shape_by_name(request, template='endless_list.html', extra_context=None): entries = MaterialShape.objects \ .filter(pixel_area__gt=Shape.MIN_PIXEL_AREA, correct=True, name_entropy__isnull=False, synthetic=False) \ .select_related('photo') \ .order_by('name_entropy', '-correct_score') context = dict_union( { 'nav': 'browse/material-shape', 'subnav': 'by-name', 'entries': entries, 'base_template': 'material_shape_base.html', 'thumb_template': 'material_shape_name_thumb.html', 'header': 'Submissions', 'header_small': 'sorted by entropy', }, extra_context) return render(request, template, context)
def rectified_normal_curate(request, template='endless_list_curate.html', extra_context=None): entries = ShapeRectifiedNormalLabel.objects \ .filter(shape__planar=True, correct=True) \ .order_by('-shape__num_vertices') if 'publishable' in request.GET: entries = entries.filter(shape__photo__license__publishable=True) context = dict_union( { 'nav': 'browse/rectified-normal', 'subnav': 'curate', 'entries': entries, 'base_template': 'rectified_normal_base.html', 'thumb_template': 'rectified_normal_thumb.html', 'header': 'Curate rectified textures', 'curate_post_url': reverse('rectified-normal-curate-post'), 'curate': True }, extra_context) return render(request, template, context)
def material_shape_by_name(request, template="endless_list.html", extra_context=None): entries = ( MaterialShape.objects.filter( pixel_area__gt=Shape.MIN_PIXEL_AREA, correct=True, name_entropy__isnull=False, synthetic=False ) .select_related("photo") .order_by("name_entropy", "-correct_score") ) context = dict_union( { "nav": "browse/material-shape", "subnav": "by-name", "entries": entries, "base_template": "material_shape_base.html", "thumb_template": "material_shape_name_thumb.html", "header": "Submissions", "header_small": "sorted by entropy", }, extra_context, ) return render(request, template, context)
from common.utils import dict_union, prepare_votes_bar, \ json_response, json_success_response from photos.models import Photo, PhotoSceneCategory # different ways photos can be filtered PHOTO_FILTERS = { 'all': { 'name': 'Raw input', 'filter': Photo.DEFAULT_FILTERS }, 'wb': { 'name': 'Whitebalanced (WB)', 'filter': dict_union( Photo.DEFAULT_FILTERS, { 'whitebalanced': True, }) }, 'nwb': { 'name': 'Not WB', 'filter': dict_union( Photo.DEFAULT_FILTERS, { 'whitebalanced': False, }) }, 'vp': { 'name': 'Has vanishing points', 'filter': dict_union( Photo.DEFAULT_FILTERS, {