Atualli commited on
Commit
9bb566b
1 Parent(s): c36e146

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -14
app.py CHANGED
@@ -4,15 +4,16 @@ import os
4
  os.system("pip -qq install yoloxdetect")
5
  import torch
6
  import json
 
 
7
 
8
- from yoloxdetect import YoloxDetector
9
 
10
  # Images
11
  torch.hub.download_url_to_file('https://github.com/ultralytics/yolov5/raw/master/data/images/zidane.jpg', 'zidane.jpg')
12
  torch.hub.download_url_to_file('https://raw.githubusercontent.com/obss/sahi/main/tests/data/small-vehicles1.jpeg', 'small-vehicles1.jpeg')
13
  torch.hub.download_url_to_file('https://raw.githubusercontent.com/Megvii-BaseDetection/YOLOX/main/assets/dog.jpg', 'dog.jpg')
14
 
15
- model = YoloxDetector('kadirnar/yolox_s-v0.1.1', 'configs.yolox_s', device="cpu", hf_model=True)
16
 
17
  def yolox_inference(
18
  image_path: gr.inputs.Image = None,
@@ -49,18 +50,19 @@ def yolox_inference(
49
  ]
50
  }
51
 
52
- #print (pred2[3])
53
- for i, element in enumerate(pred2[0]):
54
- object = {}
55
- itemclass = round(pred2[2][i].item())
56
- object["classe"] = itemclass
57
- object["nome"] = pred2[3][itemclass]
58
- object["score"] = pred2[1][i].item()
59
- object["x"] = element[0].item()
60
- object["y"] = element[1].item()
61
- object["w"] = element[2].item()
62
- object["h"] = element[3].item()
63
- tensor["tensorflow"].append(object)
 
64
 
65
  #print(tensor)
66
 
 
4
  os.system("pip -qq install yoloxdetect")
5
  import torch
6
  import json
7
+ import yoloxdetect2.helpers as yoloxdetectow
8
+ #from yoloxdetect import YoloxDetector
9
 
 
10
 
11
  # Images
12
  torch.hub.download_url_to_file('https://github.com/ultralytics/yolov5/raw/master/data/images/zidane.jpg', 'zidane.jpg')
13
  torch.hub.download_url_to_file('https://raw.githubusercontent.com/obss/sahi/main/tests/data/small-vehicles1.jpeg', 'small-vehicles1.jpeg')
14
  torch.hub.download_url_to_file('https://raw.githubusercontent.com/Megvii-BaseDetection/YOLOX/main/assets/dog.jpg', 'dog.jpg')
15
 
16
+ model = yoloxdetectow.YoloxDetector2('kadirnar/yolox_s-v0.1.1', 'configs.yolox_s', device="cpu", hf_model=True)
17
 
18
  def yolox_inference(
19
  image_path: gr.inputs.Image = None,
 
50
  ]
51
  }
52
 
53
+ if pred2 is not None:
54
+ #print (pred2[3])
55
+ for i, element in enumerate(pred2[0]):
56
+ object = {}
57
+ itemclass = round(pred2[2][i].item())
58
+ object["classe"] = itemclass
59
+ object["nome"] = pred2[3][itemclass]
60
+ object["score"] = pred2[1][i].item()
61
+ object["x"] = element[0].item()
62
+ object["y"] = element[1].item()
63
+ object["w"] = element[2].item()
64
+ object["h"] = element[3].item()
65
+ tensor["tensorflow"].append(object)
66
 
67
  #print(tensor)
68