Neurolingua
commited on
Commit
•
6d7d22e
1
Parent(s):
fbacac8
Update app.py
Browse files
app.py
CHANGED
@@ -16,9 +16,14 @@ from inference_sdk import InferenceHTTPClient
|
|
16 |
import base64
|
17 |
|
18 |
def encode_image_to_base64(filepath):
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
def predict_pest(filepath):
|
24 |
CLIENT = InferenceHTTPClient(
|
|
|
16 |
import base64
|
17 |
|
18 |
def encode_image_to_base64(filepath):
|
19 |
+
try:
|
20 |
+
with open(filepath, "rb") as image_file:
|
21 |
+
encoded_string = base64.b64encode(image_file.read()).decode('utf-8')
|
22 |
+
print(f"Encoded image length: {len(encoded_string)}") # Debug: Check length
|
23 |
+
return encoded_string
|
24 |
+
except Exception as e:
|
25 |
+
print(f"Error encoding image: {e}")
|
26 |
+
return None
|
27 |
|
28 |
def predict_pest(filepath):
|
29 |
CLIENT = InferenceHTTPClient(
|