xelpmocAI commited on
Commit
0dfbb26
·
verified ·
1 Parent(s): 0f7e32d

Udita feature

Browse files
Files changed (1) hide show
  1. app.py +15 -1
app.py CHANGED
@@ -44,6 +44,14 @@ tax_deductions = '''Extract the following information in the given format:
44
  }
45
  '''
46
 
 
 
 
 
 
 
 
 
47
  def format_nested_dict(data, indent=0):
48
  formatted_str = ""
49
  indent_str = " " * indent # Indentation for the current level
@@ -117,13 +125,16 @@ def process_document(image):
117
  # Process the image with your model
118
  one = process_function(image_path, other_benifits)
119
  two = process_function(image_path, tax_deductions)
 
 
120
  text_one = format_nested_dict(one)
121
  text_two = format_nested_dict(two)
 
122
 
123
  # Optionally, you can delete the temporary file after use
124
  os.remove(image_path)
125
 
126
- return text_one, text_two, one, two
127
 
128
 
129
 
@@ -136,8 +147,11 @@ demo = gr.Interface(
136
  outputs=[
137
  gr.Textbox(label="Other Benefits and Information"), # Second output box with heading
138
  gr.Textbox(label="Tax Deductions Information"), # Second output box with heading
 
 
139
  gr.JSON(label="Other Benefits and Information"), # First output box with heading
140
  gr.JSON(label="Tax Deductions Information"), # First output box with heading
 
141
  ],
142
  title="<div style='text-align: center;'>Information Extraction From PaySlip</div>",
143
  examples=[["Slip_1.jpg"], ["Slip_2.jpg"]],
 
44
  }
45
  '''
46
 
47
+ intro = '''Extract the following information in the given format:
48
+ {
49
+ 'check date': "",
50
+ 'name': "",
51
+ 'address': ""
52
+ }
53
+ '''
54
+
55
  def format_nested_dict(data, indent=0):
56
  formatted_str = ""
57
  indent_str = " " * indent # Indentation for the current level
 
125
  # Process the image with your model
126
  one = process_function(image_path, other_benifits)
127
  two = process_function(image_path, tax_deductions)
128
+ three = process_function(image_path, intro)
129
+
130
  text_one = format_nested_dict(one)
131
  text_two = format_nested_dict(two)
132
+ text_three = format_nested_dict(three)
133
 
134
  # Optionally, you can delete the temporary file after use
135
  os.remove(image_path)
136
 
137
+ return text_one, text_two, text_three, one, two, three
138
 
139
 
140
 
 
147
  outputs=[
148
  gr.Textbox(label="Other Benefits and Information"), # Second output box with heading
149
  gr.Textbox(label="Tax Deductions Information"), # Second output box with heading
150
+ gr.Textbox(label="Introduction"), # Second output box with heading
151
+
152
  gr.JSON(label="Other Benefits and Information"), # First output box with heading
153
  gr.JSON(label="Tax Deductions Information"), # First output box with heading
154
+ gr.JSON(label="Introduction"),
155
  ],
156
  title="<div style='text-align: center;'>Information Extraction From PaySlip</div>",
157
  examples=[["Slip_1.jpg"], ["Slip_2.jpg"]],