Open Mozoloa opened 3 days ago
Hi @Mozoloa . I just tried to reproduce the error but failed, it worked fine on my environment.
I'm just planning to load model using huggingface API.
I tried to fix it in #13, Can you see if it still happens in the latest version?
Ran update.bat, no change in requirements so launched the UI right after and got this (don't think it has changed)
G:\AI\Video\sam2-playground-portable-windows>set ARGS=
device "cuda" is detected
Running on local URL: http://127.0.0.1:7860
To create a public link, set `share=True` in `launch()`.
Applying configs to sam2.1_hiera_large model..
Error while loading SAM2 model for video predictor
Traceback (most recent call last):
File "G:\AI\Video\sam2-playground-portable-windows\sam2-playground\venv\Lib\site-packages\hydra\_internal\instantiate\_instantiate2.py", line 92, in _call_target
return _target_(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "G:\AI\Video\sam2-playground-portable-windows\sam2-playground\venv\Lib\site-packages\sam2\sam2_video_predictor.py", line 33, in __init__
super().__init__(**kwargs)
TypeError: SAM2Base.__init__() got an unexpected keyword argument 'no_obj_embed_spatial'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "G:\AI\Video\sam2-playground-portable-windows\sam2-playground\modules\sam_inference.py", line 78, in load_model
self.video_predictor = build_sam2_video_predictor(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "G:\AI\Video\sam2-playground-portable-windows\sam2-playground\venv\Lib\site-packages\sam2\build_sam.py", line 73, in build_sam2_video_predictor
model = instantiate(cfg.model, _recursive_=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "G:\AI\Video\sam2-playground-portable-windows\sam2-playground\venv\Lib\site-packages\hydra\_internal\instantiate\_instantiate2.py", line 226, in instantiate
return instantiate_node(
^^^^^^^^^^^^^^^^^
File "G:\AI\Video\sam2-playground-portable-windows\sam2-playground\venv\Lib\site-packages\hydra\_internal\instantiate\_instantiate2.py", line 347, in instantiate_node
return _call_target(_target_, partial, args, kwargs, full_key)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "G:\AI\Video\sam2-playground-portable-windows\sam2-playground\venv\Lib\site-packages\hydra\_internal\instantiate\_instantiate2.py", line 97, in _call_target
raise InstantiationException(msg) from e
hydra.errors.InstantiationException: Error in call to target 'sam2.sam2_video_predictor.SAM2VideoPredictor':
TypeError("SAM2Base.__init__() got an unexpected keyword argument 'no_obj_embed_spatial'")
full_key: model
Error while loading SAM2 model
Traceback (most recent call last):
File "G:\AI\Video\sam2-playground-portable-windows\sam2-playground\venv\Lib\site-packages\hydra\_internal\instantiate\_instantiate2.py", line 92, in _call_target
return _target_(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: SAM2Base.__init__() got an unexpected keyword argument 'no_obj_embed_spatial'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "G:\AI\Video\sam2-playground-portable-windows\sam2-playground\modules\sam_inference.py", line 89, in load_model
self.model = build_sam2(
^^^^^^^^^^^
File "G:\AI\Video\sam2-playground-portable-windows\sam2-playground\venv\Lib\site-packages\sam2\build_sam.py", line 36, in build_sam2
model = instantiate(cfg.model, _recursive_=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "G:\AI\Video\sam2-playground-portable-windows\sam2-playground\venv\Lib\site-packages\hydra\_internal\instantiate\_instantiate2.py", line 226, in instantiate
return instantiate_node(
^^^^^^^^^^^^^^^^^
File "G:\AI\Video\sam2-playground-portable-windows\sam2-playground\venv\Lib\site-packages\hydra\_internal\instantiate\_instantiate2.py", line 347, in instantiate_node
return _call_target(_target_, partial, args, kwargs, full_key)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "G:\AI\Video\sam2-playground-portable-windows\sam2-playground\venv\Lib\site-packages\hydra\_internal\instantiate\_instantiate2.py", line 97, in _call_target
raise InstantiationException(msg) from e
hydra.errors.InstantiationException: Error in call to target 'sam2.modeling.sam2_base.SAM2Base':
TypeError("SAM2Base.__init__() got an unexpected keyword argument 'no_obj_embed_spatial'")
full_key: model
Traceback (most recent call last):
File "G:\AI\Video\sam2-playground-portable-windows\sam2-playground\venv\Lib\site-packages\hydra\_internal\instantiate\_instantiate2.py", line 92, in _call_target
return _target_(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: SAM2Base.__init__() got an unexpected keyword argument 'no_obj_embed_spatial'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "G:\AI\Video\sam2-playground-portable-windows\sam2-playground\modules\sam_inference.py", line 89, in load_model
self.model = build_sam2(
^^^^^^^^^^^
File "G:\AI\Video\sam2-playground-portable-windows\sam2-playground\venv\Lib\site-packages\sam2\build_sam.py", line 36, in build_sam2
model = instantiate(cfg.model, _recursive_=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "G:\AI\Video\sam2-playground-portable-windows\sam2-playground\venv\Lib\site-packages\hydra\_internal\instantiate\_instantiate2.py", line 226, in instantiate
return instantiate_node(
^^^^^^^^^^^^^^^^^
File "G:\AI\Video\sam2-playground-portable-windows\sam2-playground\venv\Lib\site-packages\hydra\_internal\instantiate\_instantiate2.py", line 347, in instantiate_node
return _call_target(_target_, partial, args, kwargs, full_key)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "G:\AI\Video\sam2-playground-portable-windows\sam2-playground\venv\Lib\site-packages\hydra\_internal\instantiate\_instantiate2.py", line 97, in _call_target
raise InstantiationException(msg) from e
hydra.errors.InstantiationException: Error in call to target 'sam2.modeling.sam2_base.SAM2Base':
TypeError("SAM2Base.__init__() got an unexpected keyword argument 'no_obj_embed_spatial'")
full_key: model
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "G:\AI\Video\sam2-playground-portable-windows\sam2-playground\venv\Lib\site-packages\gradio\queueing.py", line 536, in process_events
response = await route_utils.call_process_api(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "G:\AI\Video\sam2-playground-portable-windows\sam2-playground\venv\Lib\site-packages\gradio\route_utils.py", line 322, in call_process_api
output = await app.get_blocks().process_api(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "G:\AI\Video\sam2-playground-portable-windows\sam2-playground\venv\Lib\site-packages\gradio\blocks.py", line 1935, in process_api
result = await self.call_function(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "G:\AI\Video\sam2-playground-portable-windows\sam2-playground\venv\Lib\site-packages\gradio\blocks.py", line 1520, in call_function
prediction = await anyio.to_thread.run_sync( # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "G:\AI\Video\sam2-playground-portable-windows\sam2-playground\venv\Lib\site-packages\anyio\to_thread.py", line 56, in run_sync
return await get_async_backend().run_sync_in_worker_thread(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "G:\AI\Video\sam2-playground-portable-windows\sam2-playground\venv\Lib\site-packages\anyio\_backends\_asyncio.py", line 2405, in run_sync_in_worker_thread
return await future
^^^^^^^^^^^^
File "G:\AI\Video\sam2-playground-portable-windows\sam2-playground\venv\Lib\site-packages\anyio\_backends\_asyncio.py", line 914, in run
result = context.run(func, *args)
^^^^^^^^^^^^^^^^^^^^^^^^
File "G:\AI\Video\sam2-playground-portable-windows\sam2-playground\venv\Lib\site-packages\gradio\utils.py", line 826, in wrapper
response = f(*args, **kwargs)
^^^^^^^^^^^^^^^^^^
File "G:\AI\Video\sam2-playground-portable-windows\sam2-playground\app.py ", line 84, in on_video_model_change
self.sam_inf.init_video_inference_state(vid_input=vid_input, model_type=model_type)
File "G:\AI\Video\sam2-playground-portable-windows\sam2-playground\modules\sam_inference.py", line 113, in init_video_inference_state
self.load_model(model_type=model_type, load_video_predictor=True)
File "G:\AI\Video\sam2-playground-portable-windows\sam2-playground\modules\sam_inference.py", line 96, in load_model
raise RuntimeError(f"Failed to load model") from e
RuntimeError: Failed to load model
@Mozoloa There was an update in the requirements.txt recently, I fetched upstream in the forked version of the sam2 to follow the recent sam2.1 patch. The patch was done in a forked version of sam-2, so there is no update in the requirements.txt here, but you actually need to update the dependency.
If you re-install the sam-2, then it should work fine without any problem.
Installed on w11 following the instructions, everything is updated yet, just launching then selecting any model downloads the model but gives this in the console instantly:
I've seen some issues about hydra but I don't understand anything nor know what to do, it's very confusing. It looks like this repo is non functional on windows