905saini commited on
Commit
fa20230
·
1 Parent(s): 3864753

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -19,7 +19,7 @@ def process_img(img):
19
 
20
  st.title("Table Extract")
21
  file_name = st.file_uploader("Upload a repport image")
22
- print(type(file_name),file_name)
23
  if file_name is not None:
24
  col1, col2 = st.columns(2)
25
 
@@ -31,22 +31,31 @@ if file_name is not None:
31
  bbox,confidance,classes,nc = model(input_image)
32
  bbox,confidance , classes , nc = bbox[0].numpy(),confidance[0].numpy(),classes[0].numpy(),nc[0].numpy()
33
  st.subheader("Detected Result")
 
 
 
34
  for i in range(nc):
35
  if confidance[i] >= threshold:
36
  x1,y1,x2,y2 = bbox[i]*640
37
  class_name = labels[int(classes[i])]
38
  st.text(class_name+" : "+str(int(confidance[i]*100))+"%")
39
  if class_name =="Header":
 
40
  color = (0,0,255) #Blue color
41
  cv2.rectangle(copy_img, (int(x1), int(y1)), (int(x2), int(y2)),color, 2)
42
 
43
  if class_name =="Column":
 
44
  color = (0,255,0) #Green color
45
  cv2.rectangle(copy_img, (int(x1), int(y1)), (int(x2), int(y2)),color, 2)
46
 
47
  if class_name =="Table":
 
48
  color = (255,0,0) #Red color
49
  cv2.rectangle(copy_img, (int(x1), int(y1)), (int(x2), int(y2)),color, 2)
 
 
 
50
  col2.header("Output Result")
51
  col2.image(copy_img, use_column_width=True)
52
 
 
19
 
20
  st.title("Table Extract")
21
  file_name = st.file_uploader("Upload a repport image")
22
+
23
  if file_name is not None:
24
  col1, col2 = st.columns(2)
25
 
 
31
  bbox,confidance,classes,nc = model(input_image)
32
  bbox,confidance , classes , nc = bbox[0].numpy(),confidance[0].numpy(),classes[0].numpy(),nc[0].numpy()
33
  st.subheader("Detected Result")
34
+ table_count =0
35
+ header_count = 0
36
+ column_count = 0
37
  for i in range(nc):
38
  if confidance[i] >= threshold:
39
  x1,y1,x2,y2 = bbox[i]*640
40
  class_name = labels[int(classes[i])]
41
  st.text(class_name+" : "+str(int(confidance[i]*100))+"%")
42
  if class_name =="Header":
43
+ header_count+=1
44
  color = (0,0,255) #Blue color
45
  cv2.rectangle(copy_img, (int(x1), int(y1)), (int(x2), int(y2)),color, 2)
46
 
47
  if class_name =="Column":
48
+ column_count+=1
49
  color = (0,255,0) #Green color
50
  cv2.rectangle(copy_img, (int(x1), int(y1)), (int(x2), int(y2)),color, 2)
51
 
52
  if class_name =="Table":
53
+ table_count+=1
54
  color = (255,0,0) #Red color
55
  cv2.rectangle(copy_img, (int(x1), int(y1)), (int(x2), int(y2)),color, 2)
56
+ st.text("No of Table Detected : "+str(table_count))
57
+ st.text("No of Header Detected : "+str(header_count))
58
+ st.text("No of Column Detected : "+str(column_count))
59
  col2.header("Output Result")
60
  col2.image(copy_img, use_column_width=True)
61