Skip to content
This repository has been archived by the owner on Dec 1, 2021. It is now read-only.

Move lmnet/executor/predict.py to blueoil/cmd #838

Merged
merged 5 commits into from
Feb 14, 2020
Merged

Move lmnet/executor/predict.py to blueoil/cmd #838

merged 5 commits into from
Feb 14, 2020

Conversation

tfujiwar
Copy link
Contributor

@tfujiwar tfujiwar commented Feb 13, 2020

What this patch does to fix the issue.

  • Remove blueoil/cmd/predict.py (3916fac)
  • Move lmnet/executor/predict.py to blueoil/cmd (fbe78d5)
  • Update blueoil/cmd/predict.py (d1a48fb)

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

@blueoil-butler blueoil-butler bot added the CI: auto-run Run CI automatically label Feb 13, 2020
@bo-code-review-bot
Copy link

This PR needs Approvals as follows.

  • Ownership Approval for / from iizukak, tkng, ruimashita
  • Readability Approval for Python from tkng, tsawada

Please choose reviewers and requet reviews!

Click to see how to approve each reviews

You can approve this PR by triggered comments as follows.

  • Approve all reviews requested to you (readability and ownership) and LGTM review
    Approval, LGTM

  • Approve all ownership reviews
    Ownership Approval or OA

  • Approve all readability reviews
    Readability Approval or RA

  • Approve specified review targets

    • Example of Ownership Reviewer of /: Ownership Approval for / or OA for /
    • Example of Readability Reviewer of Python: Readability Approval for Python or RA for Python
  • Approve LGTM review
    LGTM

See all trigger comments

Please replace [Target] to review target

  • Ownership Approval
    • Ownership Approval for [Target]
    • OA for [Target]
    • Ownership Approval
    • OA
    • Approval
  • Readability Approval
    • Readability Approval for [Target]
    • RA for [Target]
    • [Target] Readability Approval
    • [Target] RA
    • Readability Approval
    • RA
    • Approval
  • LGTM
    • LGTM
    • lgtm

@tfujiwar tfujiwar requested a review from iizukak February 13, 2020 08:02
Copy link
Member

@iizukak iizukak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ownership Approval

@tfujiwar tfujiwar requested a review from tsawada February 13, 2020 08:24
Copy link
Contributor

@tsawada tsawada left a 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):
""" """
Copy link
Contributor

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())
Copy link
Contributor

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
Copy link
Contributor

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:
Copy link
Contributor

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)
Copy link
Contributor

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(
Copy link
Contributor

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))
Copy link
Contributor

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

@tfujiwar
Copy link
Contributor Author

@tsawada Thank you for the comments! Let me clean up train.py and predict.py in other PRs.

@tfujiwar
Copy link
Contributor Author

/ready

@bo-mergebot
Copy link
Contributor

bo-mergebot bot commented Feb 14, 2020

⏳Merge job is queued...

@bo-mergebot
Copy link
Contributor

bo-mergebot bot commented Feb 14, 2020

😥Status check failed. Please fix problems and send /ready again.

@tfujiwar
Copy link
Contributor Author

/ready

@bo-mergebot
Copy link
Contributor

bo-mergebot bot commented Feb 14, 2020

⏳Merge job is queued...

@bo-mergebot bo-mergebot bot merged commit 962b722 into blue-oil:master Feb 14, 2020
@tfujiwar tfujiwar deleted the move-predict branch February 14, 2020 04:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CI: auto-run Run CI automatically
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants