yuka-friends / Windrecorder

Windrecorder is a memory search app by records everything on your screen in small size, to let you rewind what you have seen, query through OCR text or image description, and get activity statistics.
GNU General Public License v2.0
2.7k stars 110 forks source link

need help: 在使用 install_img_embedding_module.bat 安装图像语义检索时出现错误 #164

Closed TranscendMa closed 1 month ago

TranscendMa commented 1 month ago

问题描述

在尝试安装图像语义检索时出现了以下错误:

  This script will install the image semantic indexing function for Windrecorder.
  After installation, you can index and search for corresponding images using natural language descriptions.
  本向导将为捕风记录仪安装图像语义索引功能。安装完毕后,可以索引并用自然语言描述来搜索对应画面。

  ================================================================================

安装选项(将下载安装在 Windrecorder 的虚拟环境中,约占用 4G 空间):

  1. Install a version that supports CUDA acceleration for Nvidia graphics cards;
     安装支持 Nvidia 显卡 CUDA 加速的版本;

  2. Install CPU version; 安装 CPU 版本;

Please enter the options and press Enter:2
Installing an environment that supports CPU computing; 正在安装支持 CPU 运算的环境
Warning: Found deprecated priority 'default' for source 'tsinghua' in pyproject.toml. You can achieve the same effect by changing the priority to 'primary' and putting the source first.
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Requirement already satisfied: uform in d:\apps\tools\windrecorder\.venv\lib\site-packages (3.0.2)
Requirement already satisfied: huggingface-hub>=0.16.4 in d:\apps\tools\windrecorder\.venv\lib\site-packages (from uform) (0.23.0)
Requirement already satisfied: tokenizers>=0.13.3 in d:\apps\tools\windrecorder\.venv\lib\site-packages (from uform) (0.19.1)
Requirement already satisfied: pillow in d:\apps\tools\windrecorder\.venv\lib\site-packages (from uform) (10.2.0)
Requirement already satisfied: simsimd in d:\apps\tools\windrecorder\.venv\lib\site-packages (from uform) (4.3.1)
Requirement already satisfied: filelock in d:\apps\tools\windrecorder\.venv\lib\site-packages (from huggingface-hub>=0.16.4->uform) (3.13.1)
Requirement already satisfied: fsspec>=2023.5.0 in d:\apps\tools\windrecorder\.venv\lib\site-packages (from huggingface-hub>=0.16.4->uform) (2024.3.1)
Requirement already satisfied: packaging>=20.9 in d:\apps\tools\windrecorder\.venv\lib\site-packages (from huggingface-hub>=0.16.4->uform) (23.2)
Requirement already satisfied: pyyaml>=5.1 in d:\apps\tools\windrecorder\.venv\lib\site-packages (from huggingface-hub>=0.16.4->uform) (6.0.1)
Requirement already satisfied: requests in d:\apps\tools\windrecorder\.venv\lib\site-packages (from huggingface-hub>=0.16.4->uform) (2.31.0)
Requirement already satisfied: tqdm>=4.42.1 in d:\apps\tools\windrecorder\.venv\lib\site-packages (from huggingface-hub>=0.16.4->uform) (4.66.2)
Requirement already satisfied: typing-extensions>=3.7.4.3 in d:\apps\tools\windrecorder\.venv\lib\site-packages (from huggingface-hub>=0.16.4->uform) (4.10.0)
Requirement already satisfied: colorama in d:\apps\tools\windrecorder\.venv\lib\site-packages (from tqdm>=4.42.1->huggingface-hub>=0.16.4->uform) (0.4.6)
Requirement already satisfied: charset-normalizer<4,>=2 in d:\apps\tools\windrecorder\.venv\lib\site-packages (from requests->huggingface-hub>=0.16.4->uform) (3.3.2)
Requirement already satisfied: idna<4,>=2.5 in d:\apps\tools\windrecorder\.venv\lib\site-packages (from requests->huggingface-hub>=0.16.4->uform) (3.6)
Requirement already satisfied: urllib3<3,>=1.21.1 in d:\apps\tools\windrecorder\.venv\lib\site-packages (from requests->huggingface-hub>=0.16.4->uform) (2.2.1)
Requirement already satisfied: certifi>=2017.4.17 in d:\apps\tools\windrecorder\.venv\lib\site-packages (from requests->huggingface-hub>=0.16.4->uform) (2024.2.2)

  checking the installation results... 检查安装结果……

   Pytorch 未能成功安装,若重试后仍然安装失败,请复制以上报错信息前往 GitHub issue 进行反馈。
   Pytorch failed to install successfully. If the installation still fails after trying again, please copy the above error message and send it to GitHub issue for feedback.

   uform 已成功安装!
   uform has been successfully installed!
No module named 'torch'
   uform 模型似乎下载失败,请检查网络、添加代理或进行重试。
   uform model seems to have failed to download, please check the network, add a proxy, or try again.

  The installation script has been completed. 已执行完安装脚本。

我已经做过的措施:

我的使用环境:

由于本人对python相关理解较为有限,所以在此寻求帮助。如果这个问题仅仅是我的错误操作导致的,请直接关闭此issue.

TranscendMa commented 1 month ago

我尝试手动安装上述缺少的项目,但不知道如何手动安装,尤其是uform的模型,我都没找到在哪里下载😭

Antonoko commented 1 month ago

😭可以试试在 Windrecorder 目录下创建一个 temp.py,内容如下

import uform
from windrecorder import img_embed_manager

img_embed_manager.get_model("cpu")

然后在 Windrecorder 目录下执行命令

(windrecorder-py3.11) D:\git\Windrecorder>python temp.py No conda env active, defaulting to base Fetching 5 files: 100%|██████████████████████████████████████████████████████████████████████████| 5/5 [00:00<?, ?it/s]


看到log日志中还提示了`No module named 'torch'`,这种情况下torch可能没有被正确安装,可以在 Windrecorder 目录下手动执行以下命令安装torch:

poetry run pip install https://mirrors.aliyun.com/pytorch-wheels/cu121/torch-2.2.0+cu121-cp311-cp311-win_amd64.whl poetry run pip install https://mirrors.aliyun.com/pytorch-wheels/cu121/torchaudio-2.2.0+cu121-cp311-cp311-win_amd64.whl poetry run pip install https://mirrors.aliyun.com/pytorch-wheels/cu121/torchvision-0.17.0+cu121-cp311-cp311-win_amd64.whl

TranscendMa commented 1 month ago

omg 我的执行情况可能有点异常。 由于发现直接运行temp.py会提示No module named 'torch',就先安装torch,完整输入和结果如下:

PS D:\Apps\Tools\Windrecorder> poetry run pip install https://mirrors.aliyun.com/pytorch-wheels/cu121/torch-2.2.0+cu121-cp311-cp311-win_amd64.whl
Warning: Found deprecated priority 'default' for source 'tsinghua' in pyproject.toml. You can achieve the same effect by changing the priority to 'primary' and putting the source first.
Collecting torch==2.2.0+cu121
  Downloading https://mirrors.aliyun.com/pytorch-wheels/cu121/torch-2.2.0+cu121-cp311-cp311-win_amd64.whl (1090.6 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.1/1.1 GB 2.6 MB/s eta 0:00:00
ERROR: Wheel 'torch' located at C:\Users\xxx\AppData\Local\Temp\pip-unpack-9h9qsohc\torch-2.2.0+cu121-cp311-cp311-win_amd64.whl is invalid.
PS D:\Apps\Tools\Windrecorder> poetry run pip install https://mirrors.aliyun.com/pytorch-wheels/cu121/torch-2.2.0+cu121-cp311-cp311-win_amd64.whl
Warning: Found deprecated priority 'default' for source 'tsinghua' in pyproject.toml. You can achieve the same effect by changing the priority to 'primary' and putting the source first.
Collecting torch==2.2.0+cu121
  Using cached https://mirrors.aliyun.com/pytorch-wheels/cu121/torch-2.2.0+cu121-cp311-cp311-win_amd64.whl (1090.6 MB)
ERROR: Wheel 'torch' located at C:\Users\xxx\AppData\Local\Temp\pip-unpack-dwigoc8j\torch-2.2.0+cu121-cp311-cp311-win_amd64.whl is invalid.
PS D:\Apps\Tools\Windrecorder> poetry run pip install https://mirrors.aliyun.com/pytorch-wheels/cu121/torch-2.2.0+cu121-cp311-cp311-win_amd64.whl
Warning: Found deprecated priority 'default' for source 'tsinghua' in pyproject.toml. You can achieve the same effect by changing the priority to 'primary' and putting the source first.
Collecting torch==2.2.0+cu121
  Using cached https://mirrors.aliyun.com/pytorch-wheels/cu121/torch-2.2.0+cu121-cp311-cp311-win_amd64.whl (1090.6 MB)
ERROR: Wheel 'torch' located at C:\Users\xxx\AppData\Local\Temp\pip-unpack-h_z7zgev\torch-2.2.0+cu121-cp311-cp311-win_amd64.whl is invalid.

然后执行了temp.py,结果如下:

PS D:\Apps\Tools\Windrecorder> poetry run pip install https://mirrors.aliyun.com/pytorch-wheels/cu121/torchaudio-2.2.0+cu121-cp311-cp311-win_amd64.whl
Warning: Found deprecated priority 'default' for source 'tsinghua' in pyproject.toml. You can achieve the same effect by changing the priority to 'primary' and putting the source first.
Collecting torchaudio==2.2.0+cu121
  Downloading https://mirrors.aliyun.com/pytorch-wheels/cu121/torchaudio-2.2.0+cu121-cp311-cp311-win_amd64.whl (4.1 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.1/4.1 MB 4.2 MB/s eta 0:00:00
INFO: pip is looking at multiple versions of torchaudio to determine which version is compatible with other requirements. This could take a while.
ERROR: Could not find a version that satisfies the requirement torch==2.2.0+cu121 (from torchaudio) (from versions: 2.0.0, 2.0.1, 2.1.0, 2.1.1, 2.1.2, 2.2.0, 2.2.1, 2.2.2, 2.3.0)
ERROR: No matching distribution found for torch==2.2.0+cu121
PS D:\Apps\Tools\Windrecorder> poetry run pip install https://mirrors.aliyun.com/pytorch-wheels/cu121/torchvision-0.17.0+cu121-cp311-cp311-win_amd64.whl
Warning: Found deprecated priority 'default' for source 'tsinghua' in pyproject.toml. You can achieve the same effect by changing the priority to 'primary' and putting the source first.
Collecting torchvision==0.17.0+cu121
  Downloading https://mirrors.aliyun.com/pytorch-wheels/cu121/torchvision-0.17.0+cu121-cp311-cp311-win_amd64.whl (5.7 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 5.7/5.7 MB 3.8 MB/s eta 0:00:00
Requirement already satisfied: numpy in d:\apps\tools\windrecorder\.venv\lib\site-packages (from torchvision==0.17.0+cu121) (1.26.4)
Requirement already satisfied: requests in d:\apps\tools\windrecorder\.venv\lib\site-packages (from torchvision==0.17.0+cu121) (2.31.0)
INFO: pip is looking at multiple versions of torchvision to determine which version is compatible with other requirements. This could take a while.
ERROR: Could not find a version that satisfies the requirement torch==2.2.0+cu121 (from torchvision) (from versions: 2.0.0, 2.0.1, 2.1.0, 2.1.1, 2.1.2, 2.2.0, 2.2.1, 2.2.2, 2.3.0)
ERROR: No matching distribution found for torch==2.2.0+cu121
PS D:\Apps\Tools\Windrecorder> poetry run pip install https://mirrors.aliyun.com/pytorch-wheels/cu121/torchvision-0.17.0+cu121-cp311-cp311-win_amd64.whl\
Warning: Found deprecated priority 'default' for source 'tsinghua' in pyproject.toml. You can achieve the same effect by changing the priority to 'primary' and putting the source first.
Collecting https://mirrors.aliyun.com/pytorch-wheels/cu121/torchvision-0.17.0+cu121-cp311-cp311-win_amd64.whl\
  ERROR: HTTP error 404 while getting https://mirrors.aliyun.com/pytorch-wheels/cu121/torchvision-0.17.0+cu121-cp311-cp311-win_amd64.whl\
ERROR: Could not install requirement https://mirrors.aliyun.com/pytorch-wheels/cu121/torchvision-0.17.0+cu121-cp311-cp311-win_amd64.whl\ because of HTTP error 404 Client Error: Not Found for url: https://mirrors.aliyun.com/pytorch-wheels/cu121/torchvision-0.17.0+cu121-cp311-cp311-win_amd64.whl%5C for URL https://mirrors.aliyun.com/pytorch-wheels/cu121/torchvision-0.17.0+cu121-cp311-cp311-win_amd64.whl\
PS D:\Apps\Tools\Windrecorder> poetry run pip install https://mirrors.aliyun.com/pytorch-wheels/cu121/torchvision-0.17.0+cu121-cp311-cp311-win_amd64.whl
Warning: Found deprecated priority 'default' for source 'tsinghua' in pyproject.toml. You can achieve the same effect by changing the priority to 'primary' and putting the source first.
Collecting torchvision==0.17.0+cu121
  Using cached https://mirrors.aliyun.com/pytorch-wheels/cu121/torchvision-0.17.0+cu121-cp311-cp311-win_amd64.whl (5.7 MB)
Requirement already satisfied: numpy in d:\apps\tools\windrecorder\.venv\lib\site-packages (from torchvision==0.17.0+cu121) (1.26.4)
Requirement already satisfied: requests in d:\apps\tools\windrecorder\.venv\lib\site-packages (from torchvision==0.17.0+cu121) (2.31.0)
INFO: pip is looking at multiple versions of torchvision to determine which version is compatible with other requirements. This could take a while.
ERROR: Could not find a version that satisfies the requirement torch==2.2.0+cu121 (from torchvision) (from versions: 2.0.0, 2.0.1, 2.1.0, 2.1.1, 2.1.2, 2.2.0, 2.2.1, 2.2.2, 2.3.0)
ERROR: No matching distribution found for torch==2.2.0+cu121

可能我的虚拟环境有某些问题?

Antonoko commented 1 month ago

不好意思,重新检查安装脚本发现没给cpu模式添加torch的安装命令🥶(uform的依赖竟然没有带上它) 可以试试在目录下执行poetry run pip install -i https://pypi.tuna.tsinghua.edu.cn/simple torch来尝试安装cpu版本的torch

不过我用下来觉得 uform 这个嵌入模型效果并不是很好,目前也只用来嵌入图像而没有处理文本,搜索召回性能都比较差,相比 torch 依赖的巨大体积,可能不是一个太值得一试的功能(技术力太差,没能使用onnx来驱动 - -

TranscendMa commented 1 month ago

我首先执行了这个命令

poetry run pip install -i https://pypi.tuna.tsinghua.edu.cn/simple torch

接着再次执行了

poetry run pip install https://mirrors.aliyun.com/pytorch-wheels/cu121/torch-2.2.0+cu121-cp311-cp311-win_amd64.whl
poetry run pip install https://mirrors.aliyun.com/pytorch-wheels/cu121/torchaudio-2.2.0+cu121-cp311-cp311-win_amd64.whl
poetry run pip install https://mirrors.aliyun.com/pytorch-wheels/cu121/torchvision-0.17.0+cu121-cp311-cp311-win_amd64.whl

直到看上去没有任何报错,也没有任何下载进度条

然后我执行了poetry shellpython temp.py 以下是powershell窗口内的显示:

PS D:\Apps\Tools\Windrecorder> poetry shell
Warning: Found deprecated priority 'default' for source 'tsinghua' in pyproject.toml. You can achieve the same effect by changing the priority to 'primary' and putting the source first.
Spawning shell within D:\Apps\Tools\Windrecorder\.venv
Windows PowerShell
版权所有(C) Microsoft Corporation。保留所有权利。

安装最新的 PowerShell,了解新功能和改进!https://aka.ms/PSWindows

无法加载文件 D:\Apps\Tools\Windrecorder\.venv\Scripts\activate.ps1,因为在此系统上禁止运行脚本。有关详细信息,请参阅 ht
tps:/go.microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Policies。
    + CategoryInfo          : SecurityError: (:) [],ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnauthorizedAccess
PS D:\Apps\Tools\Windrecorder> poetry shell
Warning: Found deprecated priority 'default' for source 'tsinghua' in pyproject.toml. You can achieve the same effect by changing the priority to 'primary' and putting the source first.
Virtual environment already activated: D:\Apps\Tools\Windrecorder\.venv
PS D:\Apps\Tools\Windrecorder> python temp.py
Traceback (most recent call last):
  File "D:\Apps\Tools\Windrecorder\temp.py", line 1, in <module>
    import uform
ModuleNotFoundError: No module named 'uform'

不过我认为torch既然已经安装完毕,便再次尝试运行install_img_embedding_module.bat,以下是输出内容:

Warning: Found deprecated priority 'default' for source 'tsinghua' in pyproject.toml. You can achieve the same effect by changing the priority to 'primary' and putting the source first.
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Requirement already satisfied: uform in d:\apps\tools\windrecorder\.venv\lib\site-packages (3.0.2)
Requirement already satisfied: huggingface-hub>=0.16.4 in d:\apps\tools\windrecorder\.venv\lib\site-packages (from uform) (0.23.0)
Requirement already satisfied: tokenizers>=0.13.3 in d:\apps\tools\windrecorder\.venv\lib\site-packages (from uform) (0.19.1)
Requirement already satisfied: pillow in d:\apps\tools\windrecorder\.venv\lib\site-packages (from uform) (10.2.0)
Requirement already satisfied: simsimd in d:\apps\tools\windrecorder\.venv\lib\site-packages (from uform) (4.3.1)
Requirement already satisfied: filelock in d:\apps\tools\windrecorder\.venv\lib\site-packages (from huggingface-hub>=0.16.4->uform) (3.13.1)
Requirement already satisfied: fsspec>=2023.5.0 in d:\apps\tools\windrecorder\.venv\lib\site-packages (from huggingface-hub>=0.16.4->uform) (2024.3.1)
Requirement already satisfied: packaging>=20.9 in d:\apps\tools\windrecorder\.venv\lib\site-packages (from huggingface-hub>=0.16.4->uform) (23.2)
Requirement already satisfied: pyyaml>=5.1 in d:\apps\tools\windrecorder\.venv\lib\site-packages (from huggingface-hub>=0.16.4->uform) (6.0.1)
Requirement already satisfied: requests in d:\apps\tools\windrecorder\.venv\lib\site-packages (from huggingface-hub>=0.16.4->uform) (2.31.0)
Requirement already satisfied: tqdm>=4.42.1 in d:\apps\tools\windrecorder\.venv\lib\site-packages (from huggingface-hub>=0.16.4->uform) (4.66.2)
Requirement already satisfied: typing-extensions>=3.7.4.3 in d:\apps\tools\windrecorder\.venv\lib\site-packages (from huggingface-hub>=0.16.4->uform) (4.10.0)
Requirement already satisfied: colorama in d:\apps\tools\windrecorder\.venv\lib\site-packages (from tqdm>=4.42.1->huggingface-hub>=0.16.4->uform) (0.4.6)
Requirement already satisfied: charset-normalizer<4,>=2 in d:\apps\tools\windrecorder\.venv\lib\site-packages (from requests->huggingface-hub>=0.16.4->uform) (3.3.2)
Requirement already satisfied: idna<4,>=2.5 in d:\apps\tools\windrecorder\.venv\lib\site-packages (from requests->huggingface-hub>=0.16.4->uform) (3.6)
Requirement already satisfied: urllib3<3,>=1.21.1 in d:\apps\tools\windrecorder\.venv\lib\site-packages (from requests->huggingface-hub>=0.16.4->uform) (2.2.1)
Requirement already satisfied: certifi>=2017.4.17 in d:\apps\tools\windrecorder\.venv\lib\site-packages (from requests->huggingface-hub>=0.16.4->uform) (2024.2.2)

  checking the installation results... 检查安装结果……

   你的设备似乎不支持 CUDA 加速、或安装了 CPU 计算的 pytorch 环境。在索引时可能会存在性能问题。
   Your device does not seem to support CUDA acceleration, or the pytorch environment for CPU computing is installed. There may be performance issues during indexing.

   uform 已成功安装!
   uform has been successfully installed!
No conda env active, defaulting to base
module 'uform' has no attribute 'models'
   uform 模型似乎下载失败,请检查网络、添加代理或进行重试。
   uform model seems to have failed to download, please check the network, add a proxy, or try again.

  The installation script has been completed. 已执行完安装脚本。

报错少了一个,但uform模型似乎依旧没能正常安装。

作者大大加油。同时我在频繁启动/退出本软件的过程中发现其在本机上启动/退出的进程执行比较缓慢(~30s)。一般我在暂停录制之后才会选择退出,此时托盘图标的右键菜单需要过很久才能唤出,并且有时候选择了退出,依然要花上数分钟或者无法退出 (>10min)

不过我用下来觉得 uform 这个嵌入模型效果并不是很好,目前也只用来嵌入图像而没有处理文本,搜索召回性能都比较差,相比 torch 依赖的巨大体积,可能不是一个太值得一试的功能(技术力太差,没能使用onnx来驱动 - -

XiaoNieGPT commented 1 month ago

报错少了一个,但uform模型似乎依旧没能正常安装。

同款错误,怎么处理啊

Antonoko commented 1 month ago

uform has been updated to the latest version model and relies on ONNX runtime for inference. Feel free to upgrade and try to re-install.