You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank you for your great work. Translating the model to Torch has made my life much easier. However, when I tried to use it, I got some strange output.
Here is my code:
import cosem_models
import numpy as np
import tifffile as tif
import torch
from einops import rearrange
model = cosem_models.load_model(
"./v0003.2-pytorch/cosem_models/cosem_models/setup04/1820500"
)
print("min input shape: ", model.min_input_shape)
print("input size step: ", model.input_size_step)
img = tif.imread(
"/home/linhan/data/dummy.tif"
)
input = img[:216, :216, :216] / np.float32(255.0)
input = 2.0 * input - 1.0
print(input.shape, input.dtype, input.min(), input.max())
# print(model)
model = model.to("cuda")
model.eval()
with torch.no_grad():
input = torch.tensor(input, device="cuda")
input = rearrange(input, "h w d -> 1 1 h w d")
output = model.prediction_head(model.unet(input))
print(output.size(), output.max(), output.min())
output = output.cpu().numpy()
pred = np.argmax(output, axis=1)
print(pred.shape, pred.dtype, pred.max(), pred.min())
The output values are extremely large, and the predicted classes are all zero. I read single_block_inference.py and ensured the input normalization to [-1, 1]. I also checked the data type of my input, which is correct.
Do you have any idea why I am getting these strange results? Thank you so much!
The text was updated successfully, but these errors were encountered:
Thank you for your great work. Translating the model to Torch has made my life much easier. However, when I tried to use it, I got some strange output.
Here is my code:
The output is:
The output values are extremely large, and the predicted classes are all zero. I read single_block_inference.py and ensured the input normalization to [-1, 1]. I also checked the data type of my input, which is correct.
Do you have any idea why I am getting these strange results? Thank you so much!
The text was updated successfully, but these errors were encountered: