Skip to content

Commit

Permalink
Merge pull request #16 from 5sControl/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
eugenos-programos authored Sep 20, 2023
2 parents cdc33d8 + c00c0d3 commit b6b5ff0
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 17 deletions.
3 changes: 2 additions & 1 deletion idle_model/IdleObjectDetectionModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
from yolor.utils.datasets import letterbox
from yolor.utils.general import non_max_suppression, scale_coords
import time
from logging import Logger


class IdleObjectDetectionModel:
def __init__(self, model_path: str, config_path: str, conf_thresh: float, iou_thresh: float, classes: list, logger) -> None:
def __init__(self, model_path: str, config_path: str, conf_thresh: float, iou_thresh: float, classes: list, logger: Logger, **kwargs) -> None:
self.model, self.device = get_model(model_path, config_path)
self.conf_thresh = conf_thresh
self.iou_thresh = iou_thresh
Expand Down
10 changes: 3 additions & 7 deletions idle_model/app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from PIL import Image
from flask import Flask, jsonify, request
from configs.load_configs import *
from configs import configs
from IdleObjectDetectionModel import IdleObjectDetectionModel
import numpy as np
import io
Expand All @@ -25,12 +25,8 @@

app = Flask(__name__)
model = IdleObjectDetectionModel(
MODEL_PATH,
CONF_PATH,
CONF_THRES,
IOU_THRES,
CLASSES,
logger
**configs,
logger=logger
)

convert_bytes2image = lambda bytes: np.array(Image.open(io.BytesIO(bytes)), dtype=np.uint8)
Expand Down
1 change: 1 addition & 0 deletions idle_model/configs/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .load_configs import configs
6 changes: 3 additions & 3 deletions idle_model/configs/confs.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"classes": [
67
],
"iou_thres": 0.5,
"conf_thres": 0.6,
"iou_thresh": 0.5,
"conf_thresh": 0.7,
"model_path": "weights/idle_v0.4.4.pt",
"conf_path": "weights/yolor_csp_x.cfg",
"config_path": "weights/yolor_csp_x.cfg",
"port": 5001
}
6 changes: 0 additions & 6 deletions idle_model/configs/load_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,3 @@

with open("configs/confs.json", "r") as conf:
configs = json.load(conf)
CONF_THRES = configs.get("conf_thres")
CONF_PATH = configs.get("conf_path")
IOU_THRES = configs.get("iou_thres")
MODEL_PATH = configs.get("model_path")
CLASSES = configs.get("classes")
PORT = configs.get("port")

0 comments on commit b6b5ff0

Please sign in to comment.