Example #1
0
def facemask():
    cache.init_app(app2)
    with app2.app_context():
        cache.clear()
    text = "none"
    fish = glob.glob('./static/outputs/output_mask/*')
    for f in fish:
        os.remove(f)
    fish = glob.glob('MaskTheFace/data/*')
    for f in fish:
        os.remove(f)
    return render_template('facemask.html', text=text)
Example #2
0
def party():
	cache.init_app(app2)
	with app2.app_context():
			cache.clear()
	text = "none"
	fish = glob.glob('./output/second/TOM/val/*')
	for f in fish:
		os.remove(f)
	party_cloth  = ['000003' , '000108', '001719' ,'000178', '000182' , '001428' , '004710' , '017374','002061', '017642', '017377', '017963', '019067','019564', '017643']
	for i in range(len(party_cloth)):
		party_cloth[i] = (str(party_cloth[i])+"_1.jpg")
	return render_template('party_wear.html', party = party_cloth, text=text)
Example #3
0
def party():
    cache.init_app(app2)
    with app2.app_context():
        cache.clear()
    text = "none"
    fish = glob.glob('./output/second/TOM/val/*')
    for f in fish:
        os.remove(f)
    fish = glob.glob('./static/outputs/output_f/*')
    for f in fish:
        os.remove(f)
    party = [
        'Orach-Flayrd', 'MultiColor', 'Butterfly_p', 'Waved-Black', 'Shimm',
        'Wavy-Red', 'Wavy-Pink', 'Reddish-KNOTS'
    ]
    for i in range(len(party)):
        party[i] = (str(party[i]) + ".jpg")
    return render_template('party_wear.html', party=party, text=text)
Example #4
0
def tshirt():
    cache.init_app(app2)
    with app2.app_context():
        cache.clear()
    text = "none"
    fish = glob.glob('./output/second/TOM/val/*')
    for f in fish:
        os.remove(f)
    fish = glob.glob('./static/outputs/output_f/*')
    for f in fish:
        os.remove(f)
    tshirt = [
        'POLO_Black', 'POLO-blue', 'POLO-Blue', 'POLO-BLue', 'POLO-orach',
        'POLO-Violet'
    ]
    for i in range(len(tshirt)):
        tshirt[i] = (str(tshirt[i]) + ".jpg")
    return render_template('tshirt.html', tshirt=tshirt, text=text)
Example #5
0
def sports():
    cache.init_app(app2)
    with app2.app_context():
        cache.clear()
    text = "none"
    fish = glob.glob('./output/second/TOM/val/*')
    for f in fish:
        os.remove(f)
    fish = glob.glob('./static/outputs/output_f/*')
    for f in fish:
        os.remove(f)
    sport_cloth = [
        'ADIDAS-BW', 'ADIDAS_Black', 'FILA_grey', 'FILA-Pink', 'IVY-Black',
        'NIKE-grey'
    ]
    for i in range(len(sport_cloth)):
        sport_cloth[i] = (str(sport_cloth[i]) + ".jpg")
    return render_template('sports.html', sports=sport_cloth, text=text)
Example #6
0
def upload_image4():
	cache.init_app(app2)
	with app2.app_context():
			cache.clear()
	party_cloth = ['000003' , '000108', '001719' ,'017376' ,'000178', '000182' , '001428' , '004710' , '008632' , '017374','002061', '017642', '017377', '017963', '018348', '019067','019564', '017643']
	for i in range(len(party_cloth)):
		party_cloth[i] = (str(party_cloth[i])+"_1.jpg")

	if request.method=="POST":
		# if 'file' not in request.files:
		# 	flash('No file part')
		# 	return redirect(request.url)
		
		text = request.form['input_text']
		file = request.files['file']
		
		if file.filename == '':
			flash('No image selected for uploading')
			return redirect(request.url)
		
		if file and allowed_file(file.filename) and text:
			filename = secure_filename(file.filename)
			file.save(os.path.join(app.config['UPLOAD_FOLDER1'], filename))
			i_path = 'static/Database/val/person/'
			input_img = text+'.jpg'
			os.rename(i_path+filename , i_path+input_img)
			filename = text+'.jpg'
			o_path = './output/second/TOM/val'
			# fish = glob.glob('./output/second/TOM/val/*')
			fish = glob.glob('./static/output_f/*')
			for f in fish:
				os.remove(f)
			time.sleep(10)			#
			#
			#
			# 
			pose_parse(text)
			valpair_file = 'static/Database/val_pairs.txt'
			
			for i in range(len(party_cloth)):
				with open(valpair_file , "w") as f:
						f.write(text+'.jpg '+ party_cloth[i] )
						f.close()
						predict()
						im = Image.open(os.path.join(o_path,party_cloth[i]))
						width, height = im.size
						left = width / 3
						top = 2 * height / 3
						right = 2 * width / 3
						bottom = height
						im = im.crop((left, top, right, bottom)) 
						newsize = (200, 270) 
						im = im.resize(newsize)
						im.save(os.path.join(app2.config['OUTPUT_FOLDER3'],party_cloth[i]))
			#
			#
			#
			return render_template('party_wear.html', party=party_cloth, text= text)
		else:
			flash('Allowed image types are -> png, jpg, jpeg, gif')
			return redirect(request.url)
	return render_template('party_wear.html')
Example #7
0
def upload_image6():
    cache.init_app(app2)
    with app2.app_context():
        cache.clear()
    fish = glob.glob('./static/outputs/output_mask/*')
    for f in fish:
        os.remove(f)
    fish = glob.glob('MaskTheFace/data/*')
    for f in fish:
        os.remove(f)

    if request.method == "POST":
        text = "Face-Mask"
        file = request.files['file']

        if file.filename == '':
            flash('No image uploaded for size prediction.')
            return redirect(request.url)

        if file and allowed_file(file.filename) and text:
            filename = secure_filename(file.filename)
            file.save(os.path.join(app.config['UPLOAD_FOLDER3'], filename))
            #
            i_path = 'MaskTheFace/data/'
            input_img = text + '.jpg'
            os.rename(i_path + filename, i_path + input_img)
            zpath = os.path.join(i_path, input_img)
            print(i_path)
            # time.sleep(10)			#
            #

            opath = 'static/outputs/output_mask/'
            mask_type = [
                'N95', 'surgical', 'cloth', 'N95', 'surgical', 'cloth', 'N95',
                'surgical', 'cloth', 'N95', 'surgical', 'cloth', 'cloth'
            ]
            mask_color = [
                "#fc1c1a", "#177ABC", "#94B6D2", "#A5AB81", "#DD8047",
                "#6b425e", "#e26d5a", "#c92c48", "#6a506d", "#ffc900",
                "#ffffff", "#000000", "#49ff00"
            ]

            out_files = []
            for i in range(13):
                mask_the_face.run_function(zpath, mask_type[i], '', '0',
                                           mask_color[i], '0', '', 'verbose',
                                           'write_original_image')
                out_files.append(text + "_" + str(mask_type[i]) + '.jpg')
                im = Image.open(os.path.join(i_path, out_files[-1]))
                im.save(
                    os.path.join(app2.config['OUTPUT_FOLDER4'], out_files[-1]))
                new_name = text + str(i) + '.jpg'
                os.rename(opath + out_files[-1], opath + new_name)
                out_files[-1] = new_name
            return render_template('facemask.html',
                                   text=text,
                                   out_files=out_files)
        else:
            flash('Allowed image types are -> png, jpg, jpeg, gif')
            return redirect(request.url)
    return render_template('facemask.html')
Example #8
0
def upload_image5():
    cache.init_app(app2)
    with app2.app_context():
        cache.clear()
    fish = glob.glob('./static/Database/val/person/*')
    for f in fish:
        os.remove(f)
    fish = glob.glob('./static/size/*')
    for f in fish:
        os.remove(f)
    tshirt = [
        'POLO_Black', 'POLO-blue', 'POLO-Blue', 'POLO-BLue', 'POLO-orach',
        'POLO-Violet'
    ]
    for i in range(len(tshirt)):
        tshirt[i] = (str(tshirt[i]) + ".jpg")

    if request.method == "POST":
        text = "tshirtss"
        file = request.files['file']
        file1 = request.files['file1']
        height = request.form['height']
        unit = request.form.get('unit')
        Go = "False"

        if file.filename == '':
            flash('No image uploaded for size prediction.')
            return redirect(request.url)

        if file1.filename == '':
            flash('No image uploaded for trying clothes.')
            return redirect(request.url)

        if file and allowed_file(file.filename) and file1 and allowed_file(
                file1.filename) and height and unit and text:
            filename = secure_filename(file.filename)
            filename1 = secure_filename(file1.filename)
            file1.save(os.path.join(app.config['UPLOAD_FOLDER2'], filename1))
            i_path = 'static/size/'
            file_path = os.path.join(i_path, filename1)
            size = women_size_predict(file_path, height, unit)
            #
            file.save(os.path.join(app.config['UPLOAD_FOLDER1'], filename))
            i_path = 'static/Database/val/person/'
            input_img = text + '.jpg'
            os.rename(i_path + filename, i_path + input_img)
            filename = text + '.jpg'
            o_path = './output/second/TOM/val'
            # time.sleep(10)			#
            #
            #
            #
            pose_parse(text)
            valpair_file = 'static/Database/val_pairs.txt'

            for i in range(len(tshirt)):
                with open(valpair_file, "w") as f:
                    f.write(text + '.jpg ' + tshirt[i])
                    f.close()
                    predict()
                    im = Image.open(os.path.join(o_path, tshirt[i]))
                    width, height = im.size
                    left = width / 3
                    top = 2 * height / 3
                    right = 2 * width / 3
                    bottom = height
                    im = im.crop((left, top, right, bottom))
                    newsize = (200, 270)
                    im = im.resize(newsize)
                    im.save(
                        os.path.join(app2.config['OUTPUT_FOLDER3'], tshirt[i]))
            #
            #
            #
            ##
            ##
            return render_template('tshirt.html',
                                   tshirt=tshirt,
                                   text=text,
                                   size=size)
        else:
            flash('Allowed image types are -> png, jpg, jpeg, gif')
            return redirect(request.url)
    return render_template('tshirt.html')
Example #9
0
def upload_image4():
    cache.init_app(app2)
    with app2.app_context():
        cache.clear()
    fish = glob.glob('./static/Database/val/person/*')
    for f in fish:
        os.remove(f)
    fish = glob.glob('./static/size/*')
    for f in fish:
        os.remove(f)
    party = [
        'Orach-Flayrd', 'MultiColor', 'Butterfly_p', 'Waved-Black', 'Shimm',
        'Wavy-Red', 'Wavy-Pink', 'Reddish-KNOTS'
    ]
    for i in range(len(party)):
        party[i] = (str(party[i]) + ".jpg")

    if request.method == "POST":

        text = "palty"
        file = request.files['file']
        height = request.form['height']
        unit = request.form.get('unit')
        Go = "False"

        if file.filename == '':
            flash('No image uploaded for trying clothes.')
            return redirect(request.url)

        if file and allowed_file(file.filename) and height and unit and text:
            filename = secure_filename(file.filename)
            file.save(os.path.join(app.config['UPLOAD_FOLDER2'], filename))
            i_path = 'static/size/'
            file_path = os.path.join(i_path, filename)
            size, file = women_size_predict1(file_path, height, unit)
            file = Image.fromarray(file, 'RGB')
            #
            file.save(os.path.join(app.config['UPLOAD_FOLDER1'], filename))
            i_path = 'static/Database/val/person/'
            input_img = text + '.jpg'
            os.rename(i_path + filename, i_path + input_img)
            filename = text + '.jpg'
            o_path = './output/second/TOM/val'
            # fish = glob.glob('./output/second/TOM/val/*')
            fish = glob.glob('./static/outputs/output_f/*')
            for f in fish:
                os.remove(f)
            time.sleep(10)  #
            #
            #
            #
            pose_parse(text)
            valpair_file = 'static/Database/val_pairs.txt'

            for i in range(len(party)):
                with open(valpair_file, "w") as f:
                    f.write(text + '.jpg ' + party[i])
                    f.close()
                    predict()
                    im = Image.open(os.path.join(o_path, party[i]))
                    width, height = im.size
                    left = width / 3
                    top = 2 * height / 3
                    right = 2 * width / 3
                    bottom = height
                    im = im.crop((left, top, right, bottom))
                    newsize = (200, 270)
                    im = im.resize(newsize)
                    im.save(
                        os.path.join(app2.config['OUTPUT_FOLDER3'], party[i]))
            #
            #
            #
            ##
            ##
            return render_template('party_wear.html',
                                   party=party,
                                   text=text,
                                   size=size)
        else:
            flash('Allowed image types are -> png, jpg, jpeg, gif')
            return redirect(request.url)
    return render_template('party_wear.html')
Example #10
0
def upload_image3():
    cache.init_app(app2)
    with app2.app_context():
        cache.clear()
    fish = glob.glob('./static/Database/val/person/*')
    for f in fish:
        os.remove(f)
    fish = glob.glob('./static/size/*')
    for f in fish:
        os.remove(f)
    brand_cloth = [
        'Pink-Flayrd', 'Blue-flayrd', 'Flayerd-Yellow', 'Bluish-Flayrd',
        'NIKE-black', 'RED-Flayrd'
    ]  #'
    for i in range(len(brand_cloth)):
        brand_cloth[i] = (str(brand_cloth[i]) + ".jpg")

    if request.method == "POST":

        text = "brandss"
        file = request.files['file']
        height = request.form['height']
        unit = request.form.get('unit')

        if file.filename == '':
            flash('No image selected for uploading')
            return redirect(request.url)

        if file and allowed_file(file.filename) and height and unit:
            filename = secure_filename(file.filename)
            file.save(os.path.join(app.config['UPLOAD_FOLDER2'], filename))
            i_path = 'static/size/'
            file_path = os.path.join(i_path, filename)
            size, file = women_size_predict1(file_path, height, unit)
            file = Image.fromarray(file, 'RGB')
            #
            file.save(os.path.join(app.config['UPLOAD_FOLDER1'], filename))
            i_path = 'static/Database/val/person/'
            input_img = text + '.jpg'
            os.rename(i_path + filename, i_path + input_img)
            filename = text + '.jpg'
            o_path = './output/second/TOM/val'
            # fish = glob.glob('./output/second/TOM/val/*')
            fish = glob.glob('./static/outputs/output_f/*')
            for f in fish:
                os.remove(f)
            time.sleep(10)
            #
            #
            #
            #
            pose_parse(text)
            valpair_file = 'static/Database/val_pairs.txt'

            for i in range(len(brand_cloth)):
                with open(valpair_file, "w") as f:
                    f.write(text + '.jpg ' + brand_cloth[i])
                    f.close()
                    predict()
                    im = Image.open(os.path.join(o_path, brand_cloth[i]))
                    width, height = im.size
                    left = width / 3
                    top = 2 * height / 3
                    right = 2 * width / 3
                    bottom = height
                    im = im.crop((left, top, right, bottom))
                    newsize = (200, 270)
                    im = im.resize(newsize)
                    im.save(
                        os.path.join(app2.config['OUTPUT_FOLDER3'],
                                     brand_cloth[i]))
            #
            #
            #
            return render_template('brands.html',
                                   brands=brand_cloth,
                                   text=text,
                                   size=size)
        else:
            flash('Allowed image types are -> png, jpg, jpeg, gif')
            return redirect(request.url)
    return render_template('brands.html')
Example #11
0
def upload_image2():
    cache.init_app(app2)
    with app2.app_context():
        cache.clear()
    fish = glob.glob('./static/Database/val/person/*')
    for f in fish:
        os.remove(f)
    fish = glob.glob('./static/size/*')
    for f in fish:
        os.remove(f)
    sport_cloth = [
        'ADIDAS-BW', 'ADIDAS_Black', 'FILA_grey', 'FILA-Pink', 'IVY-Black',
        'NIKE-grey'
    ]
    for i in range(len(sport_cloth)):
        sport_cloth[i] = (str(sport_cloth[i]) + ".jpg")

    if request.method == "POST":
        if 'file' not in request.files:
            flash('No file part')
            return redirect(request.url)

        text = "sportss"
        file = request.files['file']
        height = request.form['height']
        unit = request.form.get('unit')
        Go = "False"

        if file.filename == '':
            flash('No image uploaded for size prediction.')
            return redirect(request.url)

        if file and allowed_file(file.filename) and height and unit:
            filename = secure_filename(file.filename)
            file.save(os.path.join(app.config['UPLOAD_FOLDER2'], filename))
            i_path = 'static/size/'
            file_path = os.path.join(i_path, filename)
            size, file = women_size_predict1(file_path, height, unit)
            file = Image.fromarray(file, 'RGB')
            #
            file.save(os.path.join(app.config['UPLOAD_FOLDER1'], filename))
            i_path = 'static/Database/val/person/'
            input_img = text + '.jpg'
            os.rename(i_path + filename, i_path + input_img)
            filename = text + '.jpg'
            o_path = './output/second/TOM/val'
            # fish = glob.glob('./output/second/TOM/val/*')
            fish = glob.glob('./static/outputs/output_f/*')
            for f in fish:
                os.remove(f)
            time.sleep(10)
            #
            #
            #
            #
            pose_parse(text)
            valpair_file = 'static/Database/val_pairs.txt'

            for i in range(len(sport_cloth)):
                with open(valpair_file, "w") as f:
                    f.write(text + '.jpg ' + sport_cloth[i])
                    f.close()
                    predict()
                    im = Image.open(os.path.join(o_path, sport_cloth[i]))
                    width, height = im.size
                    left = width / 3
                    top = 2 * height / 3
                    right = 2 * width / 3
                    bottom = height
                    im = im.crop((left, top, right, bottom))
                    newsize = (200, 270)
                    im = im.resize(newsize)
                    im.save(
                        os.path.join(app2.config['OUTPUT_FOLDER3'],
                                     sport_cloth[i]))
            #
            #
            #
            return render_template('sports.html',
                                   sports=sport_cloth,
                                   text=text,
                                   size=size)
        else:
            flash('Allowed image types are -> png, jpg, jpeg, gif')
            return redirect(request.url)
    return render_template('sports.html')
Example #12
0
def upload_image():
    cache.init_app(app2)
    with app2.app_context():
        cache.clear()
    fish = glob.glob('./static/Database/val/person/*')
    for f in fish:
        os.remove(f)
    fish = glob.glob('./static/size/*')
    for f in fish:
        os.remove(f)
    cloth = [
        'Casual-Yellow', 'Casual-Pink', 'Casual-Violet', 'Casual-White',
        'Dark_ORANGE', 'Flowers-White', 'Grey_North', 'Light-Pink',
        'Multicolo-White', 'Sky_Blue', 'TheNORTHface', 'Yellow62'
    ]
    for i in range(len(cloth)):
        cloth[i] = (str(cloth[i]) + ".jpg")

    if request.method == "POST":
        if 'file' not in request.files:
            flash('No file part')
            return redirect(request.url)

        text = "casualss"
        file = request.files['file']
        height = request.form['height']
        unit = request.form.get('unit')

        if file.filename == '':
            flash('No image selected for uploading')
            return redirect(request.url)

        if file and allowed_file(file.filename) and text and height and unit:
            filename = secure_filename(file.filename)
            file.save(os.path.join(app.config['UPLOAD_FOLDER2'], filename))
            i_path = 'static/size/'
            file_path = os.path.join(i_path, filename)
            size, file = women_size_predict1(file_path, height, unit)
            file = Image.fromarray(file, 'RGB')
            #
            file.save(os.path.join(app.config['UPLOAD_FOLDER1'], filename))
            i_path = 'static/Database/val/person/'
            input_img = text + '.jpg'
            os.rename(i_path + filename, i_path + input_img)
            filename = text + '.jpg'
            o_path = './output/second/TOM/val'
            # fish = glob.glob('./output/second/TOM/val/*')
            fish = glob.glob('./static/outputs/output_f/*')
            for f in fish:
                os.remove(f)
            time.sleep(10)
            #
            #
            #
            #
            pose_parse(text)
            valpair_file = 'static/Database/val_pairs.txt'

            for i in range(len(cloth)):
                with open(valpair_file, "w") as f:
                    f.write(text + '.jpg ' + cloth[i])
                    f.close()
                    predict()
                    im = Image.open(os.path.join(o_path, cloth[i]))
                    width, height = im.size
                    left = width / 3
                    top = 2 * height / 3
                    right = 2 * width / 3
                    bottom = height
                    im = im.crop((left, top, right, bottom))
                    newsize = (200, 270)
                    im = im.resize(newsize)
                    im.save(
                        os.path.join(app2.config['OUTPUT_FOLDER3'], cloth[i]))
            #
            #
            #
            return render_template('casuals.html',
                                   casuals=cloth,
                                   text=text,
                                   size=size)
        else:
            flash('Allowed image types are -> png, jpg, jpeg, gif')
            return redirect(request.url)
    return render_template('casuals.html')