coutant commited on
Commit
ed4ad05
1 Parent(s): 4e5c213

removed warnings.

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -17,18 +17,21 @@ def inference(img:PIL.Image.Image, threshold:float=0.6):
17
  model.conf = threshold
18
  # detections:torchvision.Detections = model(images, size=640)
19
  detections = model(images, size=640)
 
 
20
  predictions:torch.Tensor = detections.pred[0] # the predictions for our single image
 
21
  detections.render() # bounding boxes and labels added into image
22
- return detections.imgs[0], predictions.size(dim=0) # image and number of detections
 
23
 
24
  gr.Interface(
25
  fn = inference,
26
- inputs = [ gr.inputs.Image(type="pil", label="Input"), gr.Slider(minimum=0.5, maximum=0.9, step=0.05, value=0.7, label="Confidence threshold") ],
27
- outputs = [ gr.components.Image(type="pil", label="Output"), gr.components.Label(label="nb of persons detected for given confidence threshold") ],
28
  title="Person detection with YOLO v5",
29
  description="Person detection, you can twik the corresponding confidence threshold. Good results even when face not visible.",
30
  article=article,
31
  examples=[['data/businessmen-612.jpg'], ['data/businessmen-back.jpg']],
32
- enable_queue=True,
33
  allow_flagging="never"
34
- ).launch(debug=True)
 
17
  model.conf = threshold
18
  # detections:torchvision.Detections = model(images, size=640)
19
  detections = model(images, size=640)
20
+ print( "detections type:" , type(detections))
21
+ print( "attributes:" , dir(detections))
22
  predictions:torch.Tensor = detections.pred[0] # the predictions for our single image
23
+ result_image=detections.imgs[0]
24
  detections.render() # bounding boxes and labels added into image
25
+ # return detections.imgs[0], predictions.size(dim=0) # image and number of detections
26
+ return result_image, predictions.size(dim=0) # image and number of detections
27
 
28
  gr.Interface(
29
  fn = inference,
30
+ inputs = [ gr.Image(type="pil", label="Input"), gr.Slider(minimum=0.5, maximum=0.9, step=0.05, value=0.7, label="Confidence threshold") ],
31
+ outputs = [ gr.Image(type="pil", label="Output"), gr.Label(label="nb of persons detected for given confidence threshold") ],
32
  title="Person detection with YOLO v5",
33
  description="Person detection, you can twik the corresponding confidence threshold. Good results even when face not visible.",
34
  article=article,
35
  examples=[['data/businessmen-612.jpg'], ['data/businessmen-back.jpg']],
 
36
  allow_flagging="never"
37
+ ).launch(debug=True, enable_queue=True, share=True)