mirror of
https://github.com/koush/scrypted.git
synced 2026-03-16 15:12:06 +00:00
ncnn: new models
This commit is contained in:
4
plugins/ncnn/package-lock.json
generated
4
plugins/ncnn/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@scrypted/ncnn",
|
||||
"version": "0.1.88",
|
||||
"version": "0.1.89",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@scrypted/ncnn",
|
||||
"version": "0.1.88",
|
||||
"version": "0.1.89",
|
||||
"devDependencies": {
|
||||
"@scrypted/sdk": "file:../../sdk"
|
||||
}
|
||||
|
||||
@@ -50,5 +50,5 @@
|
||||
"devDependencies": {
|
||||
"@scrypted/sdk": "file:../../sdk"
|
||||
},
|
||||
"version": "0.1.88"
|
||||
"version": "0.1.89"
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ from __future__ import annotations
|
||||
import ast
|
||||
import asyncio
|
||||
import concurrent.futures
|
||||
import os
|
||||
import re
|
||||
import traceback
|
||||
from typing import Any, List, Tuple
|
||||
@@ -32,14 +33,14 @@ prepareExecutor = concurrent.futures.ThreadPoolExecutor(1, "NCNN-Prepare")
|
||||
|
||||
availableModels = [
|
||||
"Default",
|
||||
"scrypted_yolov9c_relu_320",
|
||||
"scrypted_yolov9m_relu_320",
|
||||
"scrypted_yolov9s_relu_320",
|
||||
"scrypted_yolov9t_relu_320",
|
||||
"scrypted_yolov9c_320",
|
||||
"scrypted_yolov9m_320",
|
||||
"scrypted_yolov9s_320",
|
||||
"scrypted_yolov9t_320",
|
||||
"scrypted_yolov9c_relu_test",
|
||||
"scrypted_yolov9m_relu_test",
|
||||
"scrypted_yolov9s_relu_test",
|
||||
"scrypted_yolov9t_relu_test",
|
||||
"scrypted_yolov9c_relu",
|
||||
"scrypted_yolov9m_relu",
|
||||
"scrypted_yolov9s_relu",
|
||||
"scrypted_yolov9t_relu",
|
||||
]
|
||||
|
||||
|
||||
@@ -85,39 +86,18 @@ class NCNNPlugin(
|
||||
if model == "Default" or model not in availableModels:
|
||||
if model != "Default":
|
||||
self.storage.setItem("model", "Default")
|
||||
model = "scrypted_yolov9t_relu_320"
|
||||
self.scrypted_yolov10 = "scrypted_yolov10" in model
|
||||
self.scrypted_yolo_nas = "scrypted_yolo_nas" in model
|
||||
self.scrypted_yolo = "scrypted_yolo" in model
|
||||
self.scrypted_model = "scrypted" in model
|
||||
model_version = "v2"
|
||||
model = "scrypted_yolov9t_relu_test"
|
||||
self.modelName = model
|
||||
self.labels = {
|
||||
0: "person",
|
||||
1: "vehicle",
|
||||
2: "animal",
|
||||
}
|
||||
|
||||
print(f"model: {model}")
|
||||
|
||||
if self.scrypted_yolo:
|
||||
self.labels = {
|
||||
0: "person",
|
||||
1: "vehicle",
|
||||
2: "animal",
|
||||
}
|
||||
files = [
|
||||
f"{model}/best_converted.ncnn.bin",
|
||||
f"{model}/best_converted.ncnn.param",
|
||||
]
|
||||
|
||||
for f in files:
|
||||
p = self.downloadFile(
|
||||
f"https://github.com/koush/ncnn-models/raw/main/{f}",
|
||||
f"{model_version}/{f}",
|
||||
)
|
||||
if ".bin" in p:
|
||||
binFile = p
|
||||
if ".param" in p:
|
||||
paramFile = p
|
||||
else:
|
||||
raise Exception("Unknown model. Please reinstall.")
|
||||
|
||||
model_path = self.downloadHuggingFaceModelLocalFallback(model)
|
||||
bin_file = os.path.join(model_path, "best_converted.ncnn.bin")
|
||||
param_file = os.path.join(model_path, "best_converted.ncnn.param")
|
||||
|
||||
self.net = ncnn.Net()
|
||||
self.net.opt.use_vulkan_compute = True
|
||||
@@ -125,8 +105,8 @@ class NCNNPlugin(
|
||||
# self.net.opt.use_fp16_storage = False
|
||||
# self.net.opt.use_fp16_arithmetic = False
|
||||
|
||||
self.net.load_param(paramFile)
|
||||
self.net.load_model(binFile)
|
||||
self.net.load_param(param_file)
|
||||
self.net.load_model(bin_file)
|
||||
|
||||
self.input_name = self.net.input_names()[0]
|
||||
|
||||
@@ -246,10 +226,6 @@ class NCNNPlugin(
|
||||
ex.extract("out0", output_ncnn)
|
||||
|
||||
output_tensors = np.array(output_ncnn)
|
||||
if self.scrypted_yolov10:
|
||||
return yolo.parse_yolov10(output_tensors)
|
||||
if self.scrypted_yolo_nas:
|
||||
return yolo.parse_yolo_nas([output_tensors[1], output_tensors[0]])
|
||||
return yolo.parse_yolov9(output_tensors)
|
||||
|
||||
try:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import os
|
||||
|
||||
import numpy as np
|
||||
from PIL import Image
|
||||
@@ -22,29 +23,13 @@ class NCNNFaceRecognition(FaceRecognizeDetection):
|
||||
|
||||
def downloadModel(self, model: str):
|
||||
scrypted_yolov9 = "scrypted_yolov9" in model
|
||||
ncnnmodel = "best_converted" if scrypted_yolov9 else model
|
||||
model_version = "v1"
|
||||
files = [
|
||||
f"{model}/{ncnnmodel}.ncnn.bin",
|
||||
f"{model}/{ncnnmodel}.ncnn.param",
|
||||
]
|
||||
|
||||
for f in files:
|
||||
p = self.downloadFile(
|
||||
f"https://github.com/koush/ncnn-models/raw/main/{f}",
|
||||
f"{model_version}/{f}",
|
||||
)
|
||||
if ".bin" in p:
|
||||
binFile = p
|
||||
if ".param" in p:
|
||||
paramFile = p
|
||||
|
||||
ncnnmodel = "best_converted" if scrypted_yolov9 else "best"
|
||||
model_path = self.downloadHuggingFaceModelLocalFallback(model)
|
||||
binFile = os.path.join(model_path, f"{ncnnmodel}.ncnn.bin")
|
||||
paramFile = os.path.join(model_path, f"{ncnnmodel}.ncnn.param")
|
||||
|
||||
net = ncnn.Net()
|
||||
net.opt.use_vulkan_compute = True
|
||||
# net.opt.use_fp16_packed = False
|
||||
# net.opt.use_fp16_storage = False
|
||||
# net.opt.use_fp16_arithmetic = False
|
||||
|
||||
net.load_param(paramFile)
|
||||
net.load_model(binFile)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import os
|
||||
|
||||
import numpy as np
|
||||
|
||||
@@ -16,28 +17,12 @@ textRecognizePrepare, textRecognizePredict = async_infer.create_executors(
|
||||
|
||||
class NCNNTextRecognition(TextRecognition):
|
||||
def downloadModel(self, model: str):
|
||||
model_version = "v1"
|
||||
files = [
|
||||
f"{model}/{model}.ncnn.bin",
|
||||
f"{model}/{model}.ncnn.param",
|
||||
]
|
||||
|
||||
for f in files:
|
||||
p = self.downloadFile(
|
||||
f"https://github.com/koush/ncnn-models/raw/main/{f}",
|
||||
f"{model_version}/{f}",
|
||||
)
|
||||
if ".bin" in p:
|
||||
binFile = p
|
||||
if ".param" in p:
|
||||
paramFile = p
|
||||
|
||||
model_path = self.downloadHuggingFaceModelLocalFallback(model)
|
||||
binFile = os.path.join(model_path, f"{model}.ncnn.bin")
|
||||
paramFile = os.path.join(model_path, f"{model}.ncnn.param")
|
||||
|
||||
net = ncnn.Net()
|
||||
net.opt.use_vulkan_compute = True
|
||||
# net.opt.use_fp16_packed = False
|
||||
# net.opt.use_fp16_storage = False
|
||||
# net.opt.use_fp16_arithmetic = False
|
||||
|
||||
net.load_param(paramFile)
|
||||
net.load_model(binFile)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
ncnn==1.0.20241226
|
||||
ncnn==1.0.20260114
|
||||
Pillow==11.1.0
|
||||
opencv-python-headless==4.10.0.84
|
||||
huggingface-hub==1.5.0
|
||||
Reference in New Issue
Block a user