mirror of
https://github.com/koush/scrypted.git
synced 2026-03-04 10:23:18 +00:00
tensorflow: publish desktop variant
This commit is contained in:
@@ -5,7 +5,6 @@ from PIL import Image
|
||||
import re
|
||||
import scrypted_sdk
|
||||
from typing import Any, List, Tuple, Mapping
|
||||
from gi.repository import Gst
|
||||
import asyncio
|
||||
import time
|
||||
import sys
|
||||
@@ -16,6 +15,11 @@ from collections import namedtuple
|
||||
from .sort_oh import tracker
|
||||
import numpy as np
|
||||
|
||||
try:
|
||||
from gi.repository import Gst
|
||||
except:
|
||||
pass
|
||||
|
||||
Rectangle = namedtuple('Rectangle', 'xmin ymin xmax ymax')
|
||||
|
||||
def intersect_area(a: Rectangle, b: Rectangle): # returns None if rectangles don't intersect
|
||||
@@ -252,7 +256,7 @@ class PredictPlugin(DetectPlugin, scrypted_sdk.BufferConverter, scrypted_sdk.Set
|
||||
(w, h) = self.get_input_size()
|
||||
(iw, ih) = image.size
|
||||
|
||||
if not detection_session.tracker:
|
||||
if detection_session and not detection_session.tracker:
|
||||
t = self.trackers.get(detection_session.id)
|
||||
if not t:
|
||||
t = tracker.Sort_OH(scene=np.array([iw, ih]))
|
||||
@@ -340,9 +344,11 @@ class PredictPlugin(DetectPlugin, scrypted_sdk.BufferConverter, scrypted_sdk.Set
|
||||
|
||||
ret1 = self.detect_once(first, settings, src_size, cvss1)
|
||||
first.close()
|
||||
detection_session.processed = detection_session.processed + 1
|
||||
if detection_session:
|
||||
detection_session.processed = detection_session.processed + 1
|
||||
ret2 = self.detect_once(second, settings, src_size, cvss2)
|
||||
detection_session.processed = detection_session.processed + 1
|
||||
if detection_session:
|
||||
detection_session.processed = detection_session.processed + 1
|
||||
second.close()
|
||||
|
||||
ret = ret1
|
||||
@@ -379,7 +385,7 @@ class PredictPlugin(DetectPlugin, scrypted_sdk.BufferConverter, scrypted_sdk.Set
|
||||
|
||||
ret['detections'] = detections
|
||||
|
||||
if not multipass_crop:
|
||||
if not multipass_crop and detection_session:
|
||||
sort_input = []
|
||||
for d in ret['detections']:
|
||||
r: ObjectDetectionResult = d
|
||||
|
||||
Reference in New Issue
Block a user