xelpmocAI commited on
Commit
a515837
·
verified ·
1 Parent(s): 965cbb7

keeping json and indentation

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -46,7 +46,7 @@ tax_deductions = '''Extract the following information in the given format:
46
 
47
  def format_nested_dict(data, indent=0):
48
  formatted_str = ""
49
- indent_str = " " * indent # Indentation for the current level
50
 
51
  for key, value in data.items():
52
  # If value is a dictionary, recurse deeper
@@ -115,14 +115,15 @@ def process_document(image):
115
  image_path = tmp_file.name # Get the path of the saved file
116
 
117
  # Process the image with your model
118
- one = format_nested_dict(process_function(image_path, other_benifits))
119
- two = format_nested_dict(process_function(image_path, tax_deductions))
120
-
 
121
 
122
  # Optionally, you can delete the temporary file after use
123
  os.remove(image_path)
124
 
125
- return one, two
126
 
127
 
128
 
@@ -133,7 +134,9 @@ demo = gr.Interface(
133
  fn=process_document,
134
  inputs="image", # Gradio will handle the image input
135
  outputs=[
136
- gr.Textbox(label="Tax Deductions Information"), # First output box with heading
 
 
137
  gr.Textbox(label="Other Benefits and Information") # Second output box with heading
138
  ],
139
  title="<div style='text-align: center;'>Information Extraction From PaySlip</div>",
 
46
 
47
  def format_nested_dict(data, indent=0):
48
  formatted_str = ""
49
+ indent_str = " " * indent # Indentation for the current level
50
 
51
  for key, value in data.items():
52
  # If value is a dictionary, recurse deeper
 
115
  image_path = tmp_file.name # Get the path of the saved file
116
 
117
  # Process the image with your model
118
+ one = process_function(image_path, other_benifits)
119
+ two = process_function(image_path, tax_deductions)
120
+ three = format_nested_dict(one)
121
+ four = format_nested_dict(two)
122
 
123
  # Optionally, you can delete the temporary file after use
124
  os.remove(image_path)
125
 
126
+ return one, three, two, four
127
 
128
 
129
 
 
134
  fn=process_document,
135
  inputs="image", # Gradio will handle the image input
136
  outputs=[
137
+ gr.JSON(label="Tax Deductions Information"), # First output box with heading
138
+ gr.Textbox(label="Other Benefits and Information"), # Second output box with heading
139
+ gr.JSON(label="Tax Deductions Information"), # First output box with heading
140
  gr.Textbox(label="Other Benefits and Information") # Second output box with heading
141
  ],
142
  title="<div style='text-align: center;'>Information Extraction From PaySlip</div>",