Reputation: 23
So far I have been able to ''manually'' process images by replacing 'picture' in
photo = ''directory/picture.jpg''
for every image I'm processing.
This is effective, sure, but it's very slow.
any ideas?
The code i'm using:
from deepdreamer import model, load_image, recursive_optimize
import numpy as np
import PIL.Image
layer_tensor = ...
photo = "directory/picture.jpg"
img_result = load_image(filename='{}'.format(photo))
img_result = recursive_optimize(...)
img_result = np.clip(img_result, 0.0, 255.0)
img_result = img_result.astype(np.uint8)
result = PIL.Image.fromarray(img_result, mode='RGB')
result.save(photo)
Upvotes: 0
Views: 140
Reputation: 567
Assuming all image files are in the same folder/directory, you can:
Python Code:
from deepdreamer import model, load_image, recursive_optimize
import numpy as np
import PIL.Image
import os //for file management stuff
layer_tensor = ...
def imageProcess(aFile):
photo = "directory/{aFile}"
img_result = load_image(filename='{}'.format(photo))
img_result = recursive_optimize(...)
img_result = np.clip(img_result, 0.0, 255.0)
img_result = img_result.astype(np.uint8)
result = PIL.Image.fromarray(img_result, mode='RGB')
result.save(photo)
for filename in os.listdir('dirname'):
imageProcess(filename)
It'll be something like this. Let me know how that works, I didn't run the code.
Upvotes: 0