Update app.py
Browse files
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 =
|
| 16 |
|
| 17 |
def yolox_inference(
|
| 18 |
image_path: gr.inputs.Image = None,
|
|
@@ -49,18 +50,19 @@ def yolox_inference(
|
|
| 49 |
]
|
| 50 |
}
|
| 51 |
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
|
|
|
| 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 |
|