jonas commited on
Commit
71952de
1 Parent(s): 014216d
Files changed (1) hide show
  1. app.py +15 -26
app.py CHANGED
@@ -15,36 +15,25 @@ path = [['img/test-image.jpg'], ['img/test-image-2.jpg']]
15
 
16
  # def show_preds_image(image_path):
17
  # image = cv2.imread(image_path)
18
- # # outputs = model(source=image_path)
19
- # # results = outputs[0].cpu().numpy()
20
- # results = model(image_path)
21
- # results.xyxy[0] # img1 predictions (tensor)
22
- # results.pandas().xyxy[0] # img1 predictions (pandas)
23
- # predictions = results.pred[0]
24
- # boxes = predictions[:, :4] # x1, y1, x2, y2
25
- # scores = predictions[:, 4]
26
- # categories = predictions[:, 5]
27
-
28
- # # for i, det in enumerate(results.boxes.xyxy):
29
- # # cv2.rectangle(
30
- # # image,
31
- # # (int(det[0]), int(det[1])),
32
- # # (int(det[2]), int(det[3])),
33
- # # color=(0, 0, 255),
34
- # # thickness=2,
35
- # # lineType=cv2.LINE_AA
36
- # # )
37
- # return results.show()
38
-
39
- def show_preds_image(im, size=640):
40
  #g = (size / max(im.size)) # gain
41
  #im = im.resize((int(x * g) for x in im.size), Image.ANTIALIAS) # resize
42
 
43
  results = model(im) # inference
44
- results.render() # updates results.imgs with boxes and labels
45
- results.save()
46
- os.system("ls")
47
- return "out.png"
48
 
49
  inputs_image = [
50
  gr.components.Image(type="filepath", label="Input Image"),
 
15
 
16
  # def show_preds_image(image_path):
17
  # image = cv2.imread(image_path)
18
+ # outputs = model.predict(source=image_path)
19
+ # results = outputs[0].cpu().numpy()
20
+ # for i, det in enumerate(results.boxes.xyxy):
21
+ # cv2.rectangle(
22
+ # image,
23
+ # (int(det[0]), int(det[1])),
24
+ # (int(det[2]), int(det[3])),
25
+ # color=(0, 0, 255),
26
+ # thickness=2,
27
+ # lineType=cv2.LINE_AA
28
+ # )
29
+ # return cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
30
+
31
+ def show_preds_image(im):
 
 
 
 
 
 
 
 
32
  #g = (size / max(im.size)) # gain
33
  #im = im.resize((int(x * g) for x in im.size), Image.ANTIALIAS) # resize
34
 
35
  results = model(im) # inference
36
+ return results.render()[0]
 
 
 
37
 
38
  inputs_image = [
39
  gr.components.Image(type="filepath", label="Input Image"),