Created
February 12, 2021 18:09
-
-
Save kedevked/b70fb721026171dfadcca09473890e0e to your computer and use it in GitHub Desktop.
drawing rectangle using tensorflow.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<head> | |
<style> | |
body { | |
display: flex; | |
flex-direction: row; | |
justify-content: center; | |
align-items: center; | |
} | |
canvas { | |
width: 100vh; | |
position: absolute; | |
} | |
</style> | |
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@2.0.0/dist/tf.min.js"></script> | |
</head> | |
<body> | |
<script> | |
const tensor = tf.ones([30, 40, 3], 'int32').mul(255).cast('int32'); | |
tensor1 = tensor.pad([[135, 135], [180, 180], [0, 0]], 0) | |
const canvas1 = document.createElement('canvas'); | |
tf.browser.toPixels(tensor1, canvas1); | |
document.body.append(canvas1); | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment