Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase the jpg quality in rec2image #1398

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
9 changes: 3 additions & 6 deletions recognition/common/rec2image.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import time
import sklearn
import numpy as np
from tqdm import tqdm


def main(args):
Expand All @@ -32,13 +33,9 @@ def main(args):
print('header0 label', header.label)
header0 = (int(header.label[0]), int(header.label[1]))
seq_identity = range(int(header.label[0]), int(header.label[1]))
pp = 0
for identity in seq_identity:
for identity in tqdm(seq_identity):
id_dir = os.path.join(args.output, "%d_%d" % (ds_id, identity))
os.makedirs(id_dir)
pp += 1
if pp % 10 == 0:
print('processing id', pp)
s = imgrec.read_idx(identity)
header, _ = mx.recordio.unpack(s)
imgid = 0
Expand All @@ -47,7 +44,7 @@ def main(args):
_header, _img = mx.recordio.unpack(s)
_img = mx.image.imdecode(_img).asnumpy()[:, :, ::-1] # to bgr
image_path = os.path.join(id_dir, "%d.jpg" % imgid)
cv2.imwrite(image_path, _img)
cv2.imwrite(image_path, _img, [cv2.IMWRITE_JPEG_QUALITY, 100])
imgid += 1


Expand Down