capradeepgujaran commited on
Commit
8f72082
·
verified ·
1 Parent(s): 1de2d2a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -99,10 +99,10 @@ def analyze_construction_media(media):
99
  if file_type in ['jpg', 'jpeg', 'png', 'gif']:
100
  # Handle image
101
  try:
102
- image = Image.open(file_path)
103
- logger.info(f"Successfully opened image: {file_path}")
104
- resized_image = resize_image(image)
105
- image_data_url = f"data:image/png;base64,{encode_image(resized_image)}"
106
 
107
  messages = [
108
  {
@@ -192,7 +192,6 @@ def analyze_construction_media(media):
192
  logger.error(f"Error during analysis: {str(e)}")
193
  logger.error(traceback.format_exc())
194
  return [("Analysis error", f"Error during analysis: {str(e)}")]
195
-
196
 
197
  def chat_about_image(message, chat_history):
198
  try:
 
99
  if file_type in ['jpg', 'jpeg', 'png', 'gif']:
100
  # Handle image
101
  try:
102
+ with Image.open(file_path) as image:
103
+ logger.info(f"Successfully opened image: {file_path}")
104
+ resized_image = resize_image(image)
105
+ image_data_url = f"data:image/png;base64,{encode_image(resized_image)}"
106
 
107
  messages = [
108
  {
 
192
  logger.error(f"Error during analysis: {str(e)}")
193
  logger.error(traceback.format_exc())
194
  return [("Analysis error", f"Error during analysis: {str(e)}")]
 
195
 
196
  def chat_about_image(message, chat_history):
197
  try: