rosemariafontana commited on
Commit
993fdf4
Β·
verified Β·
1 Parent(s): 87d6d42

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -42
app.py CHANGED
@@ -53,24 +53,23 @@ def parse_ticket_image(image, question):
53
 
54
  # Define questions you want to ask the model
55
 
56
- questions = ["What is the ticket number?"]
57
- #{"question": "What is the type of grain (For example: corn, soy, wheat)?", "context": image},
58
- #{"question": "What is the date?", "context": image},
59
- #{"question": "What is the time?", "context": image},
60
- #{"question": "What is the gross weight?", "context": image},
61
- #{"question": "What is the tare weight?", "context": image},
62
- #{"question": "What is the net weight?", "context": image},
63
- #{"question": "What is the moisture (moist) percentage?", "context": image},
64
- #{"question": "What is the damage percentage?", "context": image},
65
- #{"question": "What is the gross units?", "context": image},
66
- #{"question": "What is the dock units?", "context": image},
67
- #{"question": "What is the comment?", "context": image},
68
- #{"question": "What is the assembly number?", "context": image},
69
- #]
 
70
 
71
  # Use the model to answer each question
72
- #results = [model(q["question"], q["context"]) for q in questions]
73
-
74
  answers = {}
75
  for i, q in enumerate(questions):
76
  answer_text = process_question(q, document)
@@ -79,36 +78,36 @@ def parse_ticket_image(image, question):
79
 
80
 
81
  ticket_number = answers[0]
82
- # Extract answers from the results
83
- #ticket_number = results[0][0]['answer']
84
- #date = results[1][0]['answer']
85
- #time = results[2][0]['answer']
86
- #gross_weight = results[3][0]['answer']
87
- #tare_weight = results[4][0]['answer']
88
- #net_weight = results[5][0]['answer']
89
- #moisture = results[6][0]['answer']
90
- #damage = results[7][0]['answer']
91
- #gross_units = results[8][0]['answer']
92
- #dock_units = results[9][0]['answer']
93
- #comment = results[10][0]['answer']
94
- #assembly_number = results[11][0]['answer']
95
 
96
  # Create a structured format (like a table) using pandas
97
  data = {
98
- "Ticket Number": [ticket_number]
 
 
 
 
 
 
 
 
 
 
 
 
99
  }
100
- #"Assembly Number": [assembly_number],
101
- #"Date": [date],
102
- #"Time": [time],
103
- #"Gross Weight": [gross_weight],
104
- #"Tare Weight": [tare_weight],
105
- #"Net Weight": [net_weight],
106
- #"Moisture": [moisture],
107
- #"Damage": [damage],
108
- #"Gross Units": [gross_units],
109
- #"Dock Units": [dock_units],
110
- #"Comment": [comment],
111
- #}
112
  df = pd.DataFrame(data)
113
 
114
  return df
 
53
 
54
  # Define questions you want to ask the model
55
 
56
+ questions = [
57
+ "What is the ticket number?",
58
+ "What is the type of grain (For example: corn, soy, wheat)?",
59
+ "What is the date?",
60
+ "What is the time?",
61
+ "What is the gross weight?",
62
+ "What is the tare weight?",
63
+ "What is the net weight?",
64
+ "What is the moisture (moist) percentage?",
65
+ "What is the damage percentage?",
66
+ "What is the gross units?",
67
+ "What is the dock units?",
68
+ "What is the comment?",
69
+ "What is the assembly number?",
70
+ ]
71
 
72
  # Use the model to answer each question
 
 
73
  answers = {}
74
  for i, q in enumerate(questions):
75
  answer_text = process_question(q, document)
 
78
 
79
 
80
  ticket_number = answers[0]
81
+ grain_type = answers[1]
82
+ date = answers[2]
83
+ time = answers[3]
84
+ gross_weight = answers[4]
85
+ tare_weight = answers[5]
86
+ net_weight = answers[6]
87
+ moisture = answers[7]
88
+ damage = answers[8]
89
+ gross_units = answers[9]
90
+ dock_units = answers[10]
91
+ comment = answers[11]
92
+ assembly_number = answers[12]
93
+
94
 
95
  # Create a structured format (like a table) using pandas
96
  data = {
97
+ "Ticket Number": [ticket_number],
98
+ "Grain Type": [grain_type],
99
+ "Assembly Number": [assembly_number],
100
+ "Date": [date],
101
+ "Time": [time],
102
+ "Gross Weight": [gross_weight],
103
+ "Tare Weight": [tare_weight],
104
+ "Net Weight": [net_weight],
105
+ "Moisture": [moisture],
106
+ "Damage": [damage],
107
+ "Gross Units": [gross_units],
108
+ "Dock Units": [dock_units],
109
+ "Comment": [comment],
110
  }
 
 
 
 
 
 
 
 
 
 
 
 
111
  df = pd.DataFrame(data)
112
 
113
  return df