vkumartr commited on
Commit
0066f8f
·
verified ·
1 Parent(s): 3a340f2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -3
app.py CHANGED
@@ -114,8 +114,6 @@ def extract_invoice_data(file_data, content_type, json_schema):
114
  img.save(img_byte_arr, format="PNG", dpi=(300, 300))
115
  base64_encoded = base64.b64encode(img_byte_arr.getvalue()).decode('utf-8')
116
  base64_images.append(f"data:{content_type};base64,{base64_encoded}")
117
-
118
- content_type = "image/png"
119
 
120
  except Exception as e:
121
  logger.error(f"Error converting PDF to image: {e}")
@@ -124,7 +122,7 @@ def extract_invoice_data(file_data, content_type, json_schema):
124
  elif content_type.startswith("image/"):
125
  # Handle direct image files
126
  base64_encoded = base64.b64encode(file_data).decode('utf-8')
127
- base64_images.append(f"data:{content_type.lower()};base64,{base64_encoded}")
128
 
129
  # Prepare OpenAI request
130
  openai_content = [{"type": "image_url", "image_url": {"url": img_base64}} for img_base64 in base64_images]
 
114
  img.save(img_byte_arr, format="PNG", dpi=(300, 300))
115
  base64_encoded = base64.b64encode(img_byte_arr.getvalue()).decode('utf-8')
116
  base64_images.append(f"data:{content_type};base64,{base64_encoded}")
 
 
117
 
118
  except Exception as e:
119
  logger.error(f"Error converting PDF to image: {e}")
 
122
  elif content_type.startswith("image/"):
123
  # Handle direct image files
124
  base64_encoded = base64.b64encode(file_data).decode('utf-8')
125
+ base64_images.append(f"data:{content_type};base64,{base64_encoded}")
126
 
127
  # Prepare OpenAI request
128
  openai_content = [{"type": "image_url", "image_url": {"url": img_base64}} for img_base64 in base64_images]