linyiLYi / street-fighter-ai

This is an AI agent for Street Fighter II Champion Edition.
Apache License 2.0
6.34k stars 1.36k forks source link

完美的跑起来了,up主牛逼;不懂得 可以问我 #59

Open fanloveoupao opened 1 year ago

fanloveoupao commented 1 year ago

微信gknb_666

fxgeoffrey commented 1 year ago

mac 能跑吗

fr0zenrain commented 1 year ago

mac 能跑吗

可以。

hvacking commented 1 year ago

/Users/lan/opt/anaconda3/envs/StreetFighterAI/lib/python3.8/site-packages/retro/,下面怎么没看到data文件夹?

IAAI-star commented 1 year ago

我在运行python test.py时,遇到以下报错走不下去了,问了chatGPT,说是代码与模型不符,让我检查模型啥的,不懂,请大神帮忙解答,万分感谢: (StreetFighterAI) C:\Users\jiaxin\StreetFighterAI\street-fighter-ai-master\main>python test.py Wrapping the env with a Monitor wrapper Wrapping the env in a DummyVecEnv. Wrapping the env in a VecTransposeImage. Traceback (most recent call last): File "test.py", line 53, in model = PPO.load(os.path.join(MODEL_DIR, MODEL_NAME), env=env) File "C:\Users\jiaxin.conda\envs\StreetFighterAI\lib\site-packages\stable_baselines3\common\base_class.py", line 641, in load model.set_parameters(params, exact_match=True, device=device) File "C:\Users\jiaxin.conda\envs\StreetFighterAI\lib\site-packages\stable_baselines3\common\base_class.py", line 574, in set_parameters attr.load_state_dict(params[name], strict=exact_match) File "C:\Users\jiaxin.conda\envs\StreetFighterAI\lib\site-packages\torch\nn\modules\module.py", line 2041, in load_state_dict raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format( RuntimeError: Error(s) in loading state_dict for ActorCriticCnnPolicy: Unexpected key(s) in state_dict: "pi_features_extractor.cnn.0.weight", "pi_features_extractor.cnn.0.bias", "pi_features_extractor.cnn.2.weight", "pi_features_extractor.cnn.2.bias", "pi_features_extractor.cnn.4.weight", "pi_features_extractor.cnn.4.bias", "pi_features_extractor.linear.0.weight", "pi_features_extractor.linear.0.bias", "vf_features_extractor.cnn.0.weight", "vf_features_extractor.cnn.0.bias", "vf_features_extractor.cnn.2.weight", "vf_features_extractor.cnn.2.bias", "vf_features_extractor.cnn.4.weight", "vf_features_extractor.cnn.4.bias", "vf_features_extractor.linear.0.weight", "vf_features_extractor.linear.0.bias".

yoyosaygood commented 1 year ago

我安装gym指定版本装不了 然后装了最新版本 然后呢 就跑不起来test.py 安装gym的报错如下: (StreetFighterAI) E:\LJM_D\street-fighter-ai-master\main>pip install gym==0.21.0 Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Collecting gym==0.21.0 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/4b/48/920cea66177b865663fde5a9390a59de0ef3b642ad98106ac1d8717d7005/gym-0.21.0.tar.gz (1.5 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.5/1.5 MB 5.5 MB/s eta 0:00:00 Preparing metadata (setup.py) ... error error: subprocess-exited-with-error

× python setup.py egg_info did not run successfully. │ exit code: 1 ╰─> [1 lines of output] error in gym setup command: 'extras_require' must be a dictionary whose values are strings or lists of strings containing valid project/version requirement specifiers. [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed

× Encountered error while generating package metadata. ╰─> See above for output.

note: This is an issue with the package mentioned above, not pip. hint: See above for details.

然后用最新gym跑test的报错如下: (StreetFighterAI) E:\LJM_D\street-fighter-ai-master\main>python test.py Traceback (most recent call last): File "test.py", line 49, in env = make_env(game, state="Champion.Level12.RyuVsBison")() File "test.py", line 38, in _init env = retro.make( File "C:\Users\PC\miniconda3\envs\StreetFighterAI\lib\site-packages\retro__init__.py", line 55, in make return RetroEnv(game, state, inttype=inttype, kwargs) File "C:\Users\PC\miniconda3\envs\StreetFighterAI\lib\site-packages\retro\retro_env.py", line 131, in init self.seed() File "C:\Users\PC\miniconda3\envs\StreetFighterAI\lib\site-packages\retro\retro_env.py", line 214, in seed seed2 = seeding.hash_seed(seed1 + 1) % 231 AttributeError: module 'gym.utils.seeding' has no attribute 'hash_seed' 有大神指导下吗

haochenuw commented 1 year ago

@yoyosaygood 可以把requirement.txt条件放松试试

gym>=0.22.0, <=0.25.2
gym-retro==0.8.0
stable-baselines3>=1.7.0
tensorboard==2.12.1
IAAI-star commented 1 year ago

谢谢谢谢,已经解决了,非常感谢

On Wed, Jun 28, 2023 at 7:26 AM Hao Chen @.***> wrote:

@yoyosaygood https://github.com/yoyosaygood 可以把requirement.txt条件放松试试

gym>=0.22.0, <=0.25.2 gym-retro==0.8.0 stable-baselines3>=1.7.0 tensorboard==2.12.1

— Reply to this email directly, view it on GitHub https://github.com/linyiLYi/street-fighter-ai/issues/59#issuecomment-1610356433, or unsubscribe https://github.com/notifications/unsubscribe-auth/A7PPKWQP2HJ5XV42YUJO3QTXNNT2PANCNFSM6AAAAAAYHOOQ2Y . You are receiving this because you commented.Message ID: @.***>

skyrain888 commented 1 year ago

请教下如何跑通的

skyrain888 commented 1 year ago

你在m1下跑起来了?

skyrain888 commented 1 year ago

@fr0zenrain 你是mac m1吗?

761046683 commented 1 year ago

我运行test.py也出问题了,不过好像跟他们的不太一样。 C:\Users\21249.conda\envs\StreetFighterAI\lib\site-packages\stable_baselines3\common\save_util.py:166: UserWarning: Could not deserialize object observation_space. Consider using custom_objects argument to replace this object. Exception: __randomstate_ctor() takes from 0 to 1 positional arguments but 2 were given warnings.warn( Traceback (most recent call last): File "test.py", line 53, in model = PPO.load(os.path.join(MODEL_DIR, MODEL_NAME), env=env) File "C:\Users\21249.conda\envs\StreetFighterAI\lib\site-packages\stable_baselines3\common\base_class.py", line 706, in load raise KeyError("The observation_space and action_space were not given, can't verify new environments") KeyError: "The observation_space and action_space were not given, can't verify new environments" 问了gpt说是:“当您在使用 Stable Baselines3 库中的 PPO 算法尝试加载已训练好的模型时,出现了一些问题。错误信息提示在反序列化模型的 observation_space 时遇到了问题,导致加载模型时出现异常。同时,它还提到了一个警告,建议您使用 custom_objects 参数来替换这个对象。” 但是不太明白怎么该,它给的方法也都不管用,有没有大佬知道咋回事?

JizhiXiang commented 1 year ago

@761046683 如果KeyError: "The observation_space and action_space were not given, can't verify new environments"报错的话, 将test.py的52~53行换成如下即可解决:

# 参考https://github.com/linyiLYi/street-fighter-ai/issues/16#issuecomment-1515463967
# if not RANDOM_ACTION:
#     # 如果是你自己训练的模型    
#     model = PPO.load(os.path.join(MODEL_DIR, MODEL_NAME), env=env)
if not RANDOM_ACTION:
    # 如果你使用的是linyiLYi提供的模型
    keys = ['high', 'low', 'bounded_above', 'bounded_below']
    setattr(env.observation_space, '_shape', (3,100,128))
    for k in keys:
        new_attr = getattr(env.observation_space, k).reshape(3,100,128)
        setattr(env.observation_space, k, new_attr)
    model = PPO.load(os.path.join(MODEL_DIR, MODEL_NAME), env=env,
                custom_objects = {'observation_space': env.observation_space, 'action_space': env.action_space})
RidenShogunei commented 1 year ago

微信gknb_666 Traceback (most recent call last): File "C:\Users\chenj\Desktop\play\street-fighter-ai-master\street-fighter-ai-master\main\test.py", line 79, in obs, reward, done, info = env.step(action) File "C:\Users\chenj\Desktop\play\street-fighter-ai-master\street-fighter-ai-master\main\street_fighter_custom_wrapper.py", line 71, in step self.env.render() File "C:\Users\chenj.conda\envs\StreetFighterAI\lib\site-packages\retro\retro_env.py", line 228, in render from gym.envs.classic_control.rendering import SimpleImageViewer ModuleNotFoundError: No module named 'gym.envs.classic_control.rendering'大佬,请问这个问题怎么解决

dybtom commented 1 year ago

微信gknb_666回溯(最近一次调用):文件“C:\Users\chenj\Desktop\play\street-fighter-ai-master\street-fighter-ai-master\main\test.py”,第79行,在obs中,奖励,完成,info = env.step(action) 文件“C:\Users\chenj\Desktop\play\street-fighter-ai-master\street-fighter-ai-master\main\street_fighter_custom_wrapper.py”,第71行,在步骤self.env.render()文件 “C:\Users\chenj.conda\envs\StreetFighterAI\lib\site-packages\retro\retro_env.py”,第 228 行,从 gym.envs.classic_control.rendering 导入 SimpleImageViewer 渲染 ModuleNotFoundError: 没有名为 'gym.envs.classic_control.rendering'的大佬,请问这个问题怎么解决

还是要安装gym0.21,解决gym 0.21安装问题的方法。有时候新版本的setuptools或pip与旧的包存在不兼容性问题,pip install setuptools==65.5.0 pip==21 更新pip时,直接使用pip命令可能会出现问题。你应该按照错误消息中给出的建议,使用Python的-m选项来进行pip更新 python.exe -m pip install pip==21 -i https://pypi.tuna.tsinghua.edu.cn/simple 安装完成之后再下面用的清华源 pip install gym==0.21 -i https://pypi.tuna.tsinghua.edu.cn/simple

RidenShogunei commented 1 year ago

非常感谢

在 2023-10-20 18:36:23,"dybtom" @.***> 写道:

微信gknb_666回溯(最近一次调用):文件“C:\Users\chenj\Desktop\play\street-fighter-ai-master\street-fighter-ai-master\main\test.py”,第79行,在obs中,奖励,完成,info = env.step(action) 文件“C:\Users\chenj\Desktop\play\street-fighter-ai-master\street-fighter-ai-master\main\street_fighter_custom_wrapper.py”,第71行,在步骤self.env.render()文件 “C:\Users\chenj.conda\envs\StreetFighterAI\lib\site-packages\retro\retro_env.py”,第 228 行,从 gym.envs.classic_control.rendering 导入 SimpleImageViewer 渲染 ModuleNotFoundError: 没有名为 'gym.envs.classic_control.rendering'的大佬,请问这个问题怎么解决

还是要安装gym0.21,解决gym 0.21安装问题的方法。有时候新版本的setuptools或pip与旧的包存在不兼容性问题,pip install setuptools==65.5.0 pip==21 更新pip时,直接使用pip命令可能会出现问题。你应该按照错误消息中给出的建议,使用Python的-m选项来进行pip更新 python.exe -m pip install pip==21 -i https://pypi.tuna.tsinghua.edu.cn/simple 安装完成之后再下面用的清华源 pip install gym==0.21 -i https://pypi.tuna.tsinghua.edu.cn/simple

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

Jianglai543 commented 9 months ago

微信gknb_666回溯(最近一次调用):文件“C:\Users\chenj\Desktop\play\street-fighter-ai-master\street-fighter-ai-master\main\test.py”,第79行,在obs中,奖励,完成,info = env.step(action) 文件“C:\Users\chenj\Desktop\play\street-fighter-ai-master\street-fighter-ai-master\main\street_fighter_custom_wrapper.py”,第71行,在步骤self.env.render()文件 “C:\Users\chenj.conda\envs\StreetFighterAI\lib\site-packages\retro\retro_env.py”,第 228 行,从 gym.envs.classic_control.rendering 导入 SimpleImageViewer 渲染 ModuleNotFoundError: 没有名为 'gym.envs.classic_control.rendering'的大佬,请问这个问题怎么解决

还是要安装gym0.21,解决gym 0.21安装问题的方法。有时候新版本的setuptools或pip与旧的包存在不兼容性问题,pip install setuptools==65.5.0 pip==21 更新pip时,直接使用pip命令可能会出现问题。你应该按照错误消息中给出的建议,使用Python的-m选项来进行pip更新 python.exe -m pip install pip==21 -i https://pypi.tuna.tsinghua.edu.cn/simple 安装完成之后再下面用的清华源 pip install gym==0.21 -i https://pypi.tuna.tsinghua.edu.cn/simple

怎么办,我pip install setuptools==65.5.0 pip==21之后,系统让我C:\Users\future\pycharm_progect\pythonProject.venv\Scripts\python.exe -m pip install setuptools==65.5.0 pip==21,然后我的pip就不好用了,报错 from pip._vendor.six.moves import urllib, map, filter ModuleNotFoundError: No module named 'pip._vendor.six.moves' 求助,现在pip整个不好用了