Sandy2636 commited on
Commit
8435795
·
1 Parent(s): 0875303

Add application file

Browse files
Files changed (1) hide show
  1. app.py +4 -7
app.py CHANGED
@@ -4,13 +4,13 @@ import requests
4
  import json
5
 
6
  # Replace with your actual API key and model name
7
- API_KEY = "your_openrouter_api_key"
8
- IMAGE_MODEL = "OpenGVLab/InternVL3-14B"
9
 
10
  def process_passport(image):
11
  try:
12
- # Encode image to base64
13
- encoded_image = base64.b64encode(image.read()).decode("utf-8")
14
  data_url = f"data:image/jpeg;base64,{encoded_image}"
15
 
16
  prompt = "Extract all visible information from the front page of the passport. Output in JSON format."
@@ -36,9 +36,6 @@ def process_passport(image):
36
  response = requests.post("https://openrouter.ai/api/v1/chat/completions", headers=headers, json=payload)
37
  result = response.json()
38
 
39
- print("📡 OpenRouter Response:", result)
40
-
41
- # Return the whole raw JSON result
42
  return json.dumps(result, indent=2)
43
 
44
  except Exception as e:
 
4
  import json
5
 
6
  # Replace with your actual API key and model name
7
+ API_KEY = "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"
8
+ IMAGE_MODEL = "opengvlab/internvl3-14b:free"
9
 
10
  def process_passport(image):
11
  try:
12
+ with open(image, "rb") as f:
13
+ encoded_image = base64.b64encode(f.read()).decode("utf-8")
14
  data_url = f"data:image/jpeg;base64,{encoded_image}"
15
 
16
  prompt = "Extract all visible information from the front page of the passport. Output in JSON format."
 
36
  response = requests.post("https://openrouter.ai/api/v1/chat/completions", headers=headers, json=payload)
37
  result = response.json()
38
 
 
 
 
39
  return json.dumps(result, indent=2)
40
 
41
  except Exception as e: