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

Images after inferece are overwritten #99

Open
LoaferCH opened this issue Jan 20, 2023 · 0 comments
Open

Images after inferece are overwritten #99

LoaferCH opened this issue Jan 20, 2023 · 0 comments

Comments

@LoaferCH
Copy link
Collaborator

In save_preds method:

def save_preds(self, preds, stage: Stages, dst_path: pathlib.Path):
out_file_path = dst_path / "results"
os.mkdir(out_file_path)
for preds_batch in preds:
for i , pred in enumerate(preds_batch):
pred = pred.numpy()
pred[pred < 0.3] = 0
pred[pred > 0] = 255
filename = out_file_path / f"out_{i}.png"
cv2.imwrite(filename, pred[0])
logging.info(f"Saved result to: {out_file_path}")

The value of iterator i gets reset for each batch

So images get same names and overwrite each batch. This i iterator should be outside the loop and get incremented after cv2.imwrite()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant