|
import os |
|
import pickle |
|
import imageio |
|
import matplotlib.pyplot as plt |
|
from qdhf_things import run_qdhf, many_pictures |
|
|
|
EXAMPLE_PROMPTS = [ |
|
'an image of a cat on the sofa', |
|
'an image of a bear in a national park', |
|
'a photo of an astronaut riding a horse on mars', |
|
'a drawing of a tree behind a fence', |
|
'a painting of a sunset over the ocean', |
|
'a sketch of a racoon sitting on a mushroom', |
|
'a picture of a dragon flying over a castle', |
|
'a photo of a robot playing the guitar', |
|
] |
|
|
|
if __name__ == '__main__': |
|
print('Hello! I am a script!') |
|
|
|
for i, example_prompt in enumerate(EXAMPLE_PROMPTS): |
|
|
|
images = [] |
|
|
|
|
|
for archive, plt in run_qdhf(example_prompt): |
|
|
|
temp_filename = f'./examples/temp_plot_{i}.png' |
|
plt.savefig(temp_filename) |
|
plt.close() |
|
|
|
|
|
images.append(imageio.imread(temp_filename)) |
|
os.remove(temp_filename) |
|
|
|
|
|
gif_filename = f'./examples/archive_{i}.gif' |
|
imageio.mimsave(gif_filename, images, duration=0.5) |
|
|
|
|
|
pickle.dump(archive, open(f'./examples/archive_{i}.pkl', 'wb')) |
|
|
|
|
|
plt = many_pictures(archive, example_prompt) |
|
plt.savefig(f'./examples/archive_pics_{i}.png') |
|
plt.close() |
|
|