WASasquatch / was-node-suite-comfyui

An extensive node suite for ComfyUI with over 210 new nodes
MIT License
1.15k stars 170 forks source link

No module named 'midas.dpt_depth' - shadowed? #268

Closed picobyte closed 10 months ago

picobyte commented 10 months ago

Since my update comyUI all update, yesterday, I'm getting errors on a previously working worksheet.

It started in comfyui_controlnet_aux, that also had recent midas updates, and now was follows suit:

Error occurred when executing MiDaS Model Loader:

No module named 'midas.dpt_depth'

File "ComfyUI/execution.py", line 153, in recursive_execute
output_data, output_ui = get_output_data(obj, input_data_all)
File "ComfyUI/execution.py", line 83, in get_output_data
return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True)
File "ComfyUI/execution.py", line 76, in map_node_over_list
results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
File "ComfyUI/custom_nodes/was-node-suite-comfyui/WAS_Node_Suite.py", line 8462, in load_midas_model
midas = torch.hub.load("intel-isl/MiDaS", midas_model, trust_repo=True)
File "stable-diffusion-webui/venv310cu118/lib/python3.10/site-packages/torch/hub.py", line 566, in load
model = _load_local(repo_or_dir, model, *args, **kwargs)
File "stable-diffusion-webui/venv310cu118/lib/python3.10/site-packages/torch/hub.py", line 592, in _load_local
hub_module = _import_module(MODULE_HUBCONF, hubconf_path)
File "stable-diffusion-webui/venv310cu118/lib/python3.10/site-packages/torch/hub.py", line 106, in _import_module
spec.loader.exec_module(module)
File "", line 883, in exec_module
File "", line 241, in _call_with_frames_removed
File "ComfyUI/models/midas/intel-isl_MiDaS_master/hubconf.py", line 5, in
from midas.dpt_depth import DPTDepthModel

ComfyUI and stable-diffusion-webui are listed, but this is because the ComfyUI venv is a symlink to the table-diffusion-webui, which worked just fine for me.

WASasquatch commented 10 months ago

When updating ComfyUI, you often have to re-run requirements for custom nodes, to downgrade/upgrade modules.

picobyte commented 10 months ago

I tried this, but trying to find the middle way between the many outdated requirements file versions just broke more custom nodes, and the issue remains.

WASasquatch commented 10 months ago

Not outdated. Required. Comfy is the one ruining the ecosphere by running on bleeding edge python and dependencies that 90% of this stuff was not developed on. For example, Midas you are having issues with requires older transformers.

picobyte commented 10 months ago

Thanks, I think I'm getting near the solution. for this particular issue I added an __init__.py in the ComfyUI/models/midas/intel-isl_MiDaS_master/midas/ directory. Then there were more issues, I had to disable many custom nodes, mentioned here, Turned out to be related to tensorflow, and now this seems to help (MTD custom node works again). By coincidence I had some of the package versions mentioned there, but not all. The error seemed related to this. Your extension seems to have been unrelated after all. Sorry for the trouble.

WASasquatch commented 10 months ago

Clever fix on the midas model dir. Maybe this is a change with how hub works now (no longer providing py files set up)? Though that would be odd.

And ohh, well that explains my MTB issues. Lol Thanks for the ping on that. I was just about to dig into it.

Tensorflow hasn't had a good end of the year. I had a few issues with it too.

DarkAlchy commented 10 months ago

Did this ever get fixed as I just ran into this as missing and, frankly, I am unwilling to mess with python scripts that I then need to stash come update time.

WASasquatch commented 10 months ago

Did this ever get fixed as I just ran into this as missing and, frankly, I am unwilling to mess with python scripts that I then need to stash come update time.

This fix is part of the Midas model downloaded from HF this unlikely to get any updates. And all it is is creating a blank __init__.py file, nothing in it, in that folder.

DarkAlchy commented 10 months ago

I was told Midas has been abandoned on Discord yesterday. I did prefer Zoe but midas ran faster.

WASasquatch commented 10 months ago

Zoe is slow cause it's loading model each time, and it itself is not as fast. MiDaS is not abandoned. It has even newer versions, they just haven't been submitted to HF hub

jsgreenawalt commented 10 months ago

For me, the issue was that something (or someone...) had installed a package named midas:

import midas dir(midas) ['Any', 'GasDetector', 'builtins', 'cached', 'doc', 'file', 'loader', 'name', 'package', 'path', 'spec', 'command_line', 'driver', 'util'] quit()

This is numat / midas -- a python driver for a home automation device. I uninstalled this 'midas' package and that solved it for me

fernicar commented 9 months ago

ComfyUI (StabilityMatrix version) comfyui_controlnet_aux is using a different path to import this module like the other depth preprocessors, I just modified it. In your version of ComfyUI: YourPath\ComfyUI\models\midas\intel-isl_MiDaS_master\hubconf.py

at lines: 5, 6 ,7 , 306 and 307 replace from: "from midas." replace to: "from custom_midas_repo.midas."

now it should be able to find it, no need to restart ComfyUI to generate.

WASasquatch commented 9 months ago

This doesn't seem related to WAS-NS

On Tue, Jan 2, 2024, 7:20 AM fernicar @.***> wrote:

comfyui_controlnet_aux is using a different path to import this module in the other depth preprocessors, I just use modified it in my ComfyUI (StabilityMatrix version) In your version of ComfyUI: YourPath\ComfyUI\models\midas\intel-isl_MiDaS_master\hubconf.py

at lines: 5, 6 ,7 , 306 and 307 replace from: "from midas." replace to: "from custom_midas_repo.midas."

now it should be able to find it, no need to restart ComfyUI to generate.

— Reply to this email directly, view it on GitHub https://github.com/WASasquatch/was-node-suite-comfyui/issues/268#issuecomment-1874161885, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIZEZOJIUWDLIUQRO43BBLYMQQSVAVCNFSM6AAAAAA7HHSBOSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZUGE3DCOBYGU . You are receiving this because you commented.Message ID: @.***>

creeduk commented 8 months ago

I added the (init.py) fix, this allowed it to go further it download the depth model dpt_large_384.pt - to folder ComfyUI\models\midas\checkpoints.

initially I got this error: `Error occurred when executing MiDaS Depth Approximation:

Cannot find callable C:\ComfyUI\models\midas\checkpoints\dpt_large_384.pt in hubconf

This was a DOH! moment, readying some other issues I noted model loader....ah it does not error on no loader but that is what caused this problem. I added this in case anybody else runs into this

WASasquatch commented 8 months ago

Yes, Midas hasn't uploaded their new models to hugging face for transformers support. You have to download the ones compatible, listed in the node from HF.

On Fri, Jan 12, 2024, 7:40 AM creeduk @.***> wrote:

I added the fix this allowed it to go further it wanted to download the depth model dpt_large_384.pt - to folder ComfyUI\models\midas\checkpoints.

But now I get this error: `Error occurred when executing MiDaS Depth Approximation:

Cannot find callable C:\ComfyUI\models\midas\checkpoints\dpt_large_384.pt in hubconf

File "C:\ComfyUI\execution.py", line 154, in recursive_execute output_data, output_ui = get_output_data(obj, input_data_all) File "C:\ComfyUI\execution.py", line 84, in get_output_data return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True) File "C:\ComfyUI\execution.py", line 77, in map_node_over_list results.append(getattr(obj, func)(*slice_dict(input_data_all, i))) File "C:\ComfyUI\custom_nodes\was-node-suite-comfyui\WAS_Node_Suite.py", line 8561, in midas_approx midas = torch.hub.load("intel-isl/MiDaS", midas_type, trust_repo=True) File "C:\ComfyUI\comfyenv\lib\site-packages\torch\hub.py", line 566, in load model = _load_local(repo_or_dir, model, args, **kwargs) File "C:\ComfyUI\comfyenv\lib\site-packages\torch\hub.py", line 594, in _load_local entry = _load_entry_from_hubconf(hub_module, model) File "C:\ComfyUI\comfyenv\lib\site-packages\torch\hub.py", line 348, in _load_entry_from_hubconf raise RuntimeError(f'Cannot find callable {model} in hubconf')`

hubconf must be the intel_isl one which has not changed for a couple of years,

I tried with different models, tried a few py edits but could not figure out the issue, some disconnect between name and what is called maybe?

— Reply to this email directly, view it on GitHub https://github.com/WASasquatch/was-node-suite-comfyui/issues/268#issuecomment-1889528313, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIZEZIOBXPYQE5ULWRBUDDYOFKNZAVCNFSM6AAAAAA7HHSBOSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBZGUZDQMZRGM . You are receiving this because you commented.Message ID: @.***>