Skip to content

Commit

Permalink
Changes to support benchmarking
Browse files Browse the repository at this point in the history
  • Loading branch information
humpydonkey committed Jun 17, 2024
1 parent 482ccf4 commit a72084c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
3 changes: 2 additions & 1 deletion examples/mask_app/app.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import cv2
import streamlit as st
from PIL import Image
from streamlit_drawable_canvas import st_canvas

import streamlit as st

st.title("Image Segmentation Mask App")

uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "png"])
Expand Down
6 changes: 3 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions vision_agent/agent/vision_agent_prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ def find_text(image_path: str, text: str) -> str:
8. DO NOT use try except block to handle the error, let the error be raised if the code is incorrect.
9. DO NOT import the testing function as it will available in the testing environment.
10. Print the output of the function that is being tested.
11. Use the output of the function that is being tested as the return value of the testing function.
12. Run the testing function in the end and don't assign a variable to its output.
"""


Expand Down
16 changes: 16 additions & 0 deletions vision_agent/utils/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import atexit
import base64
import copy
import json
import logging
import os
import platform
Expand Down Expand Up @@ -309,6 +310,21 @@ def success(self) -> bool:
"""
return self.error is None

def get_main_result(self) -> Optional[Result]:
"""
Get the main result of the execution.
An execution may have multiple results, e.g. intermediate outputs. The main result is the last output of the cell execution.
"""
if not self.success:
_LOGGER.info("Result is not available as the execution was not successful.")
return None
if not self.results or not any(res.is_main_result for res in self.results):
_LOGGER.info("Execution was successful but there is no main result.")
return None
main_result = self.results[-1]
assert main_result.is_main_result, "The last result should be the main result."
return main_result

def to_json(self) -> str:
"""
Returns the JSON representation of the Execution object.
Expand Down

0 comments on commit a72084c

Please sign in to comment.