X-PLUG / MobileAgent

Mobile-Agent: The Powerful Mobile Device Operation Assistant Family
https://arxiv.org/abs/2406.01014
MIT License
2.76k stars 256 forks source link

找不到Screenshot目录下的screenshot.jpg文件。 #22

Open lxc00215 opened 3 months ago

lxc00215 commented 3 months ago

2024-06-07 11:28:54,386 - modelscope - INFO - loading model done ╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮ │ D:\github-app\MobileAgent\Mobile-Agent-v2\run.py:286 in │ │ │ │ 283 │ iter += 1 │ │ 284 │ if iter == 1: │ │ 285 │ │ screenshot_file = "./screenshot/screenshot.jpg" │ │ ❱ 286 │ │ perception_infos, width, height = get_perception_infos(adb_path, screenshot_file │ │ 287 │ │ shutil.rmtree(temp_file) │ │ 288 │ │ os.mkdir(temp_file) │ │ 289 │ │ │ │ D:\github-app\MobileAgent\Mobile-Agent-v2\run.py:175 in get_perception_infos │ │ │ │ 172 │ │ 173 │ │ 174 def get_perception_infos(adb_path, screenshot_file): │ │ ❱ 175 │ get_screenshot(adb_path) │ │ 176 │ │ │ 177 │ width, height = Image.open(screenshot_file).size │ │ 178 │ │ │ │ D:\github-app\MobileAgent\Mobile-Agent-v2\MobileAgent\controller.py:49 in get_screenshot │ │ │ │ 46 │ subprocess.run(command, capture_output=True, text=True, shell=True) │ │ 47 │ image_path = "./screenshot/screenshot.png" │ │ 48 │ save_path = "./screenshot/screenshot.jpg" │ │ ❱ 49 │ image = Image.open(image_path) │ │ 50 │ image.convert("RGB").save(save_path, "JPEG") │ │ 51 │ os.remove(image_path) │ │ 52 │ │ │ │ C:\Users\lxc\AppData\Local\Programs\Python\Python310\lib\site-packages\PIL\Image.py:3277 in open │ │ │ │ 3274 │ │ filename = os.path.realpath(os.fspath(fp)) │ │ 3275 │ │ │ 3276 │ if filename: │ │ ❱ 3277 │ │ fp = builtins.open(filename, "rb") │ │ 3278 │ │ exclusive_fp = True │ │ 3279 │ │ │ 3280 │ try: │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ FileNotFoundError: [Errno 2] No such file or directory: 'D:\github-app\MobileAgent\Mobile-Agent-v2\screenshot\screenshot.png'

我看了下代码,确实有去找这个文件的这个行为。但是我不确定这个行为是什么意思?我猜测是在gpt-4o工作之前需要拿到手机屏幕的一张图片,然后项目才能执行下去,是这样吗?

junyangwang0410 commented 3 months ago

2024-06-07 11:28:54,386 - modelscope - INFO - loading model done ╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮ │ D:\github-app\MobileAgent\Mobile-Agent-v2\run.py:286 in │ │ │ │ 283 │ iter += 1 │ │ 284 │ if iter == 1: │ │ 285 │ │ screenshot_file = "./screenshot/screenshot.jpg" │ │ ❱ 286 │ │ perception_infos, width, height = get_perception_infos(adb_path, screenshot_file │ │ 287 │ │ shutil.rmtree(temp_file) │ │ 288 │ │ os.mkdir(temp_file) │ │ 289 │ │ │ │ D:\github-app\MobileAgent\Mobile-Agent-v2\run.py:175 in get_perception_infos │ │ │ │ 172 │ │ 173 │ │ 174 def get_perception_infos(adb_path, screenshot_file): │ │ ❱ 175 │ get_screenshot(adb_path) │ │ 176 │ │ │ 177 │ width, height = Image.open(screenshot_file).size │ │ 178 │ │ │ │ D:\github-app\MobileAgent\Mobile-Agent-v2\MobileAgent\controller.py:49 in get_screenshot │ │ │ │ 46 │ subprocess.run(command, capture_output=True, text=True, shell=True) │ │ 47 │ image_path = "./screenshot/screenshot.png" │ │ 48 │ save_path = "./screenshot/screenshot.jpg" │ │ ❱ 49 │ image = Image.open(image_path) │ │ 50 │ image.convert("RGB").save(save_path, "JPEG") │ │ 51 │ os.remove(image_path) │ │ 52 │ │ │ │ C:\Users\lxc\AppData\Local\Programs\Python\Python310\lib\site-packages\PIL\Image.py:3277 in open │ │ │ │ 3274 │ │ filename = os.path.realpath(os.fspath(fp)) │ │ 3275 │ │ │ 3276 │ if filename: │ │ ❱ 3277 │ │ fp = builtins.open(filename, "rb") │ │ 3278 │ │ exclusive_fp = True │ │ 3279 │ │ │ 3280 │ try: │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ FileNotFoundError: [Errno 2] No such file or directory: 'D:\github-app\MobileAgent\Mobile-Agent-v2\screenshot\screenshot.png'

我看了下代码,确实有去找这个文件的这个行为。但是我不确定这个行为是什么意思?我猜测是在gpt-4o工作之前需要拿到手机屏幕的一张图片,然后项目才能执行下去,是这样吗?

你好。没有找到截图是因为你的ADB截屏没有执行成功。请确保你的手机在开发者选项中打开“USB调试”,并且USB选项选择为“传输文件”,随后在命令行中输入“adb_path devices”来检查你的设备是否在可调试列表中。在运行之前,请确保ADB的功能是正常的。

lxc00215 commented 3 months ago

image 还是有一点点问题...

junyangwang0410 commented 3 months ago

image 还是有一点点问题...

请问手机上是否有截屏,PC端的随程序运行时创建的screenshot路径是否存在?

lxc00215 commented 3 months ago

image woana我按照它提示的路径放置了一张屏幕截图,它可以执行。并且执行后的screenshot目录如上图所示。然后它又报告了上述错误。 项目执行时手机上没有出现截屏。但是当我自己使用adb命令截屏时,是可以看到截屏的,也可以执行命令从手机端拉到电脑端。 pc端有screenshot目录,但没有对应文件

junyangwang0410 commented 3 months ago

image woana我按照它提示的路径放置了一张屏幕截图,它可以执行。并且执行后的screenshot目录如上图所示。然后它又报告了上述错误。 项目执行时手机上没有出现截屏。但是当我自己使用adb命令截屏时,是可以看到截屏的,也可以执行命令从手机端拉到电脑端。 pc端有screenshot目录,但没有对应文件

问题大概出现在了ADB截屏指令没有成功执行,你可以单独用ADB去做截屏操作,然后看看什么命令和参数能够成功。之后你把成功的参数覆盖到MobileAgent/contorllor.py中的get_screenshot()里面。

lxc00215 commented 3 months ago

谢谢您,我解决了我的问题。我将所有的adb_path 切换成了adb(我以前配置过环境变量),解决了这个问题。另外项目执行的很慢,这正常吗?3分种大概执行了5次操作。

junyangwang0410 commented 3 months ago

谢谢您,我解决了我的问题。我将所有的adb_path 切换成了adb(我以前配置过环境变量),解决了这个问题。另外项目执行的很慢,这正常吗?3分种大概执行了5次操作。

十分抱歉,由于操作的pipeline较长,目前速度很难达到实时操作 可以尝试下面的操作来提速:

  1. 关闭反思agent和memory
  2. 选择直连的API
  3. caption方法选用api方式调用qwen-vl-plus