Lädt...


🔧 RandomHorizontalFlip in PyTorch


Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to

Buy Me a Coffee

*My post explains OxfordIIITPet().

RandomHorizontalFlip() can flip zero or more images horizontally as shown below:

*Memos:

  • The 1st argument for initialization is p(Optional-Default:0.5-Type:float). *It's the probability which each image is flipped. *It's the probability which each image is flipped.
  • The 1st argument is img(Required-Type:PIL Image or tensor, tuple or list of int): *Memos:
    • It must be 2D.
    • Don't use img=.
  • PIL Image or Tensor
  • v2 is recommended to use according to V1 or V2? Which one should I use?.
from torchvision.datasets import OxfordIIITPet
from torchvision.transforms import v2

v2.RandomHorizontalFlip
# torchvision.transforms.v2._geometry.RandomHorizontalFlip

v2.RandomHorizontalFlip()
# RandomHorizontalFlip(p=0.5)

v2.RandomHorizontalFlip().p
# 0.5

origin_data = OxfordIIITPet(
    root="data",
    transform=None
)

trans100_data = OxfordIIITPet(
    root="data",
    transform=v2.RandomHorizontalFlip(p=1.0)
)

trans50_data = OxfordIIITPet(
    root="data",
    transform=v2.RandomHorizontalFlip(p=0.5)
)

import matplotlib.pyplot as plt

def show_images(data, main_title=None):
    plt.figure(figsize=(10, 5))
    plt.suptitle(t=main_title, y=0.8, fontsize=14)
    for i, (im, _) in zip(range(1, 6), data):
        plt.subplot(1, 5, i)
        plt.imshow(X=im)
        plt.xticks(ticks=[])
        plt.yticks(ticks=[])
    plt.tight_layout()
    plt.show()

show_images(data=origin_data, main_title="origin_data")
show_images(data=trans100_data, main_title="trans100_data")
show_images(data=trans50_data, main_title="trans50_data")

Image description

Image description

Image description

from torchvision.datasets import OxfordIIITPet
from torchvision.transforms import v2

my_data = OxfordIIITPet(
    root="data",
    transform=None
)

import matplotlib.pyplot as plt

def show_images(data, main_title=None, prob=0.0):
    plt.figure(figsize=(10, 5))
    plt.suptitle(t=main_title, y=0.8, fontsize=14)
    for i, (im, _) in zip(range(1, 6), data):
        plt.subplot(1, 5, i)
        rhf = v2.RandomHorizontalFlip(p=prob)
        plt.imshow(X=rhf(im))
        plt.xticks(ticks=[])
        plt.yticks(ticks=[])
    plt.tight_layout()
    plt.show()

show_images(data=my_data, main_title="origin_data")
show_images(data=my_data, main_title="trans100_data", prob=1.0)
show_images(data=my_data, main_title="trans50_data", prob=0.5)

Image description

Image description

Image description

...

🔧 RandomHorizontalFlip in PyTorch


📈 46.62 Punkte
🔧 Programmierung

🔧 RandomHorizontalFlip in PyTorch


📈 46.62 Punkte
🔧 Programmierung

🔧 PyTorch Day 02: PyTorch Tensors Basics


📈 23.86 Punkte
🔧 Programmierung

🔧 PyTorch Day 02: PyTorch Tensors Basics


📈 23.86 Punkte
🔧 Programmierung

📰 PyTorch Introduces torchcodec: A Machine Learning Library for Decoding Videos into PyTorch Tensors


📈 23.86 Punkte
🔧 AI Nachrichten

📰 Pytorch: Microsoft startet neuen Azure-Service Pytorch Enterprise


📈 23.86 Punkte
📰 IT Nachrichten

📰 PyTorch Lightning 1.0: PyTorch, nur schneller und flexibler


📈 23.86 Punkte
📰 IT Nachrichten

🔧 PyTorch on Azure: Full support for PyTorch 1.2


📈 23.86 Punkte
🔧 Programmierung

🔧 Learn You a PyTorch! (aka Introduction Into PyTorch)


📈 23.86 Punkte
🔧 Programmierung

🐧 Stawinski: How We Executed a Critical Supply Chain Attack on PyTorch


📈 11.93 Punkte
🐧 Linux Tipps

📰 Building an Image Classifier with a Single-Layer Neural Network in PyTorch


📈 11.93 Punkte
🔧 AI Nachrichten

🎥 Office Space, Lockbit, 380 volts in Manilla, PyTorch, & Non-Binary RAM - SWN #264


📈 11.93 Punkte
🎥 IT Security Video

🔧 RandomCrop in PyTorch (1)


📈 11.93 Punkte
🔧 Programmierung

🎥 A PyTorch and OPEA based AI Audio Avatar Chatbot | Tech Talk | Innovation Selects


📈 11.93 Punkte
🎥 Video | Youtube

🔧 index_select() in PyTorch


📈 11.93 Punkte
🔧 Programmierung

🔧 atleast_3d in PyTorch


📈 11.93 Punkte
🔧 Programmierung

🔧 Build a Stable Diffusion VAE From Scratch using Pytorch


📈 11.93 Punkte
🔧 Programmierung

🔧 BatchNorm2d() in PyTorch


📈 11.93 Punkte
🔧 Programmierung

🔧 ReLU() and LeakyReLU() in PyTorch


📈 11.93 Punkte
🔧 Programmierung

🔧 isinf(), isposinf() and isneginf() in PyTorch


📈 11.93 Punkte
🔧 Programmierung

🔧 randn() and randn_like() in PyTorch


📈 11.93 Punkte
🔧 Programmierung

📰 Microsoft adds enterprise support for PyTorch AI on Azure


📈 11.93 Punkte
📰 IT Nachrichten

📰 Nvidia veröffentlicht Werkzeug zum Mixed-Precision-Training in PyTorch


📈 11.93 Punkte
📰 IT Nachrichten

🔧 tile() in PyTorch


📈 11.93 Punkte
🔧 Programmierung

🔧 sum(), prod() and cartesian_prod() in PyTorch


📈 11.93 Punkte
🔧 Programmierung

📰 Scale LLMs with PyTorch 2.0 FSDP on Amazon EKS – Part 2


📈 11.93 Punkte
🔧 AI Nachrichten

📰 PyTorch Introduction —Tensors and Tensor Calculations


📈 11.93 Punkte
🔧 AI Nachrichten

📰 Image Classification with PyTorch and SHAP: Can you Trust an Automated Car?


📈 11.93 Punkte
🔧 AI Nachrichten

📰 Create Amazon SageMaker models using the PyTorch Model Zoo


📈 11.93 Punkte
🔧 AI Nachrichten

🔧 RandomAffine in PyTorch (1)


📈 11.93 Punkte
🔧 Programmierung

🔧 PyTorch Day 03: Tensor Operations


📈 11.93 Punkte
🔧 Programmierung

🔧 isclose and equal in PyTorch


📈 11.93 Punkte
🔧 Programmierung

🔧 Layers in PyTorch (2)


📈 11.93 Punkte
🔧 Programmierung

🔧 CocoDetection in PyTorch (1)


📈 11.93 Punkte
🔧 Programmierung

matomo