Spaces:
Sleeping
Sleeping
fix: data model, backend output
Browse files- main.py +0 -5
- services/pipeline.py +6 -1
main.py
CHANGED
|
@@ -17,11 +17,6 @@ import dagshub
|
|
| 17 |
from fastapi import FastAPI
|
| 18 |
|
| 19 |
|
| 20 |
-
# settings = AppConfig()
|
| 21 |
-
# if settings.dagshub_user_token:
|
| 22 |
-
# os.environ["DAGSHUB_USER_TOKEN"] = settings.dagshub_user_token
|
| 23 |
-
|
| 24 |
-
|
| 25 |
@asynccontextmanager
|
| 26 |
async def lifespan(app: FastAPI):
|
| 27 |
"""
|
|
|
|
| 17 |
from fastapi import FastAPI
|
| 18 |
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
@asynccontextmanager
|
| 21 |
async def lifespan(app: FastAPI):
|
| 22 |
"""
|
services/pipeline.py
CHANGED
|
@@ -8,6 +8,7 @@ from contracts.camera_metadata import DetectionMetadata
|
|
| 8 |
from contracts.camera_metadata import CameraMetadata
|
| 9 |
import cv2 as cv
|
| 10 |
import numpy as np
|
|
|
|
| 11 |
|
| 12 |
|
| 13 |
class ProcessingPipeline:
|
|
@@ -77,7 +78,11 @@ class ProcessingPipeline:
|
|
| 77 |
camera_id, safety_detection, depth_points, boxes_center_ratio
|
| 78 |
)
|
| 79 |
|
| 80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
# Even if the camera was disconnected, redis is still going to show its data, which is not accurate.
|
| 82 |
# Instead, we set expiry date for the camera data.
|
| 83 |
await self.redis.setex(
|
|
|
|
| 8 |
from contracts.camera_metadata import CameraMetadata
|
| 9 |
import cv2 as cv
|
| 10 |
import numpy as np
|
| 11 |
+
import json
|
| 12 |
|
| 13 |
|
| 14 |
class ProcessingPipeline:
|
|
|
|
| 78 |
camera_id, safety_detection, depth_points, boxes_center_ratio
|
| 79 |
)
|
| 80 |
|
| 81 |
+
# Note that this will generate text metadata.model_dump_json() don't use it here.
|
| 82 |
+
await self.redis.publish(
|
| 83 |
+
"dashboard_stream",
|
| 84 |
+
json.dumps({camera_id: metadata.model_dump(mode="json")}),
|
| 85 |
+
)
|
| 86 |
# Even if the camera was disconnected, redis is still going to show its data, which is not accurate.
|
| 87 |
# Instead, we set expiry date for the camera data.
|
| 88 |
await self.redis.setex(
|