Convert a .JPG image-file into a PyTorch Tensor

preview_player
Показать описание

.jpg? .png? images? imread? shape? resize? rgb2gray? matplotlib? pyplot? cmap? flatten?

A common application for neural networks (and PyTorch) is image analysis, where a neural network with a larger number of images is trained on specific patterns.

However, the first step in evaluating images is the conversion of e.g. the .jpg file into a tensor, which consists only of a structured collection of numbers.

Each individual pixel of the image is divided into its 3 color channels and assembled together with the position of the pixel into a tensor. To ensure that all tensors are always the same size (same number of inputs for the neural network), all images must first be scaled to a uniform size.

The assignment of the "results" to the (supervised) training of the neural network will be discussed in another tutorial.
Рекомендации по теме
Комментарии
Автор

Thanks for such a great, simplified tutorial 🙏

mabasadailycode
Автор

Bruuder, du hast mir echt den Arsch gerettet :D
Ich hatte das Problem, dass mein Tensor nur Nullwerte enthielt.
Ich versuche nämlich, Sonagramme in Tensoren umzuwandeln.
Bin durch dich drauf gekommen, dass er hauptsächlich weiße Pixel ließt, weil das Sonagramm in einem Koordinatensystem liegt
und dieses eine entsprechende Umrundung hat.
Nachdem ich das weggeschnitten hatte, kamen endlich verlässliche Werte für Pixel und Tensor.
In diesem Sinne also tausend Dank!

ishwaashdish
Автор

great tutorial one of its kind really.. but can i get the code from somewhere?

kunalbiswas