Logo elodees  elodees

Une IA bien-veillante pour un monde meilleur













Seuls les caractères alphabétiques accentués ou non ainsi que l'espace sont acceptés

Logo IA




Débruitage d'image avec CNN





Pas encore de compte ?

Inscrivez-vous pour accéder à tous les contenus




Testé sous Anaconda et Python 3.7

import os
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.data as td
import torchvision as tv
from PIL import Image
import matplotlib.pyplot as plt
import time
 
dataset_root_dir = 'BSDS300/images'
 
class NoisyBSDSDataset(td.Dataset):
 
    def __init__(self, root_dir, mode='train', image_size=(180, 180), sigma=30):
        super(NoisyBSDSDataset, self).__init__()
        self.mode = mode
        self.image_size = image_size
        self.sigma = sigma
        self.images_dir = os.path.join(root_dir, mode)
        self.files = os.listdir(self.images_dir)
 
    def __len__(self):
        return len(self.files)
 
    def __repr__(self):
        return "NoisyBSDSDataset(mode={}, image_size={}, sigma={})". \
            format(self.mode, self.image_size, self.sigma)
 
    def __getitem__(self, idx):
        img_path = os.path.join(self.images_dir, self.files[idx])
        clean = Image.open(img_path).convert('RGB')   
        # random crop
        i = np.random.randint(clean.size[0] - self.image_size[0])
        j = np.random.randint(clean.size[1] - self.image_size[1])
 
        clean = clean.crop([i, j, i+self.image_size[0], j+self.image_size[1]])
        transform = tv.transforms.Compose([
            # convert it to a tensor
            tv.transforms.ToTensor(),
            # normalize it to the range [−1, 1]
            tv.transforms.Normalize((.5, .5, .5), (.5, .5, .5))
            ])
        clean = transform(clean)
 
        noisy = clean + 2 / 255 * self.sigma * torch.randn(clean.shape)
        return noisy, clean
 
def myimshow(image, ax=plt):
    image = image.to('cpu').numpy()
    image = np.moveaxis(image, [0, 1, 2], [2, 0, 1])
    image = (image + 1) / 2
    image[image < 0] = 0
    image[image > 1] = 1
    h = ax.imshow(image)
    ax.axis('off')
    return h
 
train_set = NoisyBSDSDataset(dataset_root_dir)
test_set = NoisyBSDSDataset(dataset_root_dir, mode='test', image_size=(320, 320))
 
input_path = (r'BSDS300/images/test')
 
cpt = 0
 
for root, dirs, files in os.walk(input_path):
    for filename in files:
        x = test_set[cpt]
        fig, axes = plt.subplots(ncols=2)
        myimshow(x[0], ax=axes[0])
        axes[0].set_title('Noisy')
        myimshow(x[1], ax=axes[1])
        axes[1].set_title('Clean')
        # print(f'image size is {x[0].shape}.')
        cpt += 1
 


Image-Denoising-with-Multi-Column-Dilated-CNNs - GitHub



Tensorflow playground

Tensorflow playground

Tensorflow playground

Tensorflow playground

Tensorflow playground

Tensorflow playground

Tensorflow playground

Tensorflow playground

Tensorflow playground




Réseau de neurones à convolution


Apprentissage profond

Apprentissage automatique












Bienvenu, je m’appelle Eric Soupet et je suis l'administrateur du site elodees.com. elodees.com est un état de l'art de l'Intelligence Artificielle et se veut collaboratif, vous pouvez dès à présent proposer du contenu tels que des articles, des événements, des tutoriels, ... alors n'hésitez pas !

Crédit des images de la plate-forme : Pixabay - Pixabay License | Pexels - Pexels License