bayer-science-for-a-better-life / Img2Mol

Apache License 2.0
108 stars 41 forks source link

Inference error #16

Open atabeyunlu opened 10 months ago

atabeyunlu commented 10 months ago

Hi,

I was trying out the inference file (example_inference.ipynb) you provided but encountered an error at:

res = img2mol(filepath="examples/digital_example1.png", cddd_server=cddd_server) part.

I am copying the error message here. I just followed the installation through the readme and just tried this script with the images you provided.

I think there are some changes in the arguments of the transforms.RandomRotation and transforms.RandomAffine.

----> [1]res = img2mol(filepath="examples/digital_example1.png", cddd_server=cddd_server)

/Img2Mol/img2mol/inference.py:136), in Img2MolInference.__call__(self, filepath, cddd_server, return_cddd)
    131 def __call__(self,
    132              filepath: str,
    133              cddd_server: CDDDRequest = None,
    134              return_cddd: bool = False,
    135              ) -> dict:
--> 136     images = self.read_image_to_tensor(filepath, repeats=50)
    137     with torch.no_grad():
    138         cddd = self.model(images).detach().cpu().numpy()

/Img2Mol/img2mol/inference.py:126), in Img2MolInference.read_image_to_tensor(self, filepath, repeats)
    124     return "Image must be jpg or png format!"
    125 image = self.read_imagefile(filepath)
--> 126 images = torch.cat([torch.unsqueeze(self.transform_image(image), 0)
    127                     for _ in range(repeats)], dim=0)
    128 images = images.to(self.device)
    129 return images

/Img2Mol/img2mol/inference.py:126), in <listcomp>(.0)
    124     return "Image must be jpg or png format!"
...
--> 107     img_PIL = transforms.RandomRotation((-15, 15), resample=3, expand=True, center=None, fill=255)(image)
    108     img_PIL = transforms.ColorJitter(brightness=[0.75, 2.0], contrast=0, saturation=0, hue=0)(img_PIL)
    109     shear_value = np.random.uniform(0.1, 7.0)

TypeError: RandomRotation.__init__() got an unexpected keyword argument 'resample'