master
关凯 2023-09-14 21:38:16 +08:00
parent c4722938a1
commit aa62056ec8
13 changed files with 3304 additions and 0 deletions

View File

@ -0,0 +1,6 @@
api:
#启动api编写功能,由于api开发是会存在注入的风险.只建议在开发环境内开启,生成环境上建议关闭关闭此功能.
enabled: false
#是否启动api加密 数据库和网络传输都会都会以加密方式
encrypt:
enable: true

View File

@ -0,0 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1694571560836" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2169" width="16" height="16" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M180.736 248.832L0 776.448h93.696l43.52-132.608h181.76l43.008 132.608h93.696l-179.2-527.616z m-16.128 311.552l63.488-204.8 62.976 204.8zM804.096 289.792c-32-25.6-82.944-39.936-151.552-39.936h-122.368v526.592h86.016V588.8h51.2c121.088 0 185.088-58.88 185.088-169.984 1.024-58.624-15.616-102.144-48.384-129.024z m-38.656 130.56c0 34.048-10.752 79.104-102.4 79.104h-46.848v-161.28h51.2c66.816 0.256 98.048 26.368 98.048 82.176zM937.984 249.856H1024v526.592h-86.016z" p-id="2170" fill="#bfbfbf"></path></svg>

After

Width:  |  Height:  |  Size: 835 B

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,403 @@
layer {
name: "data"
type: "Input"
top: "data"
input_param {
shape {
dim: 1
dim: 1
dim: 224
dim: 224
}
}
}
layer {
name: "conv0"
type: "Convolution"
bottom: "data"
top: "conv0"
param {
lr_mult: 1.0
decay_mult: 1.0
}
param {
lr_mult: 1.0
decay_mult: 0.0
}
convolution_param {
num_output: 32
bias_term: true
pad: 1
kernel_size: 3
group: 1
stride: 1
weight_filler {
type: "msra"
}
}
}
layer {
name: "conv0/lrelu"
type: "ReLU"
bottom: "conv0"
top: "conv0"
relu_param {
negative_slope: 0.05000000074505806
}
}
layer {
name: "db1/reduce"
type: "Convolution"
bottom: "conv0"
top: "db1/reduce"
param {
lr_mult: 1.0
decay_mult: 1.0
}
param {
lr_mult: 1.0
decay_mult: 0.0
}
convolution_param {
num_output: 8
bias_term: true
pad: 0
kernel_size: 1
group: 1
stride: 1
weight_filler {
type: "msra"
}
}
}
layer {
name: "db1/reduce/lrelu"
type: "ReLU"
bottom: "db1/reduce"
top: "db1/reduce"
relu_param {
negative_slope: 0.05000000074505806
}
}
layer {
name: "db1/3x3"
type: "Convolution"
bottom: "db1/reduce"
top: "db1/3x3"
param {
lr_mult: 1.0
decay_mult: 1.0
}
param {
lr_mult: 1.0
decay_mult: 0.0
}
convolution_param {
num_output: 8
bias_term: true
pad: 1
kernel_size: 3
group: 8
stride: 1
weight_filler {
type: "msra"
}
}
}
layer {
name: "db1/3x3/lrelu"
type: "ReLU"
bottom: "db1/3x3"
top: "db1/3x3"
relu_param {
negative_slope: 0.05000000074505806
}
}
layer {
name: "db1/1x1"
type: "Convolution"
bottom: "db1/3x3"
top: "db1/1x1"
param {
lr_mult: 1.0
decay_mult: 1.0
}
param {
lr_mult: 1.0
decay_mult: 0.0
}
convolution_param {
num_output: 32
bias_term: true
pad: 0
kernel_size: 1
group: 1
stride: 1
weight_filler {
type: "msra"
}
}
}
layer {
name: "db1/1x1/lrelu"
type: "ReLU"
bottom: "db1/1x1"
top: "db1/1x1"
relu_param {
negative_slope: 0.05000000074505806
}
}
layer {
name: "db1/concat"
type: "Concat"
bottom: "conv0"
bottom: "db1/1x1"
top: "db1/concat"
concat_param {
axis: 1
}
}
layer {
name: "db2/reduce"
type: "Convolution"
bottom: "db1/concat"
top: "db2/reduce"
param {
lr_mult: 1.0
decay_mult: 1.0
}
param {
lr_mult: 1.0
decay_mult: 0.0
}
convolution_param {
num_output: 8
bias_term: true
pad: 0
kernel_size: 1
group: 1
stride: 1
weight_filler {
type: "msra"
}
}
}
layer {
name: "db2/reduce/lrelu"
type: "ReLU"
bottom: "db2/reduce"
top: "db2/reduce"
relu_param {
negative_slope: 0.05000000074505806
}
}
layer {
name: "db2/3x3"
type: "Convolution"
bottom: "db2/reduce"
top: "db2/3x3"
param {
lr_mult: 1.0
decay_mult: 1.0
}
param {
lr_mult: 1.0
decay_mult: 0.0
}
convolution_param {
num_output: 8
bias_term: true
pad: 1
kernel_size: 3
group: 8
stride: 1
weight_filler {
type: "msra"
}
}
}
layer {
name: "db2/3x3/lrelu"
type: "ReLU"
bottom: "db2/3x3"
top: "db2/3x3"
relu_param {
negative_slope: 0.05000000074505806
}
}
layer {
name: "db2/1x1"
type: "Convolution"
bottom: "db2/3x3"
top: "db2/1x1"
param {
lr_mult: 1.0
decay_mult: 1.0
}
param {
lr_mult: 1.0
decay_mult: 0.0
}
convolution_param {
num_output: 32
bias_term: true
pad: 0
kernel_size: 1
group: 1
stride: 1
weight_filler {
type: "msra"
}
}
}
layer {
name: "db2/1x1/lrelu"
type: "ReLU"
bottom: "db2/1x1"
top: "db2/1x1"
relu_param {
negative_slope: 0.05000000074505806
}
}
layer {
name: "db2/concat"
type: "Concat"
bottom: "db1/concat"
bottom: "db2/1x1"
top: "db2/concat"
concat_param {
axis: 1
}
}
layer {
name: "upsample/reduce"
type: "Convolution"
bottom: "db2/concat"
top: "upsample/reduce"
param {
lr_mult: 1.0
decay_mult: 1.0
}
param {
lr_mult: 1.0
decay_mult: 0.0
}
convolution_param {
num_output: 32
bias_term: true
pad: 0
kernel_size: 1
group: 1
stride: 1
weight_filler {
type: "msra"
}
}
}
layer {
name: "upsample/reduce/lrelu"
type: "ReLU"
bottom: "upsample/reduce"
top: "upsample/reduce"
relu_param {
negative_slope: 0.05000000074505806
}
}
layer {
name: "upsample/deconv"
type: "Deconvolution"
bottom: "upsample/reduce"
top: "upsample/deconv"
param {
lr_mult: 1.0
decay_mult: 1.0
}
param {
lr_mult: 1.0
decay_mult: 0.0
}
convolution_param {
num_output: 32
bias_term: true
pad: 1
kernel_size: 3
group: 32
stride: 2
weight_filler {
type: "msra"
}
}
}
layer {
name: "upsample/lrelu"
type: "ReLU"
bottom: "upsample/deconv"
top: "upsample/deconv"
relu_param {
negative_slope: 0.05000000074505806
}
}
layer {
name: "upsample/rec"
type: "Convolution"
bottom: "upsample/deconv"
top: "upsample/rec"
param {
lr_mult: 1.0
decay_mult: 1.0
}
param {
lr_mult: 1.0
decay_mult: 0.0
}
convolution_param {
num_output: 1
bias_term: true
pad: 0
kernel_size: 1
group: 1
stride: 1
weight_filler {
type: "msra"
}
}
}
layer {
name: "nearest"
type: "Deconvolution"
bottom: "data"
top: "nearest"
param {
lr_mult: 0.0
decay_mult: 0.0
}
convolution_param {
num_output: 1
bias_term: false
pad: 0
kernel_size: 2
group: 1
stride: 2
weight_filler {
type: "constant"
value: 1.0
}
}
}
layer {
name: "Crop1"
type: "Crop"
bottom: "nearest"
bottom: "upsample/rec"
top: "Crop1"
}
layer {
name: "fc"
type: "Eltwise"
bottom: "Crop1"
bottom: "upsample/rec"
top: "fc"
eltwise_param {
operation: SUM
}
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,125 @@
function Utils(errorOutputId) {
this.errorOutput = document.getElementById(errorOutputId);
this.loadScript = function (url) {
return new Promise((resolve, reject) => {
let script = document.createElement("script");
script.setAttribute("async", "");
script.setAttribute("type", "text/javascript");
script.setAttribute("id", "opencvjs");
script.addEventListener("load", async () => {
if (cv.getBuildInformation) {
console.log(cv.getBuildInformation());
resolve();
} else {
// WASM
if (cv instanceof Promise) {
cv = await cv;
console.log(cv.getBuildInformation());
resolve();
} else {
cv["onRuntimeInitialized"] = () => {
console.log(cv.getBuildInformation());
resolve();
};
}
}
});
script.addEventListener("error", () => {
reject();
});
script.src = url;
let node = document.getElementsByTagName("script")[0];
node.parentNode.insertBefore(script, node);
});
};
/**
* 请求二维码训练模型文件
*/
this.fetchModelsData = async function (name) {
// const response = await fetch(`https://static.xxxx.com/common/opencv/models/${name}`, {
const response = await fetch(`./models/${name}`, {
method: "GET",
});
const data = await response.arrayBuffer();
return new Uint8Array(data);
};
/**
* 加载图片到canvas
* 发票的二维码基本都在左上角
* 为提高效率只截取出图片二维码的左上角区域放入canvas
* @param {*} url
* @param {*} cavansId
*/
this.loadImageToCanvas = function (url, cavansId) {
let canvas = document.getElementById(cavansId);
let ctx = canvas.getContext("2d");
let img = new Image();
img.crossOrigin = "anonymous";
img.onload = function () {
const { width, height } = img;
const isVertical = width < height;
// const crossNum = isVertical ? 3 : 4;
// const verticalNum = isVertical ? 4 : 3;
// canvas.width = width / crossNum;
// canvas.height = height / verticalNum;
// ctx.drawImage(img, isVertical ? width * (2 / 3) : 0, 0, width, height, 0, 0, width, height);
canvas.width = width
canvas.height = height;
ctx.drawImage(img, 0, 0, width, height, 0, 0, width, height);
};
img.src = url;
};
/**
* canvas转图片
*/
this.imagedataToImage = function (imagedata) {
const canvas = document.createElement("canvas");
const ctx = canvas.getContext("2d");
canvas.width = imagedata.width;
canvas.height = imagedata.height;
ctx.putImageData(imagedata, 0, 0);
return new Promise((resolve) => {
const img = new Image();
img.src = canvas.toDataURL();
img.onload = () => {
resolve(img);
};
});
};
/**
* 拆分图片坐标
* @param {*} width 图片宽
* @param {*} height 图片高
*
* @returns 坐标数组 [x,y,width,height][]
*/
this.segmentationImageCoordinates = function (width, height) {
const isVertical = width < height;
const crossNum = isVertical ? 3 : 5;
const verticalNum = isVertical ? 5 : 3;
const blockWidth = width / crossNum;
const blockHeight = height / verticalNum;
const coordinates = [];
for (let y = 0; y < verticalNum; y++) {
for (let x = 0; x < crossNum; x++) {
const cx = x * blockWidth;
const cy = y * blockHeight;
coordinates.push([cx, cy, blockWidth, blockHeight]);
}
}
return coordinates;
};
}

File diff suppressed because one or more lines are too long