Skip to content

Commit

Permalink
Update 1.9.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mkhorin committed Dec 22, 2023
1 parent f4408c8 commit 8ac6ae3
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ docker-compose up -d server
## Typical installation

#### Install environment
- [Node.js](https://nodejs.org) (version 16)
- [Node.js](https://nodejs.org) (version 20)
- [MongoDB](https://www.mongodb.com/download-center/community) (version 5)

#### Linux
Expand Down
2 changes: 1 addition & 1 deletion dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16-alpine
FROM node:20-alpine

WORKDIR /app

Expand Down
2 changes: 1 addition & 1 deletion docs/js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jQuery('.navbar-target').append(`<div class="container">
label: 'Recognition digits',
ru: 'Распознавание цифр'
}];
const lang = document.documentElement.lang;
const {lang} = document.documentElement;
const result = [];
for (const item of items) {
if (item.header) {
Expand Down
4 changes: 2 additions & 2 deletions module/front/web/src/form/FormAttr.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ Front.FormDate = class FormDate extends Front.FormAttr {
}

onChangeDate (event) {
const date = event.date;
const format = this.picker.options().format;
const {date} = event;
const {format} = this.picker.options();
const value = date ? moment(moment(date).format(format), format) : '';
this.$value.val(value ? Jam.DateHelper.stringify(value, this.utc) : '');
if (!date) {
Expand Down
18 changes: 8 additions & 10 deletions module/front/web/src/misc/Drawing.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,21 +95,21 @@ Front.Drawing = class Drawing extends Front.Element {
exportData () {
const rect = this.getCroppingRect(this.context, this.canvas.width, this.canvas.height);
if (rect) {
const {height, width} = this.target;
const sourceRect = this.convertToSquare(rect);
const context = this.targetContext;
context.fillRect(0, 0, this.target.width, this.target.height);
context.drawImage(this.canvas, ...sourceRect, 2, 2, this.target.width - 4, this.target.height - 4);
const data = context.getImageData(0, 0, this.target.width, this.target.height);
context.fillRect(0, 0, width, height);
context.drawImage(this.canvas, ...sourceRect, 2, 2, width - 4, height - 4);
const data = context.getImageData(0, 0, width, height);
this.invert(data);
context.putImageData(data, 0, 0);
return this.getGrayscale(data);
}
}

getCroppingRect (context, width, height) {
let data = context.getImageData(0, 0, width, height).data;
let x1 = width, y1 = height;
let x2 = 0, y2 = 0, i = 0;
const {data} = context.getImageData(0, 0, width, height);
let x1 = width, y1 = height, x2 = 0, y2 = 0, i = 0;
for (let y = 0; y < height; ++y) {
for (let x = 0; x < width; ++x) {
if (data[i] !== 255 || data[i] !== data[i + 1] || data[i] !== data[i + 2]) {
Expand Down Expand Up @@ -144,18 +144,16 @@ Front.Drawing = class Drawing extends Front.Element {
return [x, y, w, h];
}

invert (imageData) {
const data = imageData.data;
invert ({data}) {
for (let i = 0; i < data.length; i += 4) {
data[i] = 255 - data[i]; // red
data[i + 1] = 255 - data[i + 1]; // green
data[i + 2] = 255 - data[i + 2]; // blue
}
}

getGrayscale (imageData) {
getGrayscale ({data}) {
const result = [];
const data = imageData.data;
for (let i = 0; i < data.length; i += 4) {
result.push(Math.round(data[i] * .299 + data[i + 1] * .587 + data[i + 2] * .114));
}
Expand Down
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
{
"name": "neural-net",
"version": "1.9.0",
"version": "1.9.1",
"description": "Train, test and operate neural networks to recognize handwritten digits",
"author": {
"name": "Maxim Khorin",
"email": "maksimovichu@gmail.com"
},
"license": "MIT",
"engines": {
"node": ">=16.20.1"
},
"repository": {
"type": "git",
"url": "https://github.com/mkhorin/neural-net.git"
Expand Down
2 changes: 1 addition & 1 deletion worker/convertImageSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const {workerData, parentPort} = require('worker_threads');
const fs = require('fs');
const sharp = require('sharp');
const AdmZip = require('adm-zip');
const file = workerData.file;
const {file} = workerData;

console.log(`Unzipping archive: ${file}`);

Expand Down

0 comments on commit 8ac6ae3

Please sign in to comment.