Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion funque/core/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ class Asset(WorkdirEnabled):
def __init__(self, dataset, content_id, asset_id,
ref_path, dis_path,
asset_dict,
workdir_root=FunqueConfig.workdir_path()):
workdir_root=FunqueConfig.workdir_path(),
enable_resizer=True):
"""
:param dataset
:param content_id: ID of content the asset correspond to within dataset
Expand All @@ -68,6 +69,7 @@ def __init__(self, dataset, content_id, asset_id,
self.ref_path = ref_path
self.dis_path = dis_path
self.asset_dict = asset_dict
self.enable_resizer = enable_resizer

self._assert()

Expand Down
5 changes: 3 additions & 2 deletions funque/core/custom_feature_extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,9 @@ def _generate_result(self, asset):
y_dis, _, _ = yuv_dis

# Apply SAST.
y_ref = cv2.resize(y_ref, (w//2, h//2), interpolation=cv2.INTER_CUBIC)
y_dis = cv2.resize(y_dis, (w//2, h//2), interpolation=cv2.INTER_CUBIC)
if asset.enable_resizer:
y_ref = cv2.resize(y_ref, (w//2, h//2), interpolation=cv2.INTER_CUBIC)
y_dis = cv2.resize(y_dis, (w//2, h//2), interpolation=cv2.INTER_CUBIC)

if ref_yuv_reader._is_8bit():
y_ref = y_ref.astype(np.double) / (2.0**8 - 1.0)
Expand Down
4 changes: 2 additions & 2 deletions funque/third_party/funque_atoms/vif_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ def vif_channel_est(pyr_ref, pyr_dist, subband_keys, M):


def vif_spatial(img_ref, img_dist, k=11, sigma_nsq=0.1, stride=1, full=False):
x = img_ref.astype('float32')
y = img_dist.astype('float32')
x = img_ref
y = img_dist

_, _, var_x, var_y, cov_xy = moments(x, y, k, stride)

Expand Down
18 changes: 16 additions & 2 deletions run_funque.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,20 @@
OUT_FMTS = ['text (default)', 'xml', 'json']
POOL_METHODS = ['mean', 'harmonic_mean', 'min', 'median', 'perc5', 'perc10', 'perc20']

def str2bool(v):
if isinstance(v, bool):
return v
if v.lower() in ('yes', 'y', 'true', 't', '1'):
return True
elif v.lower() in ('no', 'n', 'false', 'f', '0'):
return False
else:
raise Exception("The string is invalid")

def print_usage():
print("usage: " + os.path.basename(sys.argv[0]) \
+ " fmt width height ref_path dis_path [--model model_path] [--out-fmt out_fmt] " \
"[--phone-model] [--ci] [--save-plot plot_dir]\n")
"[--phone-model] [--ci] [--save-plot plot_dir] [--enable_resizer true/false]\n")
print("fmt:\n\t" + "\n\t".join(FMTS) + "\n")
print("out_fmt:\n\t" + "\n\t".join(OUT_FMTS) + "\n")

Expand All @@ -46,6 +55,10 @@ def main():
height = int(sys.argv[3])
ref_file = sys.argv[4]
dis_file = sys.argv[5]

enable_resizer_str = get_cmd_option(sys.argv, 6, len(sys.argv), '--enable_resizer')
enable_resizer = str2bool(enable_resizer_str) if enable_resizer_str else True

except ValueError:
print_usage()
return 2
Expand Down Expand Up @@ -93,7 +106,8 @@ def main():
workdir_root=FunqueConfig.workdir_path(),
ref_path=ref_file,
dis_path=dis_file,
asset_dict={'width':width, 'height':height, 'yuv_type':fmt}
asset_dict={'width':width, 'height':height, 'yuv_type':fmt},
enable_resizer=enable_resizer
)
assets = [asset]

Expand Down