Git Product home page Git Product logo

genshin_auto_fish's Introduction

Introduction

现已支持不同分辨率屏幕

原神自动钓鱼AI由YOLOX, DQN两部分模型组成。使用迁移学习,半监督学习进行训练。 模型也包含一些使用opencv等传统数字图像处理方法实现的不可学习部分。

其中YOLOX用于鱼的定位和类型的识别以及鱼竿落点的定位。DQN用于自适应控制钓鱼过程的点击,让力度落在最佳区域内。

安装使用流程

安装python运行环境(解释器),推荐使用 anaconda.

python环境配置

打开anaconda prompt(命令行界面),创建新python环境并激活:

conda create -n ysfish python=3.8
conda activate ysfish

推荐安装python3.8或以下版本。

下载工程代码

使用git下载,git安装教程:

git clone https://github.com/7eu7d7/genshin_auto_fish.git

或直接在github网页端下载后直接解压。

依赖库安装

切换命令行到本工程所在目录:

cd genshin_auto_fish

执行以下命令安装依赖:

python -m pip install -U pip
python requirements.py

如果要使用显卡进行加速需要 安装CUDA和cudnn 安装后无视上面的命令用下面这条安装gpu版:

pip install -U pip
python requirements.py --cuda [cuda版本]
#例如安装的CUDA11.x
python requirements.py --cuda 111
#或者使用代理加速
python requirements.py --cuda 111 --proxy http://127.0.0.1:1080 # use proxy to speed up

可能会有Time out之类的报错,多试几遍,github太卡。

安装yolox

切换命令行到本工程所在目录,执行以下命令安装yolox:

python setup.py develop

预训练权重下载

下载后将权重文件放在 工程目录/weights

运行钓鱼AI

原神需要以1080x1920的分辨率运行,分辨率高的屏幕可以开窗口模式。

命令行窗口一定要以管理员权限启动

显卡加速

python fishing.py image -f yolox/exp/yolox_tiny_fish.py -c weights/best_tiny3.pth --conf 0.25 --nms 0.45 --tsize 640 --device gpu

cpu运行

python fishing.py image -f yolox/exp/yolox_tiny_fish.py -c weights/best_tiny3.pth --conf 0.25 --nms 0.45 --tsize 640 --device cpu

运行后出现init ok后按r键开始钓鱼,原神需要全屏。出于性能考虑检测框不会实时显示,处理运算后台进行。

YOLOX训练工作流程

<只用来钓鱼不需要训练,直接用预训练权重就可以>

YOLOX部分因为打标签太累所以用半监督学习。标注少量样本后训练模型生成其余样本伪标签再人工修正,不断迭代提高精度。 样本量较少所以使用迁移学习,在COCO预训练的模型上进行fine-tuning.

下载数据集并解压:原神鱼群数据集, 数据集(迅雷云盘:ugha)

将yolox/exp/yolox_tiny_fish.py中的self.data_dir的值改为解压后2个文件夹所在的路径。

训练代码:

python yolox_tools/train.py -f yolox/exp/yolox_tiny_fish.py -d 1 -b 8 --fp16 -o -c weights/yolox_tiny.pth

DQN训练工作流程

控制力度使用强化学习模型DQN进行训练。两次进度的差值作为reward为模型提供学习方向。模型与环境间交互式学习。

直接在原神内训练耗时较长,太累了。首先制作一个仿真环境,大概模拟钓鱼力度控制操作。在仿真环境内预训练一个模型。 随后将这一模型迁移至原神内,实现域间迁移。

仿真环境预训练代码:

python train_sim.py

原神游戏内训练:

python train.py

genshin_auto_fish's People

Contributors

fishmagic avatar hgjazhgj avatar irisrainbowneko avatar paombxxw avatar wasabiegg avatar wydy avatar yue-plus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

genshin_auto_fish's Issues

钓鱼的时候,鱼上钩不会点击鼠标左键

genshin_auto_fish\fisher\environment.py", line 61, in throw_rod
obj_list, outputs, img_info = self.predictor.image_det(cap(), with_info=True)
TypeError: 'NoneType' object is not iterable

请问这个应该怎么解决呢

Index Error

QQ截图20210922170941
init ok后开始钓鱼没反应,不接管。 过段时间后报这个。

[Errno 32] Broken pipe问题

File "E:\Download\python\envs\ysfish\lib\multiprocessing\reduction.py", line 60, in dump
ForkingPickler(file, protocol).dump(obj)
│ │ │ └ <Process(Process-3, initial daemon)>
│ │ └ None
│ └ <_io.BufferedWriter name=4>
└ <class 'multiprocessing.reduction.ForkingPickler'>

BrokenPipeError: [Errno 32] Broken pipe
如何解决?

推荐使用pyWinHook或pywin32替换停止维护的pyHook

根据官方介绍,pyHook早已经停止维护,pyWinHook是它的一个fork,并且有后续维护。
但是pyWinHook也只维护到python 3.8版本。
我刚刚读了代码,发现environment里面并没有用到太多复杂的hook,完全可以考虑使用pywin32这个基础包代替pyHook。

安装yolox失败

(ysfish) C:\Users\xx\Downloads\genshin_auto_fish>python setup.py develop
running develop
running egg_info
writing yolox.egg-info\PKG-INFO
writing dependency_links to yolox.egg-info\dependency_links.txt
writing top-level names to yolox.egg-info\top_level.txt
D:\Anaconda\envs\ysfish\lib\site-packages\torch\utils\cpp_extension.py:339: UserWarning: Attempted to use ninja as the BuildExtension backend but we could not find ninja.. Falling back to using the slow distutils backend.
warnings.warn(msg.format('we could not find ninja.'))
reading manifest file 'yolox.egg-info\SOURCES.txt'
writing manifest file 'yolox.egg-info\SOURCES.txt'
running build_ext
D:\Anaconda\envs\ysfish\lib\site-packages\torch\utils\cpp_extension.py:274: UserWarning: Error checking compiler version for cl: [WinError 2] 系统找不到指定的文件。
warnings.warn('Error checking compiler version for {}: {}'.format(compiler, error))
building 'yolox._C' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools

Building wheel for pycocotools (setup.py) ... error

Collecting git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI Cloning https://github.com/philferriere/cocoapi.git to c:\users\winds\appdata\local\temp\pip-req-build-1h2nkaa4 Running command git clone -q https://github.com/philferriere/cocoapi.git 'C:\Users\winds\AppData\Local\Temp\pip-req-build-1h2nkaa4' Resolved https://github.com/philferriere/cocoapi.git to commit 2929bd2ef6b451054755dfd7ceb09278f935f7ad Building wheels for collected packages: pycocotools Building wheel for pycocotools (setup.py) ... error ERROR: Command errored out with exit status 1: command: 'C:\Users\winds.conda\envs\ysfish\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\winds\AppData\Local\Temp\pip-req-build-1h2nkaa4\PythonAPI\setup.py'"'"'; file='"'"'C:\Users\winds\AppData\Local\Temp\pip-req-build-1h2nkaa4\PythonAPI\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\winds\AppData\Local\Temp\pip-wheel-u7e0novk' cwd: C:\Users\winds\AppData\Local\Temp\pip-req-build-1h2nkaa4\PythonAPI Complete output (13 lines): running bdist_wheel running build running build_py creating build creating build\lib.win-amd64-3.6 creating build\lib.win-amd64-3.6\pycocotools copying pycocotools\coco.py -> build\lib.win-amd64-3.6\pycocotools copying pycocotools\cocoeval.py -> build\lib.win-amd64-3.6\pycocotools copying pycocotools\mask.py -> build\lib.win-amd64-3.6\pycocotools copying pycocotools_init_.py -> build\lib.win-amd64-3.6\pycocotools running build_ext building 'pycocotools._mask' extension error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/ ---------------------------------------- ERROR: Failed building wheel for pycocotools Running setup.py clean for pycocotools ERROR: Command errored out with exit status 1: command: 'C:\Users\winds.conda\envs\ysfish\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\winds\AppData\Local\Temp\pip-req-build-1h2nkaa4\PythonAPI\setup.py'"'"'; file='"'"'C:\Users\winds\AppData\Local\Temp\pip-req-build-1h2nkaa4\PythonAPI\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' clean --all cwd: C:\Users\winds\AppData\Local\Temp\pip-req-build-1h2nkaa4 Complete output (11 lines): Traceback (most recent call last): File "", line 1, in File "C:\Users\winds\AppData\Local\Temp\pip-req-build-1h2nkaa4\PythonAPI\setup.py", line 25, in cythonize(ext_modules) File "C:\Users\winds.conda\envs\ysfish\lib\site-packages\Cython\Build\Dependencies.py", line 972, in cythonize aliases=aliases) File "C:\Users\winds.conda\envs\ysfish\lib\site-packages\Cython\Build\Dependencies.py", line 815, in create_extension_list for file in nonempty(sorted(extended_iglob(filepattern)), "'%s' doesn't match any files" % filepattern): File "C:\Users\winds.conda\envs\ysfish\lib\site-packages\Cython\Build\Dependencies.py", line 114, in nonempty raise ValueError(error_msg) ValueError: 'pycocotools/_mask.pyx' doesn't match any files ---------------------------------------- ERROR: Failed cleaning build dir for pycocotools Failed to build pycocotools Installing collected packages: pycocotools Running setup.py install for pycocotools ... error ERROR: Command errored out with exit status 1: command: 'C:\Users\winds.conda\envs\ysfish\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\winds\AppData\Local\Temp\pip-req-build-1h2nkaa4\PythonAPI\setup.py'"'"'; file='"'"'C:\Users\winds\AppData\Local\Temp\pip-req-build-1h2nkaa4\PythonAPI\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record 'C:\Users\winds\AppData\Local\Temp\pip-record-5_cc_gg0\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\winds.conda\envs\ysfish\Include\pycocotools' cwd: C:\Users\winds\AppData\Local\Temp\pip-req-build-1h2nkaa4\PythonAPI Complete output (6 lines): running install running build running build_py running build_ext building 'pycocotools._mask' extension error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/ ---------------------------------------- ERROR: Command errored out with exit status 1: 'C:\Users\winds.conda\envs\ysfish\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\winds\AppData\Local\Temp\pip-req-build-1h2nkaa4\PythonAPI\setup.py'"'"'; file='"'"'C:\Users\winds\AppData\Local\Temp\pip-req-build-1h2nkaa4\PythonAPI\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record 'C:\Users\winds\AppData\Local\Temp\pip-record-5_cc_gg0\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\winds.conda\envs\ysfish\Include\pycocotools' Check the logs for full command output. WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip. Please see pypa/pip#5599 for advice on fixing the underlying issue. To avoid this problem you can invoke Python with '-m pip' instead of running pip directly. ERROR: You must give at least one requirement to install (see "pip help install")

yolox训练报错

yolox在训练时会跳出AttributeError: module 'torch._C' has no attribute '_cuda_setDevice'
image

使用cpu运行时输入指令后输入r提示

python fishing.py image -f yolox/exp/yolox_tiny_fish.py -c weights/best_tiny3.pth --conf 0.25 --nms 0.45 --tsize 640 --device cpu

r : 2021-09-21 16:02:01.087 | INFO | main:main:91 - Args: Namespace(ckpt='weights/best_tiny3.pth', conf=0.25, d
emo='image', device='cpu', exp_file='yolox/exp/yolox_tiny_fish.py', experiment_name='yolox_tiny_fish', fp16=False, fuse
=False, legacy=False, model_dir='./weights/fish_genshin_net.pth', n_actions=2, n_states=3, name=None, nms=0.45, path='.
/assets/dog.jpg', step_tick=12, trt=False, tsize=640)
所在位置 行:1 字符: 1

  • r
  • ~
    • CategoryInfo : NotSpecified: (2021-09-21 16:0...lse, tsize=640):String) [Invoke-History], RemoteExcepti
      on
    • FullyQualifiedErrorId : NativeCommandError,Microsoft.PowerShell.Commands.InvokeHistoryCommand

r : 2021-09-21 16:02:02.845 | INFO | main:main:101 - Model Summary: Params: 5.03M, Gflops: 15.15
所在位置 行:1 字符: 1

  • r
  • ~
    • CategoryInfo : NotSpecified: (2021-09-21 16:0..., Gflops: 15.15:String) [Invoke-History], RemoteExcepti
      on
    • FullyQualifiedErrorId : NativeCommandErrorMessage,Microsoft.PowerShell.Commands.InvokeHistoryCommand

r : 2021-09-21 16:02:02.859 | INFO | main:main:114 - loading checkpoint
所在位置 行:1 字符: 1

  • r
  • ~
    • CategoryInfo : NotSpecified: (2021-09-21 16:0...ding checkpoint:String) [Invoke-History], RemoteExcepti
      on
    • FullyQualifiedErrorId : NativeCommandErrorMessage,Microsoft.PowerShell.Commands.InvokeHistoryCommand

r : 2021-09-21 16:02:04.586 | INFO | main:main:118 - loaded checkpoint done.
所在位置 行:1 字符: 1

  • r
  • ~
    • CategoryInfo : NotSpecified: (2021-09-21 16:0...heckpoint done.:String) [Invoke-History], RemoteExcepti
      on
    • FullyQualifiedErrorId : NativeCommandErrorMessage,Microsoft.PowerShell.Commands.InvokeHistoryCommand

r : Traceback (most recent call last):
所在位置 行:1 字符: 1

  • r
  • ~
    • CategoryInfo : NotSpecified: (Traceback (most recent call last)::String) [Invoke-History], RemoteExcept
      ion
    • FullyQualifiedErrorId : NativeCommandErrorMessage,Microsoft.PowerShell.Commands.InvokeHistoryCommand

r : File "fishing.py", line 189, in
所在位置 行:1 字符: 1

  • r
  • ~
    • CategoryInfo : NotSpecified: ( File "fishing...89, in :String) [Invoke-History], RemoteExcepti
      on
    • FullyQualifiedErrorId : NativeCommandErrorMessage,Microsoft.PowerShell.Commands.InvokeHistoryCommand

r : main(exp, args)
所在位置 行:1 字符: 1

  • r
  • ~
    • CategoryInfo : NotSpecified: ( main(exp, args):String) [Invoke-History], RemoteException
    • FullyQualifiedErrorId : NativeCommandErrorMessage,Microsoft.PowerShell.Commands.InvokeHistoryCommand

r : File "fishing.py", line 148, in main
所在位置 行:1 字符: 1

  • r
  • ~
    • CategoryInfo : NotSpecified: ( File "fishing.py", line 148, in main:String) [Invoke-History], RemoteEx
      ception
    • FullyQualifiedErrorId : NativeCommandErrorMessage,Microsoft.PowerShell.Commands.InvokeHistoryCommand

r : start_fishing(predictor, agent)
所在位置 行:1 字符: 1

  • r
  • ~
    • CategoryInfo : NotSpecified: ( start_fishing(predictor, agent):String) [Invoke-History], RemoteExcep
      tion
    • FullyQualifiedErrorId : NativeCommandErrorMessage,Microsoft.PowerShell.Commands.InvokeHistoryCommand

r : File "fishing.py", line 155, in start_fishing
所在位置 行:1 字符: 1

  • r
  • ~
    • CategoryInfo : NotSpecified: ( File "fishing...n start_fishing:String) [Invoke-History], RemoteExcepti
      on
    • FullyQualifiedErrorId : NativeCommandErrorMessage,Microsoft.PowerShell.Commands.InvokeHistoryCommand

r : winsound.Beep(500, 500)
所在位置 行:1 字符: 1

  • r
  • ~
    • CategoryInfo : NotSpecified: ( winsound.Beep(500, 500):String) [Invoke-History], RemoteException
    • FullyQualifiedErrorId : NativeCommandErrorMessage,Microsoft.PowerShell.Commands.InvokeHistoryCommand

r : RuntimeError: Failed to beep
所在位置 行:1 字符: 1

  • r
  • ~
    • CategoryInfo : NotSpecified: (RuntimeError: Failed to beep:String) [Invoke-History], RemoteException
    • FullyQualifiedErrorId : NativeCommandErrorMessage,Microsoft.PowerShell.Commands.InvokeHistoryCommand

init ok

YOLO训练时报错

(ysfish) C:\Users\winds\Downloads\genshin_auto_fish-master>python yolox_tools/train.py -f yolox/exp/yolox_tiny_fish.py -d 1 -b 8 --fp16 -o -c weights/yolox_tiny.pth 2021-09-22 11:45:57 | INFO | yolox.core.trainer:126 - args: Namespace(batch_size=8, cache=False, ckpt='weights/yolox_tiny.pth', devices=1, dist_backend='nccl', dist_url=None, exp_file='yolox/exp/yolox_tiny_fish.py', experiment_name='yolox_tiny_fish', fp16=True, machine_rank=0, name=None, num_machines=1, occupy=True, opts=[], resume=False, start_epoch=None) 2021-09-22 11:45:57 | INFO | yolox.core.trainer:127 - exp value: ╒══════════════════╤═════════════════════════╕ │ keys │ values │ ╞══════════════════╪═════════════════════════╡ │ seed │ None │ ├──────────────────┼─────────────────────────┤ │ output_dir │ './YOLOX_outputs' │ ├──────────────────┼─────────────────────────┤ │ print_interval │ 10 │ ├──────────────────┼─────────────────────────┤ │ eval_interval │ 10 │ ├──────────────────┼─────────────────────────┤ │ num_classes │ 6 │ ├──────────────────┼─────────────────────────┤ │ depth │ 0.33 │ ├──────────────────┼─────────────────────────┤ │ width │ 0.375 │ ├──────────────────┼─────────────────────────┤ │ data_num_workers │ 4 │ ├──────────────────┼─────────────────────────┤ │ input_size │ (640, 640) │ ├──────────────────┼─────────────────────────┤ │ multiscale_range │ 5 │ ├──────────────────┼─────────────────────────┤ │ data_dir │ '../datas/fish_dataset' │ ├──────────────────┼─────────────────────────┤ │ data_name │ 'images' │ ├──────────────────┼─────────────────────────┤ │ val_name │ 'images' │ ├──────────────────┼─────────────────────────┤ │ train_ann │ 'fish_p2_75+jam.json' │ ├──────────────────┼─────────────────────────┤ │ val_ann │ 'fish_p2_75+jam.json' │ ├──────────────────┼─────────────────────────┤ │ mosaic_prob │ 1.0 │ ├──────────────────┼─────────────────────────┤ │ mixup_prob │ 1.0 │ ├──────────────────┼─────────────────────────┤ │ hsv_prob │ 1.0 │ ├──────────────────┼─────────────────────────┤ │ flip_prob │ 0.5 │ ├──────────────────┼─────────────────────────┤ │ degrees │ 10.0 │ ├──────────────────┼─────────────────────────┤ │ translate │ 0.1 │ ├──────────────────┼─────────────────────────┤ │ mosaic_scale │ (0.5, 1.5) │ ├──────────────────┼─────────────────────────┤ │ mixup_scale │ (0.5, 1.5) │ ├──────────────────┼─────────────────────────┤ │ shear │ 2.0 │ ├──────────────────┼─────────────────────────┤ │ perspective │ 0.0 │ ├──────────────────┼─────────────────────────┤ │ enable_mixup │ False │ ├──────────────────┼─────────────────────────┤ │ warmup_epochs │ 5 │ ├──────────────────┼─────────────────────────┤ │ max_epoch │ 35 │ ├──────────────────┼─────────────────────────┤ │ warmup_lr │ 0 │ ├──────────────────┼─────────────────────────┤ │ basic_lr_per_img │ 0.00025 │ ├──────────────────┼─────────────────────────┤ │ scheduler │ 'yoloxwarmcos' │ ├──────────────────┼─────────────────────────┤ │ no_aug_epochs │ 15 │ ├──────────────────┼─────────────────────────┤ │ min_lr_ratio │ 0.05 │ ├──────────────────┼─────────────────────────┤ │ ema │ True │ ├──────────────────┼─────────────────────────┤ │ weight_decay │ 0.0005 │ ├──────────────────┼─────────────────────────┤ │ momentum │ 0.9 │ ├──────────────────┼─────────────────────────┤ │ exp_name │ 'yolox_tiny_fish' │ ├──────────────────┼─────────────────────────┤ │ test_size │ (416, 416) │ ├──────────────────┼─────────────────────────┤ │ test_conf │ 0.01 │ ├──────────────────┼─────────────────────────┤ │ nmsthre │ 0.65 │ ├──────────────────┼─────────────────────────┤ │ input_scale │ (416, 416) │ ├──────────────────┼─────────────────────────┤ │ random_size │ (10, 20) │ ╘══════════════════╧═════════════════════════╛ 2021-09-22 11:45:57 | INFO | yolox.core.trainer:133 - Model Summary: Params: 5.03M, Gflops: 6.40 2021-09-22 11:45:59 | INFO | yolox.core.trainer:286 - loading checkpoint for fine tuning 2021-09-22 11:46:00 | WARNING | yolox.utils.checkpoint:26 - Shape of head.cls_preds.0.weight in checkpoint is torch.Size([80, 96, 1, 1]), while shape of head.cls_preds.0.weight in model is torch.Size([6, 96, 1, 1]). 2021-09-22 11:46:00 | WARNING | yolox.utils.checkpoint:26 - Shape of head.cls_preds.0.bias in checkpoint is torch.Size([80]), while shape of head.cls_preds.0.bias in model is torch.Size([6]). 2021-09-22 11:46:00 | WARNING | yolox.utils.checkpoint:26 - Shape of head.cls_preds.1.weight in checkpoint is torch.Size([80, 96, 1, 1]), while shape of head.cls_preds.1.weight in model is torch.Size([6, 96, 1, 1]). 2021-09-22 11:46:00 | WARNING | yolox.utils.checkpoint:26 - Shape of head.cls_preds.1.bias in checkpoint is torch.Size([80]), while shape of head.cls_preds.1.bias in model is torch.Size([6]). 2021-09-22 11:46:00 | WARNING | yolox.utils.checkpoint:26 - Shape of head.cls_preds.2.weight in checkpoint is torch.Size([80, 96, 1, 1]), while shape of head.cls_preds.2.weight in model is torch.Size([6, 96, 1, 1]). 2021-09-22 11:46:00 | WARNING | yolox.utils.checkpoint:26 - Shape of head.cls_preds.2.bias in checkpoint is torch.Size([80]), while shape of head.cls_preds.2.bias in model is torch.Size([6]). 2021-09-22 11:46:00 | INFO | yolox.data.datasets.coco:45 - loading annotations into memory... Exception ignored in: <bound method COCODataset.del of <yolox.data.datasets.coco.COCODataset object at 0x000001A99913D860>> Traceback (most recent call last): 2021-09-22 11:46:00 File "c:\users\winds\downloads\genshin_auto_fish-master\yolox\data\datasets\coco.py", line 62, in del del self.imgs | AttributeError: imgs ERROR | yolox.core.launch:98 - An error has been caught in function 'launch', process 'MainProcess' (17720), thread 'MainThread' (3104): Traceback (most recent call last): File "yolox_tools\train.py", line 132, in args=(exp, args), │ └ Namespace(batch_size=8, cache=False, ckpt='weights/yolox_tiny.pth', devices=1, dist_backend='nccl', dist_url=None, exp_file='... └ ╒══════════════════╤═════════════════════════════════════════════════════════════════════════════════════════════════════════... > File "c:\users\winds\downloads\genshin_auto_fish-master\yolox\core\launch.py", line 98, in launch main_func(*args) │ └ (╒══════════════════╤════════════════════════════════════════════════════════════════════════════════════════════════════════... └ <function main at 0x000001A9911350D0> File "yolox_tools\train.py", line 110, in main trainer.train() │ └ <function Trainer.train at 0x000001A98F51D6A8> └ <yolox.core.trainer.Trainer object at 0x000001A99113CA58> File "c:\users\winds\downloads\genshin_auto_fish-master\yolox\core\trainer.py", line 70, in train self.before_train() │ └ <function Trainer.before_train at 0x000001A99011A598> └ <yolox.core.trainer.Trainer object at 0x000001A99113CA58> File "c:\users\winds\downloads\genshin_auto_fish-master\yolox\core\trainer.py", line 149, in before_train cache_img=self.args.cache, │ │ └ False │ └ Namespace(batch_size=8, cache=False, ckpt='weights/yolox_tiny.pth', devices=1, dist_backend='nccl', dist_url=None, exp_file='... └ <yolox.core.trainer.Trainer object at 0x000001A99113CA58> File "c:\users\winds\downloads\genshin_auto_fish-master\yolox\exp\yolox_base.py", line 122, in get_data_loader cache=cache_img, └ False File "c:\users\winds\downloads\genshin_auto_fish-master\yolox\data\datasets\coco.py", line 45, in init self.coco = COCO(os.path.join(self.data_dir, "annotations", self.json_file)) │ │ │ │ │ │ │ │ └ 'fish_p2_75+jam.json' │ │ │ │ │ │ │ └ <yolox.data.datasets.coco.COCODataset object at 0x000001A99913D860> │ │ │ │ │ │ └ '../datas/fish_dataset' │ │ │ │ │ └ <yolox.data.datasets.coco.COCODataset object at 0x000001A99913D860> │ │ │ │ └ <function join at 0x000001A90F6E3620> │ │ │ └ <module 'ntpath' from 'C:\ProgramData\Anaconda3\envs\ysfish\lib\ntpath.py'> │ │ └ <module 'os' from 'C:\ProgramData\Anaconda3\envs\ysfish\lib\os.py'> │ └ <class 'pycocotools.coco.COCO'> └ <yolox.data.datasets.coco.COCODataset object at 0x000001A99913D860> File "C:\ProgramData\Anaconda3\envs\ysfish\lib\site-packages\pycocotools\coco.py", line 85, in init dataset = json.load(open(annotation_file, 'r')) │ │ └ '../datas/fish_dataset\annotations\fish_p2_75+jam.json' │ └ <function load at 0x000001A9117DEB70> └ <module 'json' from 'C:\ProgramData\Anaconda3\envs\ysfish\lib\json\init.py'> FileNotFoundError: [Errno 2] No such file or directory: '../datas/fish_dataset\annotations\fish_p2_75+jam.json'

屏幕截图(17).png
屏幕截图(19).png
屏幕截图(20).png
屏幕截图(18).png

五个环境全爆这个

'config_settings': config_settings

File "D:\Program Files\python\envs\ysfish2\lib\site-packages\pip_vendor\pep517\wrappers.py", line 328, in _call_hook
raise BackendUnavailable(data.get('traceback', ''))
pip._vendor.pep517.wrappers.BackendUnavailable: Traceback (most recent call last):
File "D:\Program Files\python\envs\ysfish2\lib\site-packages\pip_vendor\pep517\in_process_in_process.py", line 89, in build_backend
obj = import_module(mod_path)
File "D:\Program Files\python\envs\ysfish2\lib\importlib_init
.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 994, in _gcd_import
File "", line 971, in _find_and_load
File "", line 941, in _find_and_load_unlocked
File "", line 219, in _call_with_frames_removed
File "", line 994, in _gcd_import
File "", line 971, in _find_and_load
File "", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'setuptools'

关于安装教程

关于 pip 升级

不清楚作者是如何升级 pip 的,教程里的命令会不会报错。
以下是个人拙见,望参考:

pip 由于是 lib 模块,直接 pip install pip -U 升级的话可能存在权限问题,建议改成以下命令:

python -m pip install pip -U

根据 #2 的报错,以下命令也许也行?

pip install pip -U --user

关于 yolox 安装

这个 emmmmmm,有点怪。
因为其他库的需要,我之前已经装过 msvc++ 14.0了,但我这里一直报error: Microsoft Visual C++ 14.0 or greater is required,如图。
image
image

不知道是不是需要额外设置什么环境变量,还是说我装的和被要求的 build 版本不对,又或许和我 OS 版本有关系?(Windows 10 19041.1237)
C++ 这方面不怎么擅长,我也尝试了用 conda 安装 msvc_runtime 再安装 yolox、或手动 clone yolox 的库进行安装,结果都是报这个错。

准备尝试重装一个 msvc 14.0 再试试,有进展再来更新。

鱼儿上钩后不会自动收杆

2021-09-21.12-52-18.mp4

image
image
游戏全屏了 使用的管理员权限运行的程序
启动程序的指令:python fishing.py image -f yolox/exp/yolox_tiny_fish.py -c weights/best_tiny3.pth --conf 0.25 --nms 0.45 --tsize 640 --device cpu
游戏的显示设置(不知道会不会和这个有关系):
image

钓鱼精度问题

存在脱钩情况 游戏表现也低于视频表现 想问一下是模型精度问题吗 训练的还不够的原因? 还是我电脑比较卡?导致点击信号没有及时传输进去? 想请教一下

CUDA分配内存失败

设置了batch-size = 2仍旧无法分配
image
请问cuda是分配内存还是显存?应该是显存吧
1050ti显存记得是4G 但是batch-size已经设置为2仍无法分配 请问应该如何修改?

尝试只用CPU时报错Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. If you are running on a CPU-only machine, please use torch.load with map_location=torch.device('cpu') to map your storages to the CPU.

我尝试运行
python fishing.py image -f yolox/exp/yolox_tiny_fish.py -c weights/best_tiny3.pth --conf 0.25 --nms 0.45 --tsize 640 --device cpu
时报错
Traceback (most recent call last):
File "fishing.py", line 189, in
main(exp, args)
File "fishing.py", line 143, in main
agent.load_state_dict(torch.load(args.model_dir))
File "C:\Users\34703.conda\envs\ysfish\lib\site-packages\torch\serialization.py", line 594, in load
return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
File "C:\Users\34703.conda\envs\ysfish\lib\site-packages\torch\serialization.py", line 853, in _load
result = unpickler.load()
File "C:\Users\34703.conda\envs\ysfish\lib\site-packages\torch\serialization.py", line 845, in persistent_load
load_tensor(data_type, size, key, _maybe_decode_ascii(location))
File "C:\Users\34703.conda\envs\ysfish\lib\site-packages\torch\serialization.py", line 834, in load_tensor
loaded_storages[key] = restore_location(storage, location)
File "C:\Users\34703.conda\envs\ysfish\lib\site-packages\torch\serialization.py", line 175, in default_restore_location
result = fn(storage, location)
File "C:\Users\34703.conda\envs\ysfish\lib\site-packages\torch\serialization.py", line 151, in _cuda_deserialize
device = validate_cuda_device(location)
File "C:\Users\34703.conda\envs\ysfish\lib\site-packages\torch\serialization.py", line 135, in validate_cuda_device
raise RuntimeError('Attempting to deserialize object on a CUDA '
RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. If you are running on a CPU-only machine, please use torch.load with map_location=torch.device('cpu') to map your storages to the CPU.
image

尝试根据报错将fishing.py的115行改为ckpt = torch.load(ckpt_file, map_location=torch.device('cpu'))
仍出现此报错

YOLOX训练时报错

(ysfish) C:\Users\winds\Downloads\genshin_auto_fish-master>python yolox_tools/train.py -f yolox/exp/yolox_tiny_fish.py -d 1 -b 8 --fp16 -o -c weights/yolox_tiny.pth C:\Users\winds.conda\envs\ysfish\lib\site-packages\torch\cuda\amp\grad_scaler.py:115: UserWarning: torch.cuda.amp.GradScaler is enabled, but CUDA is not available. Disabling. warnings.warn("torch.cuda.amp.GradScaler is enabled, but CUDA is not available. Disabling.") 2021-09-21 17:29:46 | INFO | yolox.core.trainer:126 - args: Namespace(batch_size=8, cache=False, ckpt='weights/yolox_tiny.pth', devices=1, dist_backend='nccl', dist_url=None, exp_file='yolox/exp/yolox_tiny_fish.py', experiment_name='yolox_tiny_fish', fp16=True, machine_rank=0, name=None, num_machines=1, occupy=True, opts=[], resume=False, start_epoch=None) 2021-09-21 17:29:46 | INFO | yolox.core.trainer:127 - exp value: ╒══════════════════╤═════════════════════════╕ │ keys │ values │ ╞══════════════════╪═════════════════════════╡ │ seed │ None │ ├──────────────────┼─────────────────────────┤ │ output_dir │ './YOLOX_outputs' │ ├──────────────────┼─────────────────────────┤ │ print_interval │ 10 │ ├──────────────────┼─────────────────────────┤ │ eval_interval │ 10 │ ├──────────────────┼─────────────────────────┤ │ num_classes │ 6 │ ├──────────────────┼─────────────────────────┤ │ depth │ 0.33 │ ├──────────────────┼─────────────────────────┤ │ width │ 0.375 │ ├──────────────────┼─────────────────────────┤ │ data_num_workers │ 4 │ ├──────────────────┼─────────────────────────┤ │ input_size │ (640, 640) │ ├──────────────────┼─────────────────────────┤ │ multiscale_range │ 5 │ ├──────────────────┼─────────────────────────┤ │ data_dir │ '../datas/fish_dataset' │ ├──────────────────┼─────────────────────────┤ │ data_name │ 'images' │ ├──────────────────┼─────────────────────────┤ │ val_name │ 'images' │ ├──────────────────┼─────────────────────────┤ │ train_ann │ 'fish_p2_75+jam.json' │ ├──────────────────┼─────────────────────────┤ │ val_ann │ 'fish_p2_75+jam.json' │ ├──────────────────┼─────────────────────────┤ │ mosaic_prob │ 1.0 │ ├──────────────────┼─────────────────────────┤ │ mixup_prob │ 1.0 │ ├──────────────────┼─────────────────────────┤ │ hsv_prob │ 1.0 │ ├──────────────────┼─────────────────────────┤ │ flip_prob │ 0.5 │ ├──────────────────┼─────────────────────────┤ │ degrees │ 10.0 │ ├──────────────────┼─────────────────────────┤ │ translate │ 0.1 │ ├──────────────────┼─────────────────────────┤ │ mosaic_scale │ (0.5, 1.5) │ ├──────────────────┼─────────────────────────┤ │ mixup_scale │ (0.5, 1.5) │ ├──────────────────┼─────────────────────────┤ │ shear │ 2.0 │ ├──────────────────┼─────────────────────────┤ │ perspective │ 0.0 │ ├──────────────────┼─────────────────────────┤ │ enable_mixup │ False │ ├──────────────────┼─────────────────────────┤ │ warmup_epochs │ 5 │ ├──────────────────┼─────────────────────────┤ │ max_epoch │ 35 │ ├──────────────────┼─────────────────────────┤ │ warmup_lr │ 0 │ ├──────────────────┼─────────────────────────┤ │ basic_lr_per_img │ 0.00025 │ ├──────────────────┼─────────────────────────┤ │ scheduler │ 'yoloxwarmcos' │ ├──────────────────┼─────────────────────────┤ │ no_aug_epochs │ 15 │ ├──────────────────┼─────────────────────────┤ │ min_lr_ratio │ 0.05 │ ├──────────────────┼─────────────────────────┤ │ ema │ True │ ├──────────────────┼─────────────────────────┤ │ weight_decay │ 0.0005 │ ├──────────────────┼─────────────────────────┤ │ momentum │ 0.9 │ ├──────────────────┼─────────────────────────┤ │ exp_name │ 'yolox_tiny_fish' │ ├──────────────────┼─────────────────────────┤ │ test_size │ (416, 416) │ ├──────────────────┼─────────────────────────┤ │ test_conf │ 0.01 │ ├──────────────────┼─────────────────────────┤ │ nmsthre │ 0.65 │ ├──────────────────┼─────────────────────────┤ │ input_scale │ (416, 416) │ ├──────────────────┼─────────────────────────┤ │ random_size │ (10, 20) │ ╘══════════════════╧═════════════════════════╛ 2021-09-21 17:29:46 | ERROR | yolox.core.launch:98 - An error has been caught in function 'launch', process 'MainProcess' (13288), thread 'MainThread' (2900): Traceback (most recent call last): File "yolox_tools\train.py", line 132, in args=(exp, args), │ └ Namespace(batch_size=8, cache=False, ckpt='weights/yolox_tiny.pth', devices=1, dist_backend='nccl', dist_url=None, exp_file='... └ ╒══════════════════╤═════════════════════════╕ │ keys │ values │ ╞══════════════════╪═══════════... > File "c:\users\winds\downloads\genshin_auto_fish-master\yolox\core\launch.py", line 98, in launch main_func(*args) │ └ (╒══════════════════╤═════════════════════════╕ │ │ keys │ values │ │ ╞══════════════════╪══════════... └ <function main at 0x0000021309F46BF8> File "yolox_tools\train.py", line 110, in main trainer.train() │ └ <function Trainer.train at 0x00000213092D7950> └ <yolox.core.trainer.Trainer object at 0x0000021309F5C1D0> File "c:\users\winds\downloads\genshin_auto_fish-master\yolox\core\trainer.py", line 70, in train self.before_train() │ └ <function Trainer.before_train at 0x0000021309F1D158> └ <yolox.core.trainer.Trainer object at 0x0000021309F5C1D0> File "c:\users\winds\downloads\genshin_auto_fish-master\yolox\core\trainer.py", line 130, in before_train torch.cuda.set_device(self.local_rank) │ │ │ │ └ 0 │ │ │ └ <yolox.core.trainer.Trainer object at 0x0000021309F5C1D0> │ │ └ <function set_device at 0x00000213072C4598> │ └ <module 'torch.cuda' from 'C:\Users\winds\.conda\envs\ysfish\lib\site-packages\torch\cuda\init.py'> └ <module 'torch' from 'C:\Users\winds\.conda\envs\ysfish\lib\site-packages\torch\init.py'> File "C:\Users\winds.conda\envs\ysfish\lib\site-packages\torch\cuda_init_.py", line 263, in set_device torch._C._cuda_setDevice(device) │ │ └ 0 │ └ <module 'torch._C' from 'C:\Users\winds\.conda\envs\ysfish\lib\site-packages\torch\_C.cp36-win_amd64.pyd'> └ <module 'torch' from 'C:\Users\winds\.conda\envs\ysfish\lib\site-packages\torch\init.py'> AttributeError: module 'torch._C' has no attribute '_cuda_setDevice'

屏幕截图(14).png
屏幕截图(15).png
屏幕截图(16).png

Microsoft Visual C++ 14.0 or greater is required.

C:\Users\Anaconda3\envs\ysfish\lib\site-packages\torch\utils\cpp_extension.py:274: UserWarning: Error checking compiler version for cl: [WinError 2] 系统找不到指定的文件。
warnings.warn('Error checking compiler version for {}: {}'.format(compiler, error))
building 'yolox._C' extension
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/

是不是还得装C++什么的。。非程序员头大了,大佬能搞个一键安装吗?谢谢大佬

yolox训练报错

File "yolox_tools/train.py", line 115, in
exp = get_exp(args.exp_file, args.name)
File "c:\users\a\downloads\genshin_auto_fish-master\genshin_auto_fish-master\yolox\exp\build.py", line 51, in get_exp
return get_exp_by_file(exp_file)
File "c:\users\a\downloads\genshin_auto_fish-master\genshin_auto_fish-master\yolox\exp\build.py", line 16, in get_exp_by_file
raise ImportError("{} doesn't contains class named 'Exp'".format(exp_file))
ImportError: yolox/exp/yolox_tiny_fish.py doesn't contains class named 'Exp'

训练集的onedrive分享链接挂了

https://1drv.ms/u/s!Agabh9imkP8qhHkZYzKsi_OQ4pfj?e=V2VApo

此项可能已被删除或过期,或者你没有查看权限。有关详细信息,请与此项的所有者联系。

运行成功之后如何触发

(ysfish) E:\code\python\genshin_auto_fish>python fishing.py image -f yolox/exp/yolox_tiny_fish.py -c weights/best_tiny3.pth --conf 0.25 --nms 0.45 --tsize 640 --device cpu 2021-09-21 11:52:40.103 | INFO | __main__:main:91 - Args: Namespace(ckpt='weights/best_tiny3.pth', conf=0.25, demo='image', device='cpu', exp_file='yolox/exp/yolox_tiny_fish.py', experiment_name='yolox_tiny_fish', fp16=False, fuse=False, legacy=False, model_dir='./weights/fish_genshin_net.pth', n_actions=2, n_states=3, name=None, nms=0.45, path='./assets/dog.jpg', step_tick=12, trt=False, tsize=640) 2021-09-21 11:52:40.217 | INFO | __main__:main:101 - Model Summary: Params: 5.03M, Gflops: 15.15 2021-09-21 11:52:40.220 | INFO | __main__:main:114 - loading checkpoint 2021-09-21 11:52:40.286 | INFO | __main__:main:118 - loaded checkpoint done.
image

按照教程跑起来之后,无效

原神鱼群数据集沒有了

此项可能不存在或不再可用
此项可能已被删除或过期,或者你没有查看权限。有关详细信息,请与此项的所有者联系。

执行python setup.py develop时报错

(ysfish) C:\Users\winds\Downloads\genshin_auto_fish-master>python setup.py develop Traceback (most recent call last): File "setup.py", line 50, in with open("README.md", "r", encoding="utf-8") as f: PermissionError: [Errno 13] Permission denied: 'README.md'

屏幕截图(13).png

使用python fishing.py image -f yolox/exp/yolox_tiny_fish.py -c weights/best_tiny3.pth --conf 0.25 --nms 0.45 --tsize 640 --device cpu后提示,无法运行

Traceback (most recent call last):
File "fishing.py", line 19, in
from fisher.predictor import *
File "C:\Users\hp\Desktop\genshin_auto_fish-master\fisher\predictor.py", line 8, in
from yolox.data.data_augment import ValTransform
File "C:\Users\hp\Desktop\genshin_auto_fish-master\yolox\data_init_.py", line 8, in
from .datasets import *
File "C:\Users\hp\Desktop\genshin_auto_fish-master\yolox\data\datasets_init_.py", line 5, in
from .coco import COCODataset
File "C:\Users\hp\Desktop\genshin_auto_fish-master\yolox\data\datasets\coco.py", line 10, in
from pycocotools.coco import COCO
ModuleNotFoundError: No module named 'pycocotools'

pip安装cuda失败

ERROR: You must give at least one requirement to install (see "pip help install")
请问一定要安装和本机同一版本的cuda吗?
还有我在执行YOLOX的时候显示No module named 'torch'我认为是我pyHook的问题,但我重新安装还是无法解决

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.