Skip to content

Commit

Permalink
predict: publish
Browse files Browse the repository at this point in the history
  • Loading branch information
koush committed Apr 27, 2023
1 parent ebc3a03 commit ffee1c5
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 30 deletions.
4 changes: 2 additions & 2 deletions plugins/coreml/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions plugins/coreml/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@
"type": "API",
"interfaces": [
"Settings",
"BufferConverter",
"ObjectDetection"
]
},
"devDependencies": {
"@scrypted/sdk": "file:../../sdk"
},
"version": "0.1.12"
"version": "0.1.13"
}
5 changes: 1 addition & 4 deletions plugins/coreml/src/coreml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,9 @@ def parse_label_contents(contents: str):
ret[row_number] = content.strip()
return ret


MIME_TYPE = 'x-scrypted-coreml/x-raw-image'

class CoreMLPlugin(PredictPlugin, scrypted_sdk.BufferConverter, scrypted_sdk.Settings):
def __init__(self, nativeId: str | None = None):
super().__init__(MIME_TYPE, nativeId=nativeId)
super().__init__(nativeId=nativeId)

labelsFile = self.downloadFile('https://raw.githubusercontent.com/koush/coreml-survival-guide/master/MobileNetV2%2BSSDLite/coco_labels.txt', 'coco_labels.txt')
modelFile = self.downloadFile('https://github.com/koush/coreml-survival-guide/raw/master/MobileNetV2%2BSSDLite/ObjectDetection/ObjectDetection/MobileNetV2_SSDLite.mlmodel', 'MobileNetV2_SSDLite.mlmodel')
Expand Down
4 changes: 2 additions & 2 deletions plugins/tensorflow-lite/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions plugins/tensorflow-lite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,11 @@
"type": "API",
"interfaces": [
"Settings",
"BufferConverter",
"ObjectDetection"
]
},
"devDependencies": {
"@scrypted/sdk": "file:../../sdk"
},
"version": "0.1.12"
"version": "0.1.13"
}
7 changes: 1 addition & 6 deletions plugins/tensorflow-lite/src/predict/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,9 @@ def __init__(self, id: int, score: float, bbox: Tuple[float, float, float, float
class PredictPlugin(DetectPlugin, scrypted_sdk.BufferConverter, scrypted_sdk.Settings):
labels: dict

def __init__(self, PLUGIN_MIME_TYPE: str, nativeId: str | None = None):
def __init__(self, nativeId: str | None = None):
super().__init__(nativeId=nativeId)

self.fromMimeType = PLUGIN_MIME_TYPE
self.toMimeType = scrypted_sdk.ScryptedMimeTypes.MediaObject.value

self.crop = False

# periodic restart because there seems to be leaks in tflite or coral API.
loop = asyncio.get_event_loop()
loop.call_later(4 * 60 * 60, lambda: self.requestRestart())
Expand Down
5 changes: 1 addition & 4 deletions plugins/tensorflow-lite/src/tflite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,9 @@ def parse_label_contents(contents: str):
ret[row_number] = content.strip()
return ret


MIME_TYPE = 'x-scrypted-tensorflow-lite/x-raw-image'

class TensorFlowLitePlugin(PredictPlugin, scrypted_sdk.BufferConverter, scrypted_sdk.Settings):
def __init__(self, nativeId: str | None = None):
super().__init__(MIME_TYPE, nativeId=nativeId)
super().__init__(nativeId=nativeId)

tfliteFile = self.downloadFile('https://raw.githubusercontent.com/google-coral/test_data/master/ssd_mobilenet_v2_coco_quant_postprocess.tflite', 'ssd_mobilenet_v2_coco_quant_postprocess.tflite')
edgetpuFile = self.downloadFile('https://raw.githubusercontent.com/google-coral/test_data/master/ssd_mobilenet_v2_coco_quant_postprocess_edgetpu.tflite', 'ssd_mobilenet_v2_coco_quant_postprocess_edgetpu.tflite')
Expand Down
4 changes: 2 additions & 2 deletions plugins/tensorflow/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions plugins/tensorflow/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@
"type": "API",
"interfaces": [
"Settings",
"BufferConverter",
"ObjectDetection"
]
},
"devDependencies": {
"@scrypted/sdk": "file:../../sdk"
},
"version": "0.1.12"
"version": "0.1.13"
}
5 changes: 1 addition & 4 deletions plugins/tensorflow/src/tf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,9 @@ def parse_label_contents(contents: str):
ret[row_number] = content.strip()
return ret


MIME_TYPE = 'x-scrypted-tensorflow/x-raw-image'

class TensorFlowPlugin(PredictPlugin, scrypted_sdk.BufferConverter, scrypted_sdk.Settings):
def __init__(self, nativeId: str | None = None):
super().__init__(MIME_TYPE, nativeId=nativeId)
super().__init__(nativeId=nativeId)

modelPath = os.path.join(os.environ['SCRYPTED_PLUGIN_VOLUME'], 'zip', 'unzipped', 'fs')
self.model = tf.saved_model.load(modelPath)
Expand Down

0 comments on commit ffee1c5

Please sign in to comment.