123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- /*
- * MIT License
- *
- * Copyright (c) 2019 Alexey Edelev <semlanik@gmail.com>
- *
- * This file is part of NeuralNetwork project https://git.semlanik.org/semlanik/NeuralNetwork
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this
- * software and associated documentation files (the "Software"), to deal in the Software
- * without restriction, including without limitation the rights to use, copy, modify,
- * merge, publish, distribute, sublicense, and/or sell copies of the Software, and
- * to permit persons to whom the Software is furnished to do so, subject to the following
- * conditions:
- *
- * The above copyright notice and this permission notice shall be included in all copies
- * or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
- * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
- * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
- import QtQuick 2.11
- import QtQuick.Window 2.11
- import QtQuick.Controls 1.4
- import QtQuick.Dialogs 1.2
- ApplicationWindow {
- id: root
- visible: true
- width: 1120
- height: 560
- maximumWidth: 1120
- maximumHeight: 560
- minimumWidth: 1120
- minimumHeight: 560
- property int tileSize: 20
- property int tileCount: 28
- property color resetColor: "#333333"
- MouseArea {
- id: drawingArea
- width: tileCount*tileSize
- height: tileCount*tileSize
- Repeater {
- model: 784
- Rectangle {
- id: tile
- width: tileSize
- height: tileSize
- color: resetColor
- x: tileSize*(model.index%tileCount)
- y: tileSize*Math.floor(model.index/tileCount)
- Connections {
- target: drawingArea
- onPositionChanged: {
- var centerX = tile.x + tile.width/2
- var centerY = tile.y + tile.height/2
- var diffX = mouse.x - centerX
- var diffY = mouse.y - centerY
- var dense = Math.sqrt(diffX * diffX + diffY * diffY)
- if (dense < tileSize*1.5) {
- var newColor = color.r + (tileSize*1.5 - dense)/tileSize*1.5
- var newValue = newColor - 0.2
- if (newColor > 1.0) {
- newColor = 1.0
- newValue = 1.0
- }
- tile.color = Qt.rgba(newColor, newColor, newColor, 1.0)
- hwengine.updateValue(model.index, newValue)
- }
- }
- }
- Connections {
- target: clearButton
- onClicked: {
- tile.color = resetColor
- hwengine.updateValue(model.index, 0.0)
- }
- }
- }
- }
- }
- Column {
- id: controls
- anchors.left: drawingArea.right
- anchors.top: parent.top
- anchors.margins: 10
- spacing: 10
- Text {
- text: "Select neural network data"
- }
- Row {
- TextField {
- id: pathToNeuralNetwork
- enabled: false
- width: 300
- }
- Button {
- id: browseButton
- text: "Browse"
- onClicked: {
- neuralNetworkImport.open()
- }
- }
- Button {
- id: uploadButton
- text: "Upload"
- onClicked: {
- hwengine.setNeuralNetworkData(pathToNeuralNetwork.text)
- }
- }
- }
- Button {
- id: tainButton
- text: "Re-run trainig"
- onClicked: {
- hwengine.retrain()
- }
- }
- Button {
- id: clearButton
- text: "Clear"
- }
- Button {
- id: recognizeButton
- text: "Recognize"
- onClicked: {
- hwengine.recognize()
- }
- }
- }
- Text {
- id: result
- anchors.top: controls.bottom
- anchors.topMargin: 100
- anchors.horizontalCenter: controls.horizontalCenter
- color: "#003b6f" //Tardis blue :)
- font.pixelSize: 40
- text: hwengine.result
- }
- FileDialog {
- id: neuralNetworkImport
- selectMultiple: false
- selectFolder: false
- nameFilters: ["*.nnd"]
- onAccepted: {
- pathToNeuralNetwork.text = neuralNetworkImport.fileUrl
- }
- }
- }
|