toshiaki1729 / dataset-tag-editor-standalone

WebUI to edit dataset captions for txt2img models
MIT License
134 stars 15 forks source link

"No module named 'modules'" on Mac m2 #10

Closed novitae closed 1 year ago

novitae commented 1 year ago

When trying to run python scripts/launch.py, here's the error I am getting:

python ./scripts/launch.py
Traceback (most recent call last):
  File "/Users/n/dataset-tag-editor-standalone/./scripts/launch.py", line 90, in <module>
    prepare_environment()
  File "/Users/n/dataset-tag-editor-standalone/./scripts/launch.py", line 84, in prepare_environment
    import devices
  File "/Users/n/dataset-tag-editor-standalone/scripts/devices.py", line 53, in <module>
    device = get_optimal_device()
             ^^^^^^^^^^^^^^^^^^^^
  File "/Users/n/dataset-tag-editor-standalone/scripts/devices.py", line 33, in get_optimal_device
    if has_mps():
       ^^^^^^^^^
  File "/Users/n/dataset-tag-editor-standalone/scripts/devices.py", line 10, in has_mps
    from modules import mac_specific
ModuleNotFoundError: No module named 'modules'

It comes from this function: https://github.com/toshiaki1729/dataset-tag-editor-standalone/blob/97ee181f42d4d03fb555df1d2586e3fbcf5934d2/scripts/devices.py#L6-L13 I am on Mac m2, so apple silicon, and it seems that nobody with this chip already reported this issue. I did my researches, and to check if MPS is available on silicon chips, we have to use torch.has_mps, as easy as it follows:

>>> import torch
>>> torch.has_mps
True
toshiaki1729 commented 1 year ago

Thank you for your report! I didn't have implemented the code for MacOS. Added the code same as the webUI.