예제 #1
0
def new_targetimage(target_id):
    target = Target.query.get_or_404(target_id)
    form = CreateTargetImageForm()
    if form.validate_on_submit():
        if form.file.data:
            file = save_item(form.file.data)
            thumbnail = save_thumbnail(form.file.data)
            targetimage = Targetimage(name=form.name.data,
                                      imagefortarget=target,
                                      file=file,
                                      thumbnail=thumbnail,
                                      age=form.age.data)
            db.session.add(targetimage)
            db.session.commit()
            flash(gettext('Your new image has been created'), 'success')
            return redirect(
                url_for('analytics.update_target', target_id=target.id))
    itemsall = Item.query.order_by(Item.date_posted.desc()).all()
    searchform = SearchItemForm()
    return render_template('create_targetimage.html',
                           title='New Image',
                           form=form,
                           legend=gettext('New image for target'),
                           itemsall=itemsall,
                           searchform=searchform)
예제 #2
0
def account():
    form = UpdateAccountForm()
    if form.validate_on_submit():
        if form.picture.data:
            picturefile = save_picture(form.picture.data)
            current_user.image_file = picturefile
        current_user.username = form.username.data
        current_user.email = form.email.data
        db.session.commit()
        flash(gettext('Your account has been updated!'), 'success')
        return redirect(url_for('users.account'))
    elif request.method == 'GET':
        form.username.data = current_user.username
        form.email.data = current_user.email
    imagefile = url_for('static',
                        filename='images/profile_pics/' +
                        current_user.image_file)
    itemsall = Item.query.order_by(Item.date_posted.desc()).all()
    searchform = SearchItemForm()
    return render_template('account.html',
                           title='Account',
                           imagefile=imagefile,
                           form=form,
                           itemsall=itemsall,
                           searchform=searchform)
예제 #3
0
def login():
    if current_user.is_authenticated:
        return redirect(url_for('main.home'))
    form = LoginForm()
    if form.validate_on_submit():
        user = User.query.filter_by(email=form.email.data).first()
        if user and bcrypt.check_password_hash(user.password,
                                               form.password.data):
            login_user(user, remember=form.remember.data)
            next_page = request.args.get('next')
            return redirect(next_page) if next_page else redirect(
                url_for('main.home'))
        else:
            current_app.logger.warning('Unsuccessful login attempt {}'.format(
                form.email.data))
            flash(
                gettext('Login Unsuccessful. Please check email and password'),
                'danger')
    itemsall = Item.query.order_by(Item.date_posted.desc()).all()
    searchform = SearchItemForm()
    return render_template('login.html',
                           title='Login',
                           form=form,
                           itemsall=itemsall,
                           searchform=searchform)
예제 #4
0
def update_targetimage(targetimage_id):
    print(targetimage_id)
    targetimage = Targetimage.query.get_or_404(targetimage_id)
    form = CreateTargetImageForm()
    if form.validate_on_submit():
        if form.file.data:
            targetimage.file = save_item(form.file.data)
            targetimage.thumbnail = save_thumbnail(form.file.data)
        targetimage.name = form.name.data
        targetimage.age = form.age.data
        db.session.commit()
        flash(gettext('Your new image has been updated'), 'success')
        return redirect(
            url_for('analytics.update_targetimage',
                    targetimage_id=targetimage.id))
    elif request.method == 'GET':
        form.name.data = targetimage.name
        form.age.data = targetimage.age
    itemsall = Item.query.order_by(Item.date_posted.desc()).all()
    searchform = SearchItemForm()
    return render_template('create_targetimage.html',
                           title='Update Image',
                           form=form,
                           legend=gettext('Update image for target'),
                           itemsall=itemsall,
                           searchform=searchform)
예제 #5
0
def target(target_id):
    target = Target.query.get_or_404(target_id)
    itemsall = Item.query.order_by(Item.date_posted.desc()).all()
    searchform = SearchItemForm()
    return render_template('target.html',
                           title=target.name,
                           target=target,
                           itemsall=itemsall,
                           searchform=searchform)
예제 #6
0
def home():
    page = request.args.get('page', 1, type=int)
    items = Item.query.order_by(Item.date_posted.desc()).paginate(page=page, per_page=12)
    texts={}  
    for item in items.items:
        line1, line2, line3, line4, foundkeywords, foundtargets, foundcelebrities, foundtext, foundlabel, entry = create_texts(item)
        texts[item.id]=entry 
    itemsall = Item.query.order_by(Item.date_posted.desc()).all()
    searchform = SearchItemForm()
    return render_template('home.html', items=items, itemsall=itemsall, searchform=searchform, texts=texts)
예제 #7
0
def keywords():
    page = request.args.get('page', 1, type=int)
    keywordstest = db.session.query(
        func.count(ItemKeyword.item_id).label('countitems'), Keyword.id,
        Keyword.keywordtextname).group_by(ItemKeyword.keyword_id).join(Keyword)
    k = keywordstest.paginate(page=page, per_page=10)
    itemsall = Item.query.order_by(Item.date_posted.desc()).all()
    searchform = SearchItemForm()
    return render_template('keywords.html',
                           keywords=k,
                           itemsall=itemsall,
                           searchform=searchform)
예제 #8
0
def celebrities():
    page = request.args.get('page', 1, type=int)
    celebritiesstest = db.session.query(
        func.count(Person.id).label('countpersons'), Celebrity.id,
        Celebrity.name,
        Celebrity.aws_id).group_by(Person.celebrity_id).join(Celebrity)
    a = celebritiesstest.paginate(page=page, per_page=10)
    itemsall = Item.query.order_by(Item.date_posted.desc()).all()
    searchform = SearchItemForm()
    return render_template('celebrities.html',
                           celebrities=a,
                           itemsall=itemsall,
                           searchform=searchform)
예제 #9
0
def attributes():
    page = request.args.get('page', 1, type=int)
    attributestest = db.session.query(
        func.count(PersonAttribute.person_id).label('countpersons'),
        Attribute.id, Attribute.attributetextname).group_by(
            PersonAttribute.attribute_id).join(Attribute)
    a = attributestest.paginate(page=page, per_page=10)
    itemsall = Item.query.order_by(Item.date_posted.desc()).all()
    searchform = SearchItemForm()
    return render_template('attributes.html',
                           attributes=a,
                           itemsall=itemsall,
                           searchform=searchform)
예제 #10
0
def new_target():
    form = CreateTargetForm()
    if form.validate_on_submit():
        if form.name.data:
            target = Target(name=form.name.data, searcher=current_user)
            db.session.add(target)
            db.session.commit()
            flash(gettext('Your new target has been created'), 'success')
            return redirect(url_for('users.account'))
    itemsall = Item.query.order_by(Item.date_posted.desc()).all()
    searchform = SearchItemForm()
    return render_template('create_target.html',
                           title='New Target',
                           form=form,
                           legend=gettext('New Target'),
                           itemsall=itemsall,
                           searchform=searchform)
예제 #11
0
def celebrity_items(aws_id):
    page = request.args.get('page', 1, type=int)
    celebrity = Celebrity.query.filter_by(aws_id=aws_id).first_or_404()
    celebrityitems = Item.query.join(Person).filter_by(
        celebrity_id=celebrity.id).distinct().paginate(page=page, per_page=12)
    texts = {}
    for item in celebrityitems.items:
        line1, line2, line3, line4, foundkeywords, foundtargets, foundcelebrities, foundtext, foundlabel, entry = create_texts(
            item)
        texts[item.id] = entry
    itemsall = Item.query.order_by(Item.date_posted.desc()).all()
    searchform = SearchItemForm()
    return render_template('celebrity_items.html',
                           items=celebrityitems,
                           celebrity=celebrity,
                           itemsall=itemsall,
                           texts=texts,
                           searchform=searchform)
예제 #12
0
def search():
    print(request.args)
    form = SearchItemForm()
    if len(form.searchtext.data) > 0:
        search_query = form.searchtext.data
    else:
        search_query = str('*')
    return redirect(
        url_for('analytics.results',
                search_query=search_query,
                search_keywords=True,
                search_attributes=False,
                search_celebs=False,
                search_text=False,
                search_age='',
                search_targets='',
                searchtexthidden=form.searchtext.data,
                myitemsonly=False))
예제 #13
0
def user_items(username):
    page = request.args.get('page', 1, type=int)
    user = User.query.filter_by(username=username).first_or_404()
    items = Item.query.filter_by(owner=user).order_by(
        Item.date_posted.desc()).paginate(page=page, per_page=12)
    texts = {}
    for item in items.items:
        line1, line2, line3, line4, foundkeywords, foundtargets, foundcelebrities, foundtext, foundlabel, entry = create_texts(
            item)
        texts[item.id] = entry
    itemsall = Item.query.order_by(Item.date_posted.desc()).all()
    searchform = SearchItemForm()
    return render_template('user_items.html',
                           items=items,
                           user=user,
                           itemsall=itemsall,
                           texts=texts,
                           searchform=searchform)
예제 #14
0
def reset_request():
    if current_user.is_authenticated:
        return redirect(url_for('main.home'))
    form = RequestResetForm()
    if form.validate_on_submit():
        user = User.query.filter_by(email=form.email.data).first()
        send_reset_email(user)
        flash(
            gettext(
                'An email has been sent with instructions to reset your password.'
            ), 'info')
        return redirect(url_for('users.login'))
    itemsall = Item.query.order_by(Item.date_posted.desc()).all()
    searchform = SearchItemForm()
    return render_template('reset_request.html',
                           title='Reset Password',
                           form=form,
                           itemsall=itemsall,
                           searchform=searchform)
예제 #15
0
def item(item_id):
    item = Item.query.get_or_404(item_id)
    itemkeywords = ItemKeyword.query.filter_by(itemin=item)
    persons = Person.query.filter_by(itemin=item)
    attributes = {}
    for person in persons:
        personattributes = PersonAttribute.query.filter_by(
            referenceperson=person).all()
        attributes[person.id] = personattributes
    itemsall = Item.query.order_by(Item.date_posted.desc()).all()
    searchform = SearchItemForm()
    return render_template('item.html',
                           title=item.itemname,
                           item=item,
                           itemkeywords=itemkeywords,
                           itemsall=itemsall,
                           persons=persons,
                           personattributes=attributes,
                           searchform=searchform)
예제 #16
0
def keyword_items(keywordtextname):
    page = request.args.get('page', 1, type=int)
    keyword = Keyword.query.filter_by(
        keywordtextname=keywordtextname).first_or_404()
    item_keywords = ItemKeyword.query.filter_by(reference=keyword).order_by(
        ItemKeyword.date_analysis.desc()).paginate(page=page, per_page=12)
    texts = {}
    for item_keyword in item_keywords.items:
        item = item_keyword.itemin
        line1, line2, line3, line4, foundkeywords, foundtargets, foundcelebrities, foundtext, foundlabel, entry = create_texts(
            item)
        texts[item.id] = entry
    itemsall = Item.query.order_by(Item.date_posted.desc()).all()
    searchform = SearchItemForm()
    return render_template('keyword_items.html',
                           item_keywords=item_keywords,
                           keyword=keyword,
                           itemsall=itemsall,
                           texts=texts,
                           searchform=searchform)
예제 #17
0
def update_target(target_id):
    target = Target.query.get_or_404(target_id)
    if target.searcher != current_user:
        abort(403)
    form = CreateTargetForm()
    if form.validate_on_submit():
        target.name = form.name.data
        db.session.commit()
        flash(gettext('Your target has been updated'), 'success')
        return redirect(url_for('users.account'))
    elif request.method == 'GET':
        form.name.data = target.name
    itemsall = Item.query.order_by(Item.date_posted.desc()).all()
    searchform = SearchItemForm()
    return render_template('create_target.html',
                           title="Update Target",
                           form=form,
                           legend=gettext('Update Target'),
                           target=target,
                           itemsall=itemsall,
                           searchform=searchform)
예제 #18
0
def reset_token(token):
    if current_user.is_authenticated:
        return redirect(url_for('main.home'))
    user = User.verify_reset_token(token)
    if user is None:
        flash(gettext('That is an invalid or expired token'), "warning")
        return redirect(url_for('users.reset_request'))
    form = ResetPasswordForm()
    if form.validate_on_submit():
        hashedpassword = bcrypt.generate_password_hash(
            form.password.data).decode('utf-8')
        user.password = hashedpassword
        db.session.commit()
        flash(f'Your password has been updated! you are able to log in',
              'success')
        return redirect(url_for('users.login'))
    itemsall = Item.query.order_by(Item.date_posted.desc()).all()
    searchform = SearchItemForm()
    return render_template('reset_token.html',
                           title='Reset Password',
                           form=form,
                           itemsall=itemsall,
                           searchform=searchform)
예제 #19
0
def register():
    if current_user.is_authenticated:
        return redirect(url_for('main.home'))
    form = RegistrationForm()
    if form.validate_on_submit():
        hashedpassword = bcrypt.generate_password_hash(
            form.password.data).decode('utf-8')
        user = User(username=form.username.data,
                    email=form.email.data,
                    password=hashedpassword)
        db.session.add(user)
        db.session.commit()
        current_app.logger.info('New user registered {} {}'.format(
            user.username, user.email))
        flash(gettext('Your account has been created! you are able to log in'),
              'success')
        return redirect(url_for('users.login'))
    itemsall = Item.query.order_by(Item.date_posted.desc()).all()
    searchform = SearchItemForm()
    return render_template('register.html',
                           title='Register',
                           form=form,
                           itemsall=itemsall,
                           searchform=searchform)
예제 #20
0
def new_item():
    form = CreateItemForm()
    if form.validate_on_submit():
        if form.item_file.data:
            try:
                itemfile = save_item(form.item_file.data)
                thumbnailfile = save_thumbnail(form.item_file.data)
            except Exception as e:
                current_app.logger.warning('File {} of {}: {}'.format(
                    form.item_file.data, current_user.username, e))
                flash(gettext('No item can be created for this file'),
                      'danger')
                return redirect(url_for('items.new_item'))
            else:
                item = Item(item_file=itemfile,
                            itemname=form.itemname.data,
                            thumbnail=thumbnailfile,
                            owner=current_user,
                            analysis_keywords=form.analysis_keywords.data,
                            analysis_persons=form.analysis_persons.data,
                            analysis_celebs=form.analysis_celebs.data,
                            analysis_targets=form.analysis_targets.data,
                            analysis_text=form.analysis_text.data,
                            analysis_labels=form.analysis_labels.data,
                            analysis_threshold=form.analysis_threshold.data)
                db.session.add(item)
                db.session.commit()
                try:
                    object_and_scene_detection_error = True
                    facial_analysis_error = True
                    celebrity_recognition_error = True
                    face_comparison_error = True
                    text_detection_error = True
                    unsafe_content_detection_error = True
                    # Object and scene detection - Keywords
                    object_and_scene_detection(item=item)
                    object_and_scene_detection_error = False
                    # Facial analysis - Persons
                    facial_analysis(item=item)
                    facial_analysis_error = False
                    # Celebrity recognition
                    celebrity_recognition(item=item)
                    celebrity_recognition_error = False
                    # Face comparision
                    face_comparison(item=item)
                    face_comparison_error = False
                    # Test in item
                    text_detection(item=item)
                    text_detection_error = False
                    # Image moderation
                    unsafe_content_detection(item=item)
                    unsafe_content_detection_error = False
                except Exception:
                    current_app.logger.exception(
                        'Analysis item {} of {} incomplete: {} / {} / {} / {} / {} / {}'
                        .format(form.item_file.data, current_user.username,
                                object_and_scene_detection_error,
                                facial_analysis_error,
                                celebrity_recognition_error,
                                face_comparison_error, text_detection_error,
                                unsafe_content_detection_error))
                    flash(gettext('The item cannot be analysed completly'),
                          'danger')
                else:
                    flash(gettext('Your new item has been created'), 'success')
                return redirect(url_for('items.item', item_id=item.id))
    itemsall = Item.query.order_by(Item.date_posted.desc()).all()
    form.analysis_keywords.data = True
    form.analysis_threshold.data = 90
    searchform = SearchItemForm()
    return render_template('create_item.html',
                           title='New Item',
                           form=form,
                           legend=gettext('New Item'),
                           itemsall=itemsall,
                           searchform=searchform)
예제 #21
0
def about():
    db.drop_all()
    db.create_all()
    itemsall = Item.query.order_by(Item.date_posted.desc()).all()
    searchform = SearchItemForm()
    return render_template('about.html', title='About', itemsall=itemsall, searchform=searchform)
예제 #22
0
def results(search_query):
    page = request.args.get('page', 1, type=int)
    if search_query != str('*'):
        itemscollect = Item.query.filter(
            Item.itemname.contains(search_query)).distinct()
    else:
        itemscollect = Item.query.order_by(Item.date_posted.desc())

    if request.args.get('search_keywords') == 'True':
        itemscollect1 = Item.query.join(ItemKeyword).join(Keyword).filter(
            Keyword.keywordtextname.contains(search_query)).distinct()
        itemscollect2 = itemscollect1.union(itemscollect)
        itemscollect = itemscollect2
        itemscollect1 = Item.query.join(Person).join(PersonAttribute).join(
            Attribute).filter(
                Attribute.attributetextname.contains(search_query)).distinct()
        itemscollect2 = itemscollect1.union(itemscollect)
        itemscollect = itemscollect2

    if request.args.get('search_celebs') == 'True':
        itemscollect1 = Item.query.join(Person).join(Celebrity).filter(
            Celebrity.name.contains(search_query)).distinct()
        itemscollect2 = itemscollect1.union(itemscollect)
        itemscollect = itemscollect2

    if request.args.get('search_text') == 'True':
        itemscollect1 = Item.query.filter(
            Item.text.contains(search_query)).distinct()
        itemscollect2 = itemscollect1.union(itemscollect)
        itemscollect = itemscollect2
    if request.args.get('search_targets'):
        itemscollect = itemscollect.join(Person).join(Targetimage).join(
            Target).filter_by(id=request.args.get('search_targets'))
    if request.args.get('myitemsonly') == 'True':
        itemscollect = itemscollect.filter_by(owner=current_user)

    items = itemscollect.distinct().paginate(page=page, per_page=8)
    texts = {}
    for item in items.items:
        line1, line2, line3, line4, foundkeywords, foundtargets, foundcelebrities, foundtext, foundlabel, entry = create_texts(
            item)
        texts[item.id] = entry

    itemsall = Item.query.order_by(Item.date_posted.desc()).all()
    formsearch = SearchItemForm()
    formfilter = FilterItemForm()
    formsearch.searchtext.data = request.args.get('searchtexthidden')
    if request.args.get('search_keywords') == 'True':
        formfilter.search_keywords.data = request.args.get('search_keywords')
    if request.args.get('search_attributes') == 'True':
        formfilter.search_attributes.data = request.args.get(
            'search_attributes')
    if request.args.get('search_celebs') == 'True':
        formfilter.search_celebs.data = request.args.get('search_celebs')
    if request.args.get('search_text') == 'True':
        formfilter.search_text.data = request.args.get('search_text')
    if request.args.get('myitemsonly') == 'True':
        formfilter.myitemsonly.data = request.args.get('myitemsonly')
    formfilter.search_age.data = request.args.get('search_age')
    formfilter.searchtexthidden.data = request.args.get('searchtexthidden')

    if current_user.is_authenticated:
        choices = Target.query.filter_by(searcher=current_user)
        formfilter.search_targets.query = choices
        if request.args.get('search_targets'):
            select = Target.query.get(request.args.get('search_targets'))
            formfilter.search_targets.process_data(select)

    return render_template('searchresults.html',
                           title='Search',
                           legend=gettext('Item search'),
                           searchform=formsearch,
                           filterform=formfilter,
                           items=items,
                           itemsall=itemsall,
                           texts=texts,
                           search_query=search_query)
예제 #23
0
def error_404(error):
    itemsall = Item.query.order_by(Item.date_posted.desc()).all()
    searchform = SearchItemForm()
    return render_template('errors/404.html',
                           itemsall=itemsall,
                           searchform=searchform), 404
예제 #24
0
def update_item(item_id):
    item = Item.query.get_or_404(item_id)
    if item.owner != current_user:
        abort(403)
    form = CreateItemForm()
    if form.validate_on_submit():
        if form.item_file.data:
            try:
                item.item_file = save_item(form.item_file.data)
                item.thumbnail = save_thumbnail(form.item_file.data)
            except Exception as e:
                current_app.logger.warning('File {} of {}: {}'.format(
                    form.item_file.data, current_user.username, e))
                flash(gettext('The item cannot be updated for this file'),
                      'danger')
                return redirect(url_for('items.update_item', item_id=item.id))
        item.itemname = form.itemname.data
        item.analysis_keywords = form.analysis_keywords.data
        item.analysis_persons = form.analysis_persons.data
        item.analysis_celebs = form.analysis_celebs.data
        item.analysis_targets = form.analysis_targets.data
        item.analysis_text = form.analysis_text.data
        item.analysis_labels = form.analysis_labels.data
        item.analysis_threshold = form.analysis_threshold.data
        db.session.query(ItemKeyword).filter(
            ItemKeyword.item_id == item_id).delete()
        db.session.query(Person).filter(Person.item_id == item_id).delete()
        db.session.commit()
        try:
            object_and_scene_detection_error = True
            facial_analysis_error = True
            celebrity_recognition_error = True
            face_comparison_error = True
            text_detection_error = True
            unsafe_content_detection_error = True
            # Object and scene detection - Keywords
            object_and_scene_detection(item=item)
            object_and_scene_detection_error = False
            # Facial analysis - Persons
            facial_analysis(item=item)
            facial_analysis_error = False
            # Celebrity recognition
            celebrity_recognition(item=item)
            celebrity_recognition_error = False
            # Face comparision
            face_comparison(item=item)
            face_comparison_error = False
            # Test in item
            text_detection(item=item)
            text_detection_error = False
            # Image moderation
            unsafe_content_detection(item=item)
            unsafe_content_detection_error = False
        except Exception:
            current_app.logger.exception(
                'Analysis item {} of {} incomplete: {} / {} / {} / {} / {} / {}'
                .format(form.item_file.data, current_user.username,
                        object_and_scene_detection_error,
                        facial_analysis_error, celebrity_recognition_error,
                        face_comparison_error, text_detection_error,
                        unsafe_content_detection_error))
            flash(gettext('The item cannot be analysed completly'), 'danger')
        else:
            flash(gettext('Your item has been updated'), 'success')
        return redirect(url_for('items.item', item_id=item.id))
    elif request.method == 'GET':
        form.itemname.data = item.itemname
        form.item_file.data = item.item_file
        form.analysis_keywords.data = item.analysis_keywords
        form.analysis_persons.data = item.analysis_persons
        form.analysis_celebs.data = item.analysis_celebs
        form.analysis_targets.data = item.analysis_targets
        form.analysis_text.data = item.analysis_text
        form.analysis_labels.data = item.analysis_labels
        form.analysis_threshold.data = item.analysis_threshold
    itemsall = Item.query.order_by(Item.date_posted.desc()).all()
    itemkeywords = ItemKeyword.query.filter_by(itemin=item).all()
    persons = Person.query.filter_by(itemin=item)
    attributes = {}
    for person in persons:
        personattributes = PersonAttribute.query.filter_by(
            referenceperson=person).all()
        attributes[person.id] = personattributes
    searchform = SearchItemForm()
    return render_template('create_item.html',
                           title="Update Item",
                           form=form,
                           legend=gettext('Update Item'),
                           item=item,
                           itemsall=itemsall,
                           itemkeywords=itemkeywords,
                           persons=persons,
                           searchform=searchform)
예제 #25
0
def new_multipleitem():
    form = MultipleItemForm()

    if form.validate_on_submit():
        pics = request.files.getlist(form.item_files.name)
        if pics:
            current_user.multipleupload = len(pics)
            db.session.commit()
            founderror = False
            for pic in pics:
                filename = pic.filename
                try:
                    itemfile = save_item(pic)
                    thumbnailfile = save_thumbnail(pic)
                except Exception as e:
                    current_app.logger.warning('File {} of {}: {}'.format(
                        pic.filename, current_user.username, e))
                    founderror = True
                else:
                    itemname = form.itemname.data + " - " + filename
                    if len(itemname) > 35:
                        itemname = itemname[0:32] + "..."
                    item = Item(
                        item_file=itemfile,
                        itemname=itemname,
                        thumbnail=thumbnailfile,
                        owner=current_user,
                        analysis_keywords=form.analysis_keywords.data,
                        analysis_persons=form.analysis_persons.data,
                        analysis_celebs=form.analysis_celebs.data,
                        analysis_targets=form.analysis_targets.data,
                        analysis_text=form.analysis_text.data,
                        analysis_labels=form.analysis_labels.data,
                        analysis_threshold=form.analysis_threshold.data)
                    db.session.add(item)
                    db.session.commit()
                    try:
                        object_and_scene_detection_error = True
                        facial_analysis_error = True
                        celebrity_recognition_error = True
                        face_comparison_error = True
                        text_detection_error = True
                        unsafe_content_detection_error = True
                        # Object and scene detection - Keywords
                        object_and_scene_detection(item=item)
                        object_and_scene_detection_error = False
                        # Facial analysis - Persons
                        facial_analysis(item=item)
                        facial_analysis_error = False
                        # Celebrity recognition
                        celebrity_recognition(item=item)
                        celebrity_recognition_error = False
                        # Face comparision
                        face_comparison(item=item)
                        face_comparison_error = False
                        # Test in item
                        text_detection(item=item)
                        text_detection_error = False
                        # Image moderation
                        unsafe_content_detection(item=item)
                        unsafe_content_detection_error = False
                    except Exception:
                        current_app.logger.exception(
                            'Analysis item {} of {} incomplete: {} / {} / {} / {} / {} / {}'
                            .format(pic.filename, current_user.username,
                                    object_and_scene_detection_error,
                                    facial_analysis_error,
                                    celebrity_recognition_error,
                                    face_comparison_error,
                                    text_detection_error,
                                    unsafe_content_detection_error))
                        founderror = True
            if founderror:
                flash(
                    gettext(
                        'The new items could not be created and analysed completly'
                    ), 'danger')
            else:
                flash(gettext('Your new items have been created'), 'success')
            return redirect(url_for('main.home'))
    itemsall = Item.query.order_by(Item.date_posted.desc()).all()
    form.analysis_keywords.data = True
    form.analysis_threshold.data = 90
    searchform = SearchItemForm()
    return render_template('multiple_item.html',
                           title='New Items',
                           form=form,
                           legend=gettext('New Items'),
                           itemsall=itemsall,
                           searchform=searchform)