Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -107,15 +107,19 @@ def process_document(image):
|
|
107 |
)
|
108 |
print("8")
|
109 |
print("output_text ---->>>>", output_text)
|
|
|
|
|
110 |
|
111 |
# Handle output text to convert it into JSON
|
|
|
112 |
try:
|
113 |
print("Trying ......")
|
114 |
almost_json = output_text[0].split('\n')[-1].split('\n')[0]
|
115 |
json = literal_eval(almost_json)
|
116 |
except Exception as e:
|
117 |
print(f"Got error {e}")
|
118 |
-
json = output_text[0] # Return raw output if JSON parsing fails
|
|
|
119 |
|
120 |
# Optionally, you can delete the temporary file after use
|
121 |
os.remove(image_path)
|
@@ -126,7 +130,7 @@ def process_document(image):
|
|
126 |
demo = gr.Interface(
|
127 |
fn=process_document,
|
128 |
inputs="image", # Gradio will handle the image input
|
129 |
-
outputs="
|
130 |
title="PaySlip_Demo_Model",
|
131 |
examples=[["Slip_1.jpg"], ["Slip_2.jpg"]],
|
132 |
cache_examples=False
|
|
|
107 |
)
|
108 |
print("8")
|
109 |
print("output_text ---->>>>", output_text)
|
110 |
+
print("output text type --->>>> ", type(output_text))
|
111 |
+
print("First element", output_text[0])
|
112 |
|
113 |
# Handle output text to convert it into JSON
|
114 |
+
json = str()
|
115 |
try:
|
116 |
print("Trying ......")
|
117 |
almost_json = output_text[0].split('\n')[-1].split('\n')[0]
|
118 |
json = literal_eval(almost_json)
|
119 |
except Exception as e:
|
120 |
print(f"Got error {e}")
|
121 |
+
# json = output_text[0] # Return raw output if JSON parsing fails
|
122 |
+
json = output_text
|
123 |
|
124 |
# Optionally, you can delete the temporary file after use
|
125 |
os.remove(image_path)
|
|
|
130 |
demo = gr.Interface(
|
131 |
fn=process_document,
|
132 |
inputs="image", # Gradio will handle the image input
|
133 |
+
outputs="text",
|
134 |
title="PaySlip_Demo_Model",
|
135 |
examples=[["Slip_1.jpg"], ["Slip_2.jpg"]],
|
136 |
cache_examples=False
|