From 0f394faa6189164fbddf9dea7cc558ac87568a72 Mon Sep 17 00:00:00 2001 From: Benjamin Loison Date: Wed, 3 Apr 2024 18:20:31 +0200 Subject: [PATCH] Multicores prototype --- datasets/raise/extract_noise.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/datasets/raise/extract_noise.py b/datasets/raise/extract_noise.py index 5bb0610..c8d4be1 100755 --- a/datasets/raise/extract_noise.py +++ b/datasets/raise/extract_noise.py @@ -6,18 +6,29 @@ import numpy as np from PIL import Image import os from tqdm import tqdm -import gzip +from multiprocessing import Pool imagesFolderPath = 'tif' -npArrayFolderPath = 'np' +''' for imageFileName in tqdm(os.listdir(imagesFolderPath)): - npArrayFilePath = f'{npArrayFolderPath}/{imageFileName}.npy.gz' + npArrayFilePath = f'mean.npy' if os.path.isfile(npArrayFilePath): continue imageFilePath = f'{imagesFolderPath}/{imageFileName}' imagePil = Image.open(imageFilePath) imageNpArray = img_as_float(np.array(imagePil)) imageNoiseNpArray = imageNpArray - denoise_tv_chambolle(imageNpArray, weight=0.2, channel_axis=-1) - with gzip.open(npArrayFilePath, 'wb') as f: + with open(npArrayFilePath, 'wb') as f: np.save(f, imageNoiseNpArray) +''' + +import time + +def treatImage(imageFilePath): + while True: + print(imageFilePath) + time.sleep(1) + +with Pool(22) as p: + p.map(treatImage, )