-
Notifications
You must be signed in to change notification settings - Fork 86
Move lmnet/executor/predict.py to blueoil/cmd #838
Conversation
This PR needs Approvals as follows.
Please choose reviewers and requet reviews! Click to see how to approve each reviewsYou can approve this PR by triggered comments as follows.
See all trigger commentsPlease replace [Target] to review target
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ownership Approval
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Readability Approval
After adding a few comments to predict.py, I realized you just copied it... I'll leave the comment for the record / reference but feel free to merge this as is.
restore_path = os.path.join( | ||
output_dir, experiment_id, "checkpoints", checkpoint | ||
def _get_images(filenames, pre_processor, data_format): | ||
""" """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please write something or remove this line
|
||
def _run(input_dir, output_dir, config, restore_path, save_images): | ||
ModelClass = config.NETWORK_CLASS | ||
network_kwargs = dict((key.lower(), val) for key, val in config.NETWORK.items()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{a: b for a, b in c.items()}
|
||
results = [] | ||
for step in range(step_size): | ||
start_index = (step) * config.BATCH_SIZE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove parenthesis
|
||
image_files = all_image_files[start_index:end_index] | ||
|
||
while len(image_files) != config.BATCH_SIZE: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is inefficient, and will loop forever if len(image_files) > config.BATCH_SIZE.
if len > size:
files += [DUMMY] * (len - size)
image_files, config.DATASET.PRE_PROCESSOR, config.DATA_FORMAT) | ||
|
||
feed_dict = {images_placeholder: images} | ||
outputs = sess.run(output_op, feed_dict=feed_dict) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put feed_dict in a single line
|
||
results.append(outputs) | ||
|
||
writer.write( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you concatenate into fewer lines?
config = config_util.merge(config, config_util.load(config_file)) | ||
|
||
if not os.path.isdir(input_dir): | ||
raise Exception("Input directory {} does not exist.".format(input_dir)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid raising Exception
and use more specific ones. In this case, FileNotFoundError
might be a good choice
@tsawada Thank you for the comments! Let me clean up |
/ready |
⏳Merge job is queued... |
😥Status check failed. Please fix problems and send |
/ready |
⏳Merge job is queued... |
What this patch does to fix the issue.
This PR looks big but most of the changes are just copied. Maybe it's easier to check each commit one by one than checking the whole changes.
Link to any relevant issues or pull requests.
#746