From ba8ae104cf3315861fa53c8146c2981c80679028 Mon Sep 17 00:00:00 2001 From: tsuky_chen <3107760494@qq.com> Date: Wed, 17 Jan 2024 18:00:20 +0800 Subject: [PATCH] update impress eval examples --- desktop_env/evaluators/metrics/__init__.py | 1 + desktop_env/evaluators/metrics/impress.py | 19 ++++++++ .../3b27600c-3668-4abd-8f84-7bcdebbccbdb.json | 40 ++++++++++++++-- .../ce88f674-ab7a-43da-9201-468d38539e4a.json | 35 ++++++++++++-- .../f0a334af-f91b-4c03-b578-aac9bec2b543.json | 46 +++++++++++++++++-- 5 files changed, 126 insertions(+), 15 deletions(-) diff --git a/desktop_env/evaluators/metrics/__init__.py b/desktop_env/evaluators/metrics/__init__.py index 59ebab2..fc46434 100644 --- a/desktop_env/evaluators/metrics/__init__.py +++ b/desktop_env/evaluators/metrics/__init__.py @@ -15,3 +15,4 @@ from .general import check_csv, check_accessibility_tree, check_list, run_sqlite from .thunderbird import check_thunderbird_prefs, check_thunderbird_filter from .vscode import compare_text_file, compare_config, compare_answer, is_extension_installed from .impress import check_slide_numbers_color, compare_pptx_files, check_for_two_lines, check_for_audio, check_formula_shape, check_file_exists +from .impress import check_slide_orientation_Portrait, contains_mp4_video \ No newline at end of file diff --git a/desktop_env/evaluators/metrics/impress.py b/desktop_env/evaluators/metrics/impress.py index 719ae56..749bc0e 100644 --- a/desktop_env/evaluators/metrics/impress.py +++ b/desktop_env/evaluators/metrics/impress.py @@ -94,6 +94,25 @@ def check_formula_shape(prs): return 1 return 0 +def check_slide_orientation_Portrait(pptx_path): + presentation = Presentation(pptx_path) + + slide_height = presentation.slide_height + slide_width = presentation.slide_width + + if slide_width < slide_height: + return 1 + return 0 + +def contains_mp4_video(pptx_path): + prs = Presentation(pptx_path) + for slide in prs.slides: + for shape in slide.shapes: + if shape.shape_type == 16: + if shape.media_type == 3: + return 1 + return 0 + if __name__ == "__main__": path1 = "../../任务数据/LibreOffice Impress/Change_Color_Slide_Number_gold_textbox.pptx" presentation = Presentation(path1) diff --git a/evaluation_examples/examples/libreoffice_impress/3b27600c-3668-4abd-8f84-7bcdebbccbdb.json b/evaluation_examples/examples/libreoffice_impress/3b27600c-3668-4abd-8f84-7bcdebbccbdb.json index 784913c..615cabc 100644 --- a/evaluation_examples/examples/libreoffice_impress/3b27600c-3668-4abd-8f84-7bcdebbccbdb.json +++ b/evaluation_examples/examples/libreoffice_impress/3b27600c-3668-4abd-8f84-7bcdebbccbdb.json @@ -1,12 +1,42 @@ { "id": "3b27600c-3668-4abd-8f84-7bcdebbccbdb", "snapshot": "libreoffice_impress", - "instruction": "Could you help me change the background color to blue 2 and apply it to all my slides.", + "instruction": "Please make the background blue on all my slides.", "source": "https://www.libreofficehelp.com/change-slide-background-impress/#All_Slides", - "config": [], + "config": [ + { + "type": "download", + "parameters": { + "files": [ + { + "url": "https://drive.usercontent.google.com/download?id=1aHMJzk2G8B_EqDlTAZLEiJ4h-ZsgA9UE&export=download&authuser=0&confirm=t&uuid=196a082d-5f08-4b3e-a64f-c021351f9cd8&at=APZUnTUXH4gvLvElvm9TtFhUJlIn:1705481007789", + "path": "Desktop/lec17-gui-events.pptx" + } + ] + } + }, + { + "type": "open", + "parameters": { + "path": "Desktop/lec17-gui-events.pptx" + } + } + ], "trajectory": "trajectories/", "related_apps": [ - "" + "libreoffice_impress" ], - "evaluator": "evaluation_dir" -} + "evaluator": { + "func": "compare_pptx_files", + "expected": { + "type": "cloud_file", + "path": "https://drive.usercontent.google.com/download?id=1LU-wnmIqMQgwkdAUFBLE1wNkH4gSl3IR&export=download&authuser=0&confirm=t&uuid=74520405-4028-4fbe-bab8-d56dc82ffb6c&at=APZUnTU0dz5ZE5CcQry8IeY5_s1J:1705481009686", + "dest": "lec17-gui-events_Gold.docx" + }, + "result": { + "type": "vm_file", + "path": "Desktop/lec17-gui-events.pptx", + "dest": "lec17-gui-events.pptx" + } + } +} \ No newline at end of file diff --git a/evaluation_examples/examples/libreoffice_impress/ce88f674-ab7a-43da-9201-468d38539e4a.json b/evaluation_examples/examples/libreoffice_impress/ce88f674-ab7a-43da-9201-468d38539e4a.json index 1149fbb..7f3b272 100644 --- a/evaluation_examples/examples/libreoffice_impress/ce88f674-ab7a-43da-9201-468d38539e4a.json +++ b/evaluation_examples/examples/libreoffice_impress/ce88f674-ab7a-43da-9201-468d38539e4a.json @@ -1,12 +1,37 @@ { "id": "ce88f674-ab7a-43da-9201-468d38539e4a", "snapshot": "libreoffice_impress", - "instruction": "Could you help me change my slides to portrait (from landscape)?", + "instruction": "Please set my slides upright instead of sideways.", "source": "https://justclickhere.co.uk/resources/change-slides-in-impress-to-portrait/", - "config": [], + "config": [ + { + "type": "download", + "parameters": { + "files": [ + { + "url": "https://drive.usercontent.google.com/download?id=1LErTnC_w_YPQVo84QK5sifww9xZ-Cq0X&export=download&authuser=0&confirm=t&uuid=81ff0aaf-9c2e-4342-b7ce-36e65dd2218e&at=APZUnTUmQKCTp2HUP0dOqYqD10G3:1705479016156", + "path": "Desktop/AM_Last_Page_Template.pptx" + } + ] + } + }, + { + "type": "open", + "parameters": { + "path": "Desktop/AM_Last_Page_Template.pptx" + } + } + ], "trajectory": "trajectories/", "related_apps": [ - "" + "libreoffice_impress" ], - "evaluator": "evaluation_dir" -} + "evaluator": { + "func": "check_slide_orientation_Portrait", + "result": { + "type": "vm_file", + "path": "Desktop/AM_Last_Page_Template.pptx", + "dest": "AM_Last_Page_Template.pptx" + } + } +} \ No newline at end of file diff --git a/evaluation_examples/examples/libreoffice_impress/f0a334af-f91b-4c03-b578-aac9bec2b543.json b/evaluation_examples/examples/libreoffice_impress/f0a334af-f91b-4c03-b578-aac9bec2b543.json index 86342e6..3411aa8 100644 --- a/evaluation_examples/examples/libreoffice_impress/f0a334af-f91b-4c03-b578-aac9bec2b543.json +++ b/evaluation_examples/examples/libreoffice_impress/f0a334af-f91b-4c03-b578-aac9bec2b543.json @@ -1,12 +1,48 @@ { "id": "f0a334af-f91b-4c03-b578-aac9bec2b543", "snapshot": "libreoffice_impress", - "instruction": "Help me insert the video at VIDEO_PATH in the current slide.", + "instruction": "Insert the video Movie_countdown_2.mov on the Desktop into my current slide, please.", "source": "https://www.libreofficehelp.com/insert-video-impress-presentation/#Inserting_a_Video_in_Impress", - "config": [], + "config": [ + { + "type": "download", + "parameters": { + "files": [ + { + "url": "https://drive.usercontent.google.com/download?id=1vvRkrxOK_sFPX9PLFniFqrdNEZ2pQnPP&export=download&authuser=0&confirm=t&uuid=71964a12-2d0a-4c71-9375-2f9ec15de1ad&at=APZUnTX_B-T2GeZPS7ZmchMQ6E7m:1705481285721", + "path": "Desktop/Movie_activities_TURKEY.pptx" + } + ] + } + }, + { + "type": "download", + "parameters": { + "files": [ + { + "url": "https://drive.usercontent.google.com/download?id=1S4lACtBb40Ff0DEjB2bG2tzr2qWwQLGd&export=download&authuser=0&confirm=t&uuid=a28c123e-5371-4e17-82c2-ed7b1f05b728&at=APZUnTW_rlUPV6mM4RjS0R6dMSv4:1705469776913", + "path": "Desktop/Movie_countdown_2.mov" + } + ] + } + }, + { + "type": "open", + "parameters": { + "path": "Desktop/Movie_activities_TURKEY.pptx" + } + } + ], "trajectory": "trajectories/", "related_apps": [ - "" + "libreoffice_impress" ], - "evaluator": "evaluation_dir" -} + "evaluator": { + "func": "contains_mp4_video", + "result": { + "type": "vm_file", + "path": "Desktop/Movie_activities_TURKEY.pptx", + "dest": "Movie_activities_TURKEY.pptx" + } + } +} \ No newline at end of file