Spaces:
Sleeping
Sleeping
Update utils/basic_functions.py
Browse files- utils/basic_functions.py +5 -2
utils/basic_functions.py
CHANGED
|
@@ -77,19 +77,22 @@ def gemini_identify_id(model_name,image,system_prompt):
|
|
| 77 |
# 2. Function to process image with Gemini Pro Vision
|
| 78 |
try:
|
| 79 |
genai.configure(api_key=get_secret('GEMINI_API'))
|
| 80 |
-
|
| 81 |
model = genai.GenerativeModel("gemini-2.0-flash")
|
|
|
|
| 82 |
response = model.generate_content([system_prompt, image])
|
|
|
|
| 83 |
response_text = response.text
|
|
|
|
| 84 |
if not response_text:
|
| 85 |
print('Could not find an ID number')
|
| 86 |
return [image,'no response was received']
|
| 87 |
-
print(f"response_text: {response_text}")
|
| 88 |
|
| 89 |
except Exception as e:
|
| 90 |
return [image,f"Error processing image: {str(e)}"]
|
| 91 |
|
| 92 |
draw = ImageDraw.Draw(image)
|
|
|
|
| 93 |
draw.rectangle(ast.literal_eval(response_text),outline='yellow',width=5)
|
| 94 |
#image.save(f'{os.path.dirname(os.path.dirname(os.path.abspath(__file__)))}\\download\\{dt.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")}.jpg')
|
| 95 |
return [image,response_text]
|
|
|
|
| 77 |
# 2. Function to process image with Gemini Pro Vision
|
| 78 |
try:
|
| 79 |
genai.configure(api_key=get_secret('GEMINI_API'))
|
| 80 |
+
print(f"genai: {genai}")
|
| 81 |
model = genai.GenerativeModel("gemini-2.0-flash")
|
| 82 |
+
print(f"model: {model}")
|
| 83 |
response = model.generate_content([system_prompt, image])
|
| 84 |
+
print(f"response: {response}")
|
| 85 |
response_text = response.text
|
| 86 |
+
print(f"response: {response_text}")
|
| 87 |
if not response_text:
|
| 88 |
print('Could not find an ID number')
|
| 89 |
return [image,'no response was received']
|
|
|
|
| 90 |
|
| 91 |
except Exception as e:
|
| 92 |
return [image,f"Error processing image: {str(e)}"]
|
| 93 |
|
| 94 |
draw = ImageDraw.Draw(image)
|
| 95 |
+
print(f"draw: {draw}")
|
| 96 |
draw.rectangle(ast.literal_eval(response_text),outline='yellow',width=5)
|
| 97 |
#image.save(f'{os.path.dirname(os.path.dirname(os.path.abspath(__file__)))}\\download\\{dt.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")}.jpg')
|
| 98 |
return [image,response_text]
|