offthewallace commited on
Commit
cd9032a
·
1 Parent(s): 3c3369a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -7
app.py CHANGED
@@ -13,17 +13,27 @@ def yolo(im, size=640):
13
  results.render() # updates results.imgs with boxes and labels
14
  return Image.fromarray(results.ims[0])
15
 
16
- def detect(image):
17
- results = model(image)
18
- results.render()
19
- return Image.fromarray(results.ims[0])
 
 
 
 
 
 
 
 
 
20
 
21
 
22
  inputs = gr.inputs.Image(type='pil', label="Original Image")
23
- outputs = gr.outputs.Image(type="pil", label="Output Image")
24
 
25
- title = "Object detection from Infrared image using YOLOv5n"
 
26
 
27
 
28
- gr.Interface(detect, inputs, outputs, title=title, theme="huggingface").launch(debug=True)
29
 
 
13
  results.render() # updates results.imgs with boxes and labels
14
  return Image.fromarray(results.ims[0])
15
 
16
+ def detect(pdf):
17
+
18
+ path_to_pdf = pdf.name
19
+ imgs = pdf2image.convert_from_path(path_to_pdf)
20
+ for i in range(len(imgs):
21
+
22
+ result = model(np.array(imgs[i]))
23
+ result_pred=result.pred
24
+
25
+ for j in range(len(result_pred[0])):
26
+ if result_pred[0][j][5]==1 and result_pred[i][j][4]>0.5:
27
+ return {'not signature': 0, 'signature': 1}
28
+ return return {'not signature': 1, 'signature': 0}
29
 
30
 
31
  inputs = gr.inputs.Image(type='pil', label="Original Image")
32
+ #outputs = gr.outputs.Image(type="pil", label="Output Image")
33
 
34
+ title = "Object detection for signature detections in pdf file "
35
+ description = "Drop a PDF (WARNING: only the first page will be converted into an image)."
36
 
37
 
38
+ gr.Interface(detect, inputs=gr.File(label="PDF"), outputs="label", title=title, description=description,theme="huggingface").launch(debug=True)
39