Multicores prototype

This commit is contained in:
Benjamin Loison 2024-04-03 18:20:31 +02:00
parent faed1e33e8
commit 0f394faa61
No known key found for this signature in database

View File

@ -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, )