quic / ai-hub-models

The Qualcomm® AI Hub Models are a collection of state-of-the-art machine learning models optimized for performance (latency, memory etc.) and ready to deploy on Qualcomm® devices.
https://aihub.qualcomm.com
BSD 3-Clause "New" or "Revised" License
482 stars 77 forks source link

[BUG] Windows install Whisper not working #123

Open BrickDesignerNL opened 1 day ago

BrickDesignerNL commented 1 day ago

Describe the bug Dependencies not there

To Reproduce

conda create -n whisper python=3.12.7
conda activate whisper
conda install conda-forge::ffmpeg

cd C:\Users\<user_name>\miniconda3\envs\whisper

copy the 4 file of 
[code of](https://github.com/quic/ai-hub-apps/tree/main/apps/windows/python/Whisper) 
to  
C:\Users\<user_name>\miniconda3\envs\whisper

py -m pip install -r requirements.txt

Expected behavior I expected that the above would run and that I then finally could run

py -m qai-hub-models.models.whisper_base_en.export --target-runtime onnx py demo.py --audio_path /path/to/test/data.mp3

To get the first thing running.

Stack trace (whisper) C:\Users\\miniconda3\envs\whisper>py -m pip install -r requirements.txt Collecting opencv-python (from -r requirements.txt (line 1)) Using cached opencv-python-4.10.0.84.tar.gz (95.1 MB) Installing build dependencies ... done Getting requirements to build wheel ... done ERROR: Exception: Traceback (most recent call last): File "C:\Users\\AppData\Local\Programs\Python\Python313-arm64\Lib\site-packages\pip_internal\cli\base_command.py", line 105, in _run_wrapper status = _inner_run() File "C:\Users\\AppData\Local\Programs\Python\Python313-arm64\Lib\site-packages\pip_internal\cli\base_command.py", line 96, in _inner_run return self.run(options, args)


  File "C:\Users\<user_name>\AppData\Local\Programs\Python\Python313-arm64\Lib\site-packages\pip\_internal\cli\req_command.py", line 67, in wrapper
    return func(self, options, args)
  File "C:\Users\<user_name>\AppData\Local\Programs\Python\Python313-arm64\Lib\site-packages\pip\_internal\commands\install.py", line 379, in run
    requirement_set = resolver.resolve(
        reqs, check_supported_wheels=not options.target_dir
    )
  File "C:\Users\<user_name>\AppData\Local\Programs\Python\Python313-arm64\Lib\site-packages\pip\_internal\resolution\resolvelib\resolver.py", line 95, in resolve
    result = self._result = resolver.resolve(
                            ~~~~~~~~~~~~~~~~^
        collected.requirements, max_rounds=limit_how_complex_resolution_can_be
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "C:\Users\<user_name>\AppData\Local\Programs\Python\Python313-arm64\Lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 546, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
  File "C:\Users\<user_name>\AppData\Local\Programs\Python\Python313-arm64\Lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 397, in resolve
    self._add_to_criteria(self.state.criteria, r, parent=None)
    ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\<user_name>\AppData\Local\Programs\Python\Python313-arm64\Lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 173, in _add_to_criteria
    if not criterion.candidates:
           ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\<user_name>\AppData\Local\Programs\Python\Python313-arm64\Lib\site-packages\pip\_vendor\resolvelib\structs.py", line 156, in __bool__
    return bool(self._sequence)
  File "C:\Users\<user_name>\AppData\Local\Programs\Python\Python313-arm64\Lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 174, in __bool__
    return any(self)
  File "C:\Users\<user_name>\AppData\Local\Programs\Python\Python313-arm64\Lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 162, in <genexpr>
    return (c for c in iterator if id(c) not in self._incompatible_ids)
                       ^^^^^^^^
  File "C:\Users\<user_name>\AppData\Local\Programs\Python\Python313-arm64\Lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 53, in _iter_built
    candidate = func()
  File "C:\Users\<user_name>\AppData\Local\Programs\Python\Python313-arm64\Lib\site-packages\pip\_internal\resolution\resolvelib\factory.py", line 187, in _make_candidate_from_link
    base: Optional[BaseCandidate] = self._make_base_candidate_from_link(
                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        link, template, name, version
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "C:\Users\<user_name>\AppData\Local\Programs\Python\Python313-arm64\Lib\site-packages\pip\_internal\resolution\resolvelib\factory.py", line 233, in _make_base_candidate_from_link
    self._link_candidate_cache[link] = LinkCandidate(
                                       ~~~~~~~~~~~~~^
        link,
        ^^^^^
    ...<3 lines>...
        version=version,
        ^^^^^^^^^^^^^^^^
    )
    ^
  File "C:\Users\<user_name>\AppData\Local\Programs\Python\Python313-arm64\Lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 304, in __init__
    super().__init__(
    ~~~~~~~~~~~~~~~~^
        link=link,
        ^^^^^^^^^^
    ...<4 lines>...
        version=version,
        ^^^^^^^^^^^^^^^^
    )
    ^
  File "C:\Users\<user_name>\AppData\Local\Programs\Python\Python313-arm64\Lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 159, in __init__
    self.dist = self._prepare()
                ~~~~~~~~~~~~~^^
  File "C:\Users\<user_name>\AppData\Local\Programs\Python\Python313-arm64\Lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 236, in _prepare
    dist = self._prepare_distribution()
  File "C:\Users\<user_name>\AppData\Local\Programs\Python\Python313-arm64\Lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 315, in _prepare_distribution
    return preparer.prepare_linked_requirement(self._ireq, parallel_builds=True)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\<user_name>\AppData\Local\Programs\Python\Python313-arm64\Lib\site-packages\pip\_internal\operations\prepare.py", line 527, in prepare_linked_requirement
    return self._prepare_linked_requirement(req, parallel_builds)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\<user_name>\AppData\Local\Programs\Python\Python313-arm64\Lib\site-packages\pip\_internal\operations\prepare.py", line 642, in _prepare_linked_requirement
    dist = _get_prepared_distribution(
        req,
    ...<3 lines>...
        self.check_build_deps,
    )
  File "C:\Users\<user_name>\AppData\Local\Programs\Python\Python313-arm64\Lib\site-packages\pip\_internal\operations\prepare.py", line 72, in _get_prepared_distribution
    abstract_dist.prepare_distribution_metadata(
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        finder, build_isolation, check_build_deps
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "C:\Users\<user_name>\AppData\Local\Programs\Python\Python313-arm64\Lib\site-packages\pip\_internal\distributions\sdist.py", line 56, in prepare_distribution_metadata
    self._install_build_reqs(finder)
    ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
  File "C:\Users\<user_name>\AppData\Local\Programs\Python\Python313-arm64\Lib\site-packages\pip\_internal\distributions\sdist.py", line 126, in _install_build_reqs
    build_reqs = self._get_build_requires_wheel()
  File "C:\Users\<user_name>\AppData\Local\Programs\Python\Python313-arm64\Lib\site-packages\pip\_internal\distributions\sdist.py", line 103, in _get_build_requires_wheel
    return backend.get_requires_for_build_wheel()
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "C:\Users\<user_name>\AppData\Local\Programs\Python\Python313-arm64\Lib\site-packages\pip\_internal\utils\misc.py", line 701, in get_requires_for_build_wheel
    return super().get_requires_for_build_wheel(config_settings=cs)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\<user_name>\AppData\Local\Programs\Python\Python313-arm64\Lib\site-packages\pip\_vendor\pyproject_hooks\_impl.py", line 166, in get_requires_for_build_wheel
    return self._call_hook('get_requires_for_build_wheel', {
           ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        'config_settings': config_settings
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    })
    ^^
  File "C:\Users\<user_name>\AppData\Local\Programs\Python\Python313-arm64\Lib\site-packages\pip\_vendor\pyproject_hooks\_impl.py", line 321, in _call_hook
    raise BackendUnavailable(data.get('traceback', ''))
pip._vendor.pyproject_hooks._impl.BackendUnavailable: Traceback (most recent call last):
  File "C:\Users\<user_name>\AppData\Local\Programs\Python\Python313-arm64\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 77, in _build_backend
    obj = import_module(mod_path)
  File "C:\Users\<user_name>\AppData\Local\Programs\Python\Python313-arm64\Lib\importlib\__init__.py", line 88, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1310, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 1022, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "C:\Users\<user_name>\AppData\Local\Temp\pip-build-env-wgih5ett\overlay\Lib\site-packages\setuptools\__init__.py", line 10, in <module>
    import distutils.core
ModuleNotFoundError: No module named 'distutils''

**Host configuration:**
 - OS and version: Windows 11
 - CPU: Qualcomm X Elite  x1e0-78-100

**Additional context**
:(

so here as well 

setuptools

is missing the the requirements.txt
BrickDesignerNL commented 1 day ago

And again the

  AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?

error after installing setuptools using

py -m install setuptools

and then re-running requirements.txt

BrickDesignerNL commented 1 day ago

How to fix it

Not fixed

python -m qai-hub-models.models.whisper_base_en.export --target-runtime onnx

C:\Users\\miniconda3\envs\whisper\python.exe: Error while finding module specification for 'qai-hub-models.models.whisper_base_en.export' (ModuleNotFoundError: No module named 'qai-hub-models')

BrickDesignerNL commented 1 day ago

Typo in readme: https://github.com/quic/ai-hub-apps/blob/main/apps/windows/python/Whisper/README.md

Instruction needs to be

python -m qai_hub_models.models.whisper_base_en.export --target-runtime onnx

not

python -m qai-hub-models.models.whisper_base_en.export --target-runtime onnx

(underscore vs dash)

as in line with:

https://github.com/quic/ai-hub-models/tree/main/qai_hub_models/models/whisper_base_en qai_hub_models/models/whisper_base_en

BrickDesignerNL commented 23 hours ago

and don't forget to run

pip install "qai_hub_models[whisper_base_en]"

BrickDesignerNL commented 23 hours ago

How should I use: https://aihub.qualcomm.com/models/whisper_base_en?chipsets=Snapdragon+X+Elite

click "download model" on the link above to get a S3 link with temporary access to download:

https://tetrahub-qprod-userdata.s3.amazonaws.com/models/mmdyv5ywm_GLlPHt0OMqSg80pW.bin

I see an ONNX file and bin files. How can I use those? And how can I use them in a way that they run on the GPU/NPU and have a nice UI, like ONNX-web or Forge WebUI?

kory commented 20 hours ago

Typo in readme: https://github.com/quic/ai-hub-apps/blob/main/apps/windows/python/Whisper/README.md

Thanks for the report. We've actually fixed this already (yay!) and it will be included in the next release of AI Hub Apps.

I see an ONNX file and bin files. How can I use those?

Great question. The ONNX files you can download here are used by the whisper python demo you linked to above. The context binaries (.bin) are more complex. I recommend you reach out on our Slack so we can communicate more directly about this (ONNX, and Context Binaries)

AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?

I see "Python313" in your error message. Are you using Python 3.13?

I've seen similar errors before when trying it. We don't support 3.13--our supported pythons are 3.9, 3.10, 3.11, and 3.12.