Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -46,7 +46,7 @@ def yolo_and_trocr(image_input, save):
|
|
46 |
else:
|
47 |
decoded_text = decoded_text[0]
|
48 |
|
49 |
-
# Saving the info in a dictionary
|
50 |
if save:
|
51 |
data_dict = ast.literal_eval(decoded_text)
|
52 |
file_path = f"{data_dict['Address']}.json"
|
@@ -54,8 +54,10 @@ def yolo_and_trocr(image_input, save):
|
|
54 |
current_datetime = datetime.now()
|
55 |
timestamp = current_datetime.strftime("%Y-%m-%d %H:%M:%S")
|
56 |
data_dict['Last_Reading'] = {f'{timestamp}': f'{text}'}
|
|
|
57 |
return image, text, decoded_text, file_path
|
58 |
|
|
|
59 |
else:
|
60 |
return image, text, decoded_text, None
|
61 |
|
|
|
46 |
else:
|
47 |
decoded_text = decoded_text[0]
|
48 |
|
49 |
+
# Saving the info in a dictionary for output if requested
|
50 |
if save:
|
51 |
data_dict = ast.literal_eval(decoded_text)
|
52 |
file_path = f"{data_dict['Address']}.json"
|
|
|
54 |
current_datetime = datetime.now()
|
55 |
timestamp = current_datetime.strftime("%Y-%m-%d %H:%M:%S")
|
56 |
data_dict['Last_Reading'] = {f'{timestamp}': f'{text}'}
|
57 |
+
json.dump(data_dict, file, indent=4)
|
58 |
return image, text, decoded_text, file_path
|
59 |
|
60 |
+
# Outputing the image, reading, and QR code info without saving the data
|
61 |
else:
|
62 |
return image, text, decoded_text, None
|
63 |
|