ml-cvnets icon indicating copy to clipboard operation
ml-cvnets copied to clipboard

How to solve this problem:ModuleNotFoundError: No module named 'cvnets.models.classification.'

Open acrlife opened this issue 1 year ago • 5 comments

Hi@sacmehta @mchorton When I comment out "self.check_model()" in "./ml-cvnets/cvnets/models/classification/mobilevit.py",and run command as figure1,I got a error as figure2. I uncomment "self.check_model()",run command again,but also got this error. How to solve this problem? Thank you very much! 1 2

acrlife avatar Oct 27 '23 10:10 acrlife

@acrlife it looks like python cannot find the module - is CVNets missing from your pythonpath? Assuming you're running from the root directory in the CVNets repository, try adding PYTHONPATH=. before your command.

mchorton avatar Oct 29 '23 22:10 mchorton

@mchorton I have found reason of this problem: When I installed cvnets ,command cvnets-train can works, but it does't work after I add my own model file named "denseformer.py" to "ml-cvnets/cvnets/models/classification". I have try to reinstall cvnets by pip install --editable ., but it also does't work. Figure 1 shows the situation after just installing CVnets, and Figure 2 shows the situation after adding my own model file. I really want to know how to train my own model using CVNets,thank you! 5 6

acrlife avatar Oct 30 '23 10:10 acrlife

The error implies you're trying to import cvnets.models.classification.config somewhere. Since the config folder isn't a module, you're getting an import error. I think you meant to remove the config from your import statement.

mchorton avatar Oct 30 '23 16:10 mchorton

@mchorton I think CVNets has built a fully functional framework for the main tasks in the field of computer vision. I would like to know how to use CVNets to train my own model. Can you provide a tutorial? Thank you very much!

acrlife avatar Oct 31 '23 01:10 acrlife

@acrlife we have documentation here: https://apple.github.io/ml-cvnets/getting_started.html

I believe your issue involved importing the wrong directory, as mentioned above. If you are still having trouble, try this:

  • Revert all your code changes, so that your branch matches the main branch.
  • Add your model definition to an existing .py file in which some other model is defined. That way, you can rule out an import error.

mchorton avatar Oct 31 '23 16:10 mchorton