Skip to content

Commit

Permalink
Minor changes to support benchmarking (#138)
Browse files Browse the repository at this point in the history
* Changes to support benchmarking

* Fix lint

* Empty-Commit

* Replace pkg_resources with importlib

* Empty-Commit
  • Loading branch information
humpydonkey authored Jun 18, 2024
1 parent b10d3d4 commit 6d2223b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 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
19 changes: 17 additions & 2 deletions vision_agent/utils/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,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 Expand Up @@ -411,11 +426,11 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
"""
import platform
import sys
import pkg_resources
import importlib.metadata
print(f"Python version: {sys.version}")
print(f"OS version: {platform.system()} {platform.release()} ({platform.architecture()})")
va_version = pkg_resources.get_distribution("vision-agent").version
va_version = importlib.metadata.version("vision-agent")
print(f"Vision Agent version: {va_version}")"""
)
sys_versions = "\n".join(result.logs.stdout)
Expand Down

0 comments on commit 6d2223b

Please sign in to comment.