-
Notifications
You must be signed in to change notification settings - Fork 96
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
Mismatch Issue Between Input Image and Model Prediction #37
Comments
Hi @loseen01 I'm sorry, but I don't fully understand the specific problem you're encountering without additional context. It sounds like a typical issue with a mismatch in input dimensions. Have you ensured that your image is resized to the required dimensions for the model? you need to confirm that your input tensor matches the model's expected size. Feel free to post some snapshots or codes if you want us to take a quick look. Also, if you are a beginner of pytorch for CV applications, you may want to go over tutorials like this first. https://pytorch.org/tutorials/beginner/transfer_learning_tutorial.html |
Hi, I also encountered the same issue and would appreciate any input on it. import torch, torchvision mean = (0.485, 0.456, 0.406) model = ctranspath() image = Image.open("./exsample/exsample.tif") The exsample.tif image is provided in your code. Based on my understanding, the images should be in tif format, they should be preprocessed (background removal- mentioned in one of your other comments) and then the CTransPath would be applied to it. The transformation "transforms.Resize(224)" provides us with tiles with a 224x224 dimension. This would be the input to CTransPath. When I run this code the below error is presented to me (please note I inserted a couple of print lines to understand what torch input is being passed on to the model): Patch shape after preprocessing/before model input: torch.Size([1, 3, 224, 224]) Can you please advise on this matter? Thank you |
@sara-hashemi |
@Dadatata-JZ |
I redid all the installation and prerequisite's process this morning, including installation of timm-0.5.4 and requirements.txt. I am running your code on an AWS GPU server and it keeps getting stuck in the initial phase. I have downloaded all the pre-trained files/weights available on your Google Drive onto a folder (model_weights) and am running the below sample code from your GitHub page: ========================================= import torch, torchvision mean = (0.485, 0.456, 0.406) model = ctranspath() image = Image.open("./exsample/exsample.tif") ========================================= This should be able to extract features from the one provided image (exsample.tif) in the form of a tensor with a shape of 1x768. However, The same error is being shown: RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same
|
RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) @sara-hashemi it is a pytorch question. you model is on GPU and your data is on CPU. |
Hi @Dadatata-JZ import torch from models.ctran import ctranspath Increase PIL's MAX_IMAGE_PIXELS limit to handle large images
|
Hello everyone,
I'm facing an issue with matrix handling when inputting an image, such as from the files (exsample.tif). The final prediction result shows a mismatch between the input image and what the model expects. This is surprising since the input image is supposed to be one of the images used during model training. Has anyone encountered this issue or have any suggestions on how to resolve it?
I'm a beginner so any help is appreciated.
The text was updated successfully, but these errors were encountered: