model.names statt model.model.names (kein None-Attribut-Warnung)

Type-Checker sah model.model als evtl. None. YOLO bietet die Klassen-
namen direkt ueber model.names an (identischer Inhalt verifiziert).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-02 11:37:56 +02:00
parent 8ed9b4662a
commit 73bcd41b5d

4
app.py
View File

@@ -165,7 +165,7 @@ app.config["MAX_CONTENT_LENGTH"] = 200 * 1024 * 1024 # 200MB Upload-Limit
# Globales Modell fuer den Video-Upload-Pfad (per Request).
model = YOLO("yolo11s.pt")
names = model.model.names
names = model.names
VEHICLE_CLASSES = {"car", "truck", "bus", "motorcycle"}
ALLOWED_EXTENSIONS = {"mp4", "mov", "avi", "mkv"}
@@ -554,7 +554,7 @@ class WebcamGrabber:
def _ensure_model(self):
if self.model is None:
self.model = YOLO(WEBCAM_MODEL)
self.names = self.model.model.names
self.names = self.model.names
def _publish(self, jpeg: bytes):
with self.frame_cond: