mirror of
https://github.com/azaion/detections.git
synced 2026-04-22 07:06:32 +00:00
[AZ-173] [AZ-174] Stream-based detection API and DB-driven AI config
Made-with: Cursor
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import os
|
||||
|
||||
from flask import Flask, request
|
||||
|
||||
app = Flask(__name__)
|
||||
@@ -25,6 +27,35 @@ def auth_refresh():
|
||||
return {"token": "refreshed-test-token"}
|
||||
|
||||
|
||||
@app.route("/api/users/<user_id>/ai-settings", methods=["GET"])
|
||||
def user_ai_settings(user_id):
|
||||
if _fail():
|
||||
return "", 503
|
||||
return {
|
||||
"frame_period_recognition": 4,
|
||||
"frame_recognition_seconds": 2,
|
||||
"probability_threshold": 0.25,
|
||||
"tracking_distance_confidence": 0.1,
|
||||
"tracking_probability_increase": 0.1,
|
||||
"tracking_intersection_threshold": 0.6,
|
||||
"model_batch_size": 8,
|
||||
"big_image_tile_overlap_percent": 20,
|
||||
"altitude": 400,
|
||||
"focal_length": 24,
|
||||
"sensor_width": 23.5,
|
||||
}
|
||||
|
||||
|
||||
@app.route("/api/media/<media_id>", methods=["GET"])
|
||||
def media_path(media_id):
|
||||
if _fail():
|
||||
return "", 503
|
||||
root = os.environ.get("MEDIA_DIR", "/media")
|
||||
if media_id.startswith("sse-") or media_id.startswith("video-"):
|
||||
return {"path": f"{root}/video_test01.mp4"}
|
||||
return {"path": f"{root}/image_small.jpg"}
|
||||
|
||||
|
||||
@app.route("/mock/config", methods=["POST"])
|
||||
def mock_config():
|
||||
global _mode
|
||||
|
||||
@@ -3,3 +3,5 @@ pytest-csv
|
||||
requests==2.32.4
|
||||
sseclient-py
|
||||
pytest-timeout
|
||||
flask
|
||||
gunicorn
|
||||
|
||||
@@ -1,35 +1,17 @@
|
||||
import json
|
||||
import os
|
||||
import threading
|
||||
import time
|
||||
import uuid
|
||||
|
||||
import pytest
|
||||
|
||||
_MEDIA = os.environ.get("MEDIA_DIR", "/media")
|
||||
|
||||
|
||||
def _ai_config_video() -> dict:
|
||||
return {
|
||||
"probability_threshold": 0.25,
|
||||
"tracking_intersection_threshold": 0.6,
|
||||
"altitude": 400,
|
||||
"focal_length": 24,
|
||||
"sensor_width": 23.5,
|
||||
"paths": [f"{_MEDIA}/video_test01.mp4"],
|
||||
"frame_period_recognition": 4,
|
||||
"frame_recognition_seconds": 2,
|
||||
}
|
||||
return {}
|
||||
|
||||
|
||||
def _ai_config_image() -> dict:
|
||||
return {
|
||||
"probability_threshold": 0.25,
|
||||
"altitude": 400,
|
||||
"focal_length": 24,
|
||||
"sensor_width": 23.5,
|
||||
"paths": [f"{_MEDIA}/image_small.jpg"],
|
||||
}
|
||||
return {}
|
||||
|
||||
|
||||
def test_ft_p08_immediate_async_response(
|
||||
|
||||
+2
-13
@@ -20,20 +20,9 @@ def _make_jwt() -> str:
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def video_events(warm_engine, http_client, video_short_path):
|
||||
def video_events(warm_engine, http_client):
|
||||
media_id = f"video-{uuid.uuid4().hex}"
|
||||
body = {
|
||||
"probability_threshold": 0.25,
|
||||
"frame_period_recognition": 4,
|
||||
"frame_recognition_seconds": 2,
|
||||
"tracking_distance_confidence": 0.1,
|
||||
"tracking_probability_increase": 0.1,
|
||||
"tracking_intersection_threshold": 0.6,
|
||||
"altitude": 400.0,
|
||||
"focal_length": 24.0,
|
||||
"sensor_width": 23.5,
|
||||
"paths": [video_short_path],
|
||||
}
|
||||
body = {}
|
||||
token = _make_jwt()
|
||||
|
||||
collected: list[tuple[float, dict]] = []
|
||||
|
||||
Reference in New Issue
Block a user