Comments (3)
Hi @trile83 , the .json data is the same as the prediction data in python, just in .json format.
I use the following script to generate input data from .jpg image (make sure resize input image to 416 * 416 before applying the following script):
<canvas id="container" width="416" height="416"></canvas>
<script>
var context = document.getElementById('container').getContext("2d");
var img = new Image();
img.onload = function () {
context.drawImage(img, 0, 0);
let dataArray = context.getImageData(0, 0, 416, 416).data;
let array = [];
for (let i = 0; i < dataArray.length; i++) {
if (i % 4 !== 3) {
array.push((dataArray[i] / 255).toFixed(4));
}
}
console.log(array.toString());
};
img.src = "PATH/TO/IMAGE/predict_image.jpg";
</script>
If you have already prepared a dataset in python, you can reproduce the above function in Python to generate the JSON format input data .
from tensorspace.
Thank you so much for your help. I was able to use my image in the model using the script to process the image. However, I am new to python and I hope you can help me understand the function in python. I am planning to process an array of image and put into the model.
from tensorspace.
Hi @trile83 , for YOLOv2-tiny demo, each JSON data is an array [R, G, B, R, G, B ....., R, G, B], the array length is 3 * 416 * 416
. To reproduce it in Python, get out RGB of each point (416 * 416 in total) from input image, normalize the RGB value to 0-1, and then generate JSON array.
As you have an array of images, you can apply this strategy to images one by one, and generate a folder of JSON files to be the input data of your model, or generate a matrix:
[
[R, G, B, R, G, B ....., R, G, B],
[R, G, B, R, G, B ....., R, G, B],
...
[R, G, B, R, G, B ....., R, G, B]
]
To fully understand how YOLO pre-process input data and post-process network result, YOLO website may help.
from tensorspace.
Related Issues (20)
- [Question]: Loading Keras models into appropriate TSP layers automatically HOT 2
- TensorSpace-Converter documentation in Website
- Make sure trackballcontrol work when container moves
- Demo - add TensorSpace to tfjs-vis HOT 1
- Automatically inject layer metrics if there is a pre-trained model
- Update preprocess docs with new preprocess pipeline
- ImportError: cannot import name 'convert_to_constants' HOT 3
- Expose Three Scene
- Angular Support !
- How will I insert our own picture? HOT 2
- Layers data
- Render Initial Model Viz Horizontally
- This is probably not a problem with npm. There is likely additional logging output above. HOT 1
- Use with model trained in TFJS? HOT 2
- How to construct topology of the TensorSpace model if I have many self-defined layers in my keras model? HOT 2
- "neural-network" GitHub Topic on the repository is spelled incorrectly
- Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'setShape')
- May I ask if this project is still being maintained?
- 无法抓取模型
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tensorspace.