Skip to content

Commit

Permalink
Merge pull request #99 from ks6088ts-labs/bugfix/issue-98_fix-image-i…
Browse files Browse the repository at this point in the history
…nference

fix image inference
  • Loading branch information
ks6088ts authored Aug 28, 2024
2 parents 03ec950 + 73ef1a4 commit faf8478
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
12 changes: 9 additions & 3 deletions apps/1_call_azure_openai_chat/query_image.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import argparse
import base64
import logging
from os import getenv

from dotenv import load_dotenv
Expand All @@ -15,10 +16,17 @@ def init_args() -> argparse.Namespace:
parser.add_argument("-f", "--file")
parser.add_argument("-s", "--system", default="You are a professional image analyst. Describe the image.")
parser.add_argument("-p", "--prompt", default="Please describe the content of the image")
parser.add_argument("-v", "--verbose", action="store_true")
return parser.parse_args()


if __name__ == "__main__":
args = init_args()

# Set verbose mode
if args.verbose:
logging.basicConfig(level=logging.DEBUG)

# Parse .env file and set environment variables
load_dotenv()

Expand All @@ -29,8 +37,6 @@ def init_args() -> argparse.Namespace:
azure_endpoint=getenv("AZURE_OPENAI_ENDPOINT"),
)

args = init_args()

# Read image file and encode it to base64
try:
with open(args.file, "rb") as f:
Expand All @@ -56,7 +62,7 @@ def init_args() -> argparse.Namespace:
},
{
"type": "text",
"content": args.prompt,
"text": args.prompt,
},
],
},
Expand Down
2 changes: 1 addition & 1 deletion apps/99_streamlit_examples/pages/2_Image_Q&A.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def is_configured():
},
{
"type": "text",
"content": question,
"text": question,
},
],
},
Expand Down
2 changes: 1 addition & 1 deletion apps/99_streamlit_examples/pages/3_Camera_Q&A.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def is_configured():
},
{
"type": "text",
"content": question,
"text": question,
},
],
},
Expand Down

0 comments on commit faf8478

Please sign in to comment.