def get_data_from_frontend(): r = request.get_json() json_text = r with open("users.json", 'w', encoding='utf-8') as f: json.dump(json_text, f, ensure_ascii=False, indent=4) print(jsonify(reco.reco())) return jsonify(reco.reco())
for quality in range(0, 101, 1): subprocess.check_call('gm convert %s -quality %d %s' % (ref_file, quality, dist_file), shell=True) file_size = os.path.getsize(dist_file) dist = scipy.misc.imread(dist_file, flatten=True).astype(numpy.float32) quality_values.append(quality) size_values.append(int(file_size / 1024)) vifp_values.append(vifp.vifp_mscale(ref, dist)) ssim_values.append(ssim.ssim_exact(ref / 255, dist / 255)) psnr_values.append(psnr.psnr(ref, dist)) # niqe_values.append( niqe.niqe(dist/255) ) reco_values.append(reco.reco(ref / 255, dist / 255)) plt.plot(quality_values, vifp_values, label='VIFP') plt.plot(quality_values, ssim_values, label='SSIM') # plt.plot(niqe_values, label='NIQE') plt.plot(quality_values, reco_values, label='RECO') plt.plot(quality_values, numpy.asarray(psnr_values) / 100.0, label='PSNR/100') plt.legend(loc='lower right') plt.xlabel('JPEG Quality') plt.ylabel('Metric') plt.savefig('jpg_demo_quality.png') plt.figure(figsize=(8, 8)) plt.plot(size_values, vifp_values, label='VIFP') plt.plot(size_values, ssim_values, label='SSIM')
print "Frame=%d VIFP=%f SSIM=%f" % (frame_num, vifp_value, ssim_value) frame_num += 1 else: # Inputs are image files ref = scipy.misc.imread(ref_file, flatten=True).astype(numpy.float32) dist = scipy.misc.imread(dist_file, flatten=True).astype(numpy.float32) width, height = ref.shape[1], ref.shape[0] print "Comparing %s to %s, resolution %d x %d" % (ref_file, dist_file, width, height) vifp_value = vifp.vifp_mscale(ref, dist) print "VIFP=%f" % (vifp_value) ssim_value = ssim.ssim_exact(ref / 255, dist / 255) print "SSIM=%f" % (ssim_value) # FIXME this is buggy, disable for now # ssim_value2 = ssim.ssim(ref/255, dist/255) # print "SSIM approx=%f" % (ssim_value2) psnr_value = psnr.psnr(ref, dist) print "PSNR=%f" % (psnr_value) # niqe_value = niqe.niqe(dist/255) # print "NIQE=%f" % (niqe_value) reco_value = reco.reco(ref / 255, dist / 255) print "RECO=%f" % (reco_value)
ssim_value = ssim.ssim(ref, dist) print "Frame=%d VIFP=%f SSIM=%f" % (frame_num, vifp_value, ssim_value) frame_num += 1 else: # Inputs are image files ref = scipy.misc.imread(ref_file, flatten=True).astype(numpy.float32) dist = scipy.misc.imread(dist_file, flatten=True).astype(numpy.float32) width, height = ref.shape[1], ref.shape[0] print "Comparing %s to %s, resolution %d x %d" % (ref_file, dist_file, width, height) vifp_value = vifp.vifp_mscale(ref, dist) print "VIFP=%f" % (vifp_value) ssim_value = ssim.ssim_exact(ref / 255, dist / 255) print "SSIM=%f" % (ssim_value) # FIXME this is buggy, disable for now # ssim_value2 = ssim.ssim(ref/255, dist/255) # print "SSIM approx=%f" % (ssim_value2) psnr_value = psnr.psnr(ref, dist) print "PSNR=%f" % (psnr_value) # niqe_value = niqe.niqe(dist/255) # print "NIQE=%f" % (niqe_value) reco_value = reco.reco(ref / 255, dist / 255) print "RECO=%f" % (reco_value)
plt.figure(figsize=(8, 8)) for quality in range(0, 101, 1): subprocess.check_call('gm convert %s -quality %d %s'%(ref_file, quality, dist_file), shell=True) file_size = os.path.getsize(dist_file) dist = scipy.misc.imread(dist_file, flatten=True).astype(numpy.float32) quality_values.append( quality ) size_values.append( int(file_size/1024) ) vifp_values.append( vifp.vifp_mscale(ref, dist) ) ssim_values.append( ssim.ssim_exact(ref/255, dist/255) ) psnr_values.append( psnr.psnr(ref, dist) ) # niqe_values.append( niqe.niqe(dist/255) ) reco_values.append( reco.reco(ref/255, dist/255) ) plt.plot(quality_values, vifp_values, label='VIFP') plt.plot(quality_values, ssim_values, label='SSIM') # plt.plot(niqe_values, label='NIQE') plt.plot(quality_values, reco_values, label='RECO') plt.plot(quality_values, numpy.asarray(psnr_values)/100.0, label='PSNR/100') plt.legend(loc='lower right') plt.xlabel('JPEG Quality') plt.ylabel('Metric') plt.savefig('jpg_demo_quality.png') plt.figure(figsize=(8, 8)) plt.plot(size_values, vifp_values, label='VIFP') plt.plot(size_values, ssim_values, label='SSIM')