artificialguybr commited on
Commit
9aaed47
·
verified ·
1 Parent(s): 02256ee

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -40,9 +40,15 @@ def text_line_detection_function(img):
40
  print("Text Line Detection Function Called")
41
  preds = batch_detection([img], det_model, det_processor)[0] # Assuming this returns a DetectionResult object
42
  print(f"Detection Predictions: {preds}")
43
- # Adjusted access to properties of preds
44
- img_with_lines = draw_polys_on_image(preds.polygons, img) # Assuming preds has a .polygons attribute
45
- return img_with_lines, preds
 
 
 
 
 
 
46
 
47
 
48
  with gr.Blocks() as app:
 
40
  print("Text Line Detection Function Called")
41
  preds = batch_detection([img], det_model, det_processor)[0] # Assuming this returns a DetectionResult object
42
  print(f"Detection Predictions: {preds}")
43
+
44
+ # Check if preds has an attribute 'bboxes' and use it
45
+ if hasattr(preds, 'bboxes'):
46
+ # Assuming draw_polys_on_image can work with the format of bboxes directly or you adapt it accordingly
47
+ img_with_lines = draw_polys_on_image([bbox.polygon for bbox in preds.bboxes], img)
48
+ return img_with_lines, preds
49
+ else:
50
+ raise AttributeError("DetectionResult object does not have 'bboxes' attribute")
51
+
52
 
53
 
54
  with gr.Blocks() as app: