-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnnTest.html
More file actions
142 lines (124 loc) · 4.03 KB
/
Copy pathnnTest.html
File metadata and controls
142 lines (124 loc) · 4.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>MNIST Digits Simples</title>
<!-- script src="./node_modules/mnist/dist/mnist.js"></script-->
<script src="./lib/sketchpad.js?v1.1"></script>
<script src="./dist/build.js"></script>
<script>
console.log(window["nn"]);
console.log(window["imgUtil"]);
console.log(window["startWarp"]);
</script>
<script>
var warp = WarpFactory.forMainnet();
var deployedContracts = {
fc: 'Q1ga6CExJs-AARQi3mvtFiPcdZmXi_8e22QURdhrnug',
};
async function startWarpContact() {
console.log("Entered startWarpContact");
// create Wallet
const wallet = await arweave.wallets.generate();
walletAddress = await arweave.wallets.getAddress(wallet);
console.log(`Wallet address: ${walletAddress}`);
// Interacting with the contract
var contract = warp
.pst(deployedContracts.fc)
.connect(wallet);
console.log(`contract: ${contract}`);
}
async function runWarpFunction() {
const viewState = await contract.viewState({function: 'brainFn'});
return viewState.result;
}
</script>
<style>
body {
margin: 10px;
padding: 10px;
font-family:Arial;
background-color: #dafcfe;
}
#container {
display: flex;
justify-content: flex-start;
width: 100%;
}
#sketchpad {
border: 5px solid #077;
}
/* #thumbnail {
position: relative;
} */
#thumbnail {
border: 1px solid #077;
width: 28px;
height: 28px;
/* position: absolute; */
/* bottom: 0; */
}
#result {
font-size: 128pt; /* Размер шрифта в пунктах */
float: right;
width: 280px;
height: 280px;
// border: 5px solid #dafcfe;
text-align: center;
line-height: 280px;
/* padding-left: 80px; */
}
.image-box {
display: flex;
align-items: center;
justify-content: space-between;
left: 0;
right: 0;
}
#ethwarsaw-logo {
min-width: 200px;
width: 80%;
height:200px;
margin: 20px;
}
#warp-logo {
min-width: 200px;
margin: 20px;
width: 80%;
height:200px;
}
#arweave-logo {
min-width: 200px;
margin: 20px;
width: 80%;
height:200px;
}
</style>
</head>
<body>
<h1 style="overflow-wrap: break-word;">Recognizing hand-written digits from MNIST dataset with Brain.js. Neural Networks live example.
Running on Warp smart-contracts, built on smartweave</h1>
<p>
Draw a digit in the box below and click the "recognize" button.
</p>
<br/>
<div id="container">
<section style="justify-items: start; padding-right: 80px">
<canvas id="sketchpad" width="280" height="280">Sorry, your browser is not supported.</canvas>
<canvas id="thumbnail" width="28" height="28">Sorry, your browser is not supported.</canvas>
</section>
<div id="result"></div>
<section class="image-box">
<img id="ethwarsaw-logo" src="./public/ethwarsaw-logo.svg" alt="ETHWarsaw" width="100" height="100">
<img id="warp-logo" src="./public/warp-logo-full.svg" alt="WarpLogo" width="100" height="100">
<img id="arweave-logo" src="./public/arweave-logo.svg" alt="ArweaveLogo" width="100" height="100">
</section>
</div>
<button type="button" id="connect">WARP CONNECT</button>
<button type="button" id="sketchClearButton">Clear</button>
<button type="button" id="sketchRecogniseButton">Recognise</button>
<br/>
<br/>
<br/>
</body>
</html>