Update app.py
Browse files
app.py
CHANGED
@@ -3,8 +3,21 @@ import os
|
|
3 |
import tempfile
|
4 |
import json
|
5 |
import zipfile
|
6 |
-
from
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
def process_yolox_api(files):
|
10 |
'''API endpoint for YOLOX processing.'''
|
@@ -27,11 +40,9 @@ def process_yolox_api(files):
|
|
27 |
shutil.copy(file.name, input_dir)
|
28 |
|
29 |
try:
|
30 |
-
# Run YOLOX
|
31 |
-
coco_json_path = run_yolox(input_dir, output_dir)
|
32 |
|
33 |
-
|
34 |
-
cropped_paths =
|
35 |
|
36 |
# Create zip file
|
37 |
zip_path = os.path.join(temp_dir, "cropped_results.zip")
|
|
|
3 |
import tempfile
|
4 |
import json
|
5 |
import zipfile
|
6 |
+
from tools.demo_api import build_predictor, run_detection
|
7 |
+
import square_crop # todo: cropping implementation
|
8 |
+
|
9 |
+
PREDICTOR = build_predictor(
|
10 |
+
exp_file = "path",
|
11 |
+
model_name = "yolox_s",
|
12 |
+
ckpt_path = "path",
|
13 |
+
device="cpu",
|
14 |
+
fp16=False,
|
15 |
+
fuse=False,
|
16 |
+
trt=False,
|
17 |
+
conf=0.3,
|
18 |
+
nms=0.3,
|
19 |
+
tsize=640,
|
20 |
+
)
|
21 |
|
22 |
def process_yolox_api(files):
|
23 |
'''API endpoint for YOLOX processing.'''
|
|
|
40 |
shutil.copy(file.name, input_dir)
|
41 |
|
42 |
try:
|
|
|
|
|
43 |
|
44 |
+
coco_json_path = run_detection(PREDICTOR, input_dir)
|
45 |
+
cropped_paths = square_crop(input_dir, coco_json_path, cropped_dir)
|
46 |
|
47 |
# Create zip file
|
48 |
zip_path = os.path.join(temp_dir, "cropped_results.zip")
|