LightningCLI() call error while trying the imagenet.py example from Git

hi,
I’m trying the imagenet.py model example from Lightening GitHub with my storm images dataset. It gives me this error":
“ModuleNotFoundError: Requirement ‘jsonargparse[signatures]>=4.15.2’ not met, DistributionNotFound: The ‘typeshed-client>=2.1.0; extra == “signatures”’ distribution was not found and is required byjsonargparse.”
while I already have the package installed. Is there a different way to call ImageNetLightningModel in jupyter notebook (not the lightningCLI)?
The example file I’m referencing: https://github.com/Lightning-AI/lightning/blob/master/examples/pl_domain_templates/imagenet.py

PS: I asked on slack channel and was told to try here.

Have you tried upgrading the package?

pip install -U jsonargparse[signatures]

Or installing the package as referenced in the error message:

pip install typeshed-client

I’m not sure why this is happening in the first place. A good sanity check is always to start from a fresh environment.

Yes, have tried both of those, but it still gives the same error. That’s what threw me off.
Is it the recommended way to make the call to the CLI function (LightningCLI) from the notebook?

You can do that but IMO I think there is only very little value in using LightningCLI in notebooks. The only benefit I can see is that it allows you to configure the parameters in one central place or through the config file. But it was designed to work well with scripts to be executed from, well, the CLI.

If you have a notebook, could you maybe upload it to Google Colab and share here or on Lightning’s GitHub issues so we can reproduce the error you are seeing?

Since this issue looks specific to jsonargparse, I suggest that you open an issue report with a link to this colab notebook in Issues · omni-us/jsonargparse · GitHub

yes, exactly my thought. But the example uses the CLI call, so i was just trying to replicate before modifying for my use. Where can I find the documentation for regular call to ImageNetLightningModel, for that imagenet example?
Ya, I can upload the notebook. but here’s the code snippet. I’m working with the lightening example only passing my own train and val data. LINK: lightning/imagenet.py at 8dc68996f0967d10fdae66f2f99284ed222ee27c · Lightning-AI/lightning · GitHub
CODE SNIPPET:
Data variable update inside init:
self.train_dataset = DatasetWIND(self.x_train, self.y_train)
self.val_dataset = DatasetWIND(self.x_val, self.y_val)
MAIN CALL:
if name == “main”:
LightningCLI(
ImageNetLightningModel,
trainer_defaults={
“max_epochs”: 9,
“accelerator”: “auto”,
“devices”: 1,
“logger”: False,
“benchmark”: True,
“callbacks”: [
# the PyTorch example refreshes every 10 batches
TQDMProgressBar(refresh_rate=10),
# save when the validation top1 accuracy improves
ModelCheckpoint(monitor=“val_acc1”, mode=“max”),
],
},
seed_everything_default=42,
save_config_kwargs={“overwrite”: True},
)

Hi, @carmocca your recommended imagenet example on GitHub only shows the CLI call, which Adrian above indicated that is not needed for trying out in notebook. I have been trying to look for the regular call to the ImageNetLightningModel, but haven’t been able to find an example yet.
Thank you for your help.

You can run it without the CLI by doing:

trainer = Trainer()
model = ImageNetLightningModel()
trainer.fit(model)

You can also find more docs about how to use the Trainer in Welcome to ⚡ PyTorch Lightning — PyTorch Lightning 1.9.2 documentation