Giter Club home page Giter Club logo

Comments (3)

syt123450 avatar syt123450 commented on June 14, 2024

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.

trile83 avatar trile83 commented on June 14, 2024

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.

syt123450 avatar syt123450 commented on June 14, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.