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

Unclear inference results. #97

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

Unclear inference results. #97

LoaferCH opened this issue Jan 20, 2023 · 0 comments

Comments

@LoaferCH
Copy link
Collaborator

After running inference.py, output is saved as .png images into logs folder. However it is unclear what is the original data.
It could be better if forward() method returned a tuple of both outs and batch

def forward(self, batch: torch.Tensor) -> torch.Tensor:
"""Make a prediction"""
logits = self.model(batch)
outs = (logits > self.threshold).to(torch.uint8)
return outs

So both original image and predict for it could be saved with cv2.imwrite at:

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}")

Originals could be saved with original_ prefix in the same folder as preds.

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