-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
31 lines (24 loc) · 934 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import os
import random
from argparse import ArgumentParser
from PIL import Image
def get_random_image(image_directory):
images = [f for f in os.listdir(image_directory) if os.path.isfile(os.path.join(image_directory, f))]
return random.choice(images)
def open_image(image_path):
with Image.open(image_path) as img:
img.show()
def main():
parser = ArgumentParser(description="Generative-Al: Generate a random Al image.")
parser.add_argument("command", help="command to run. use generate to see generative Al in action")
args = parser.parse_args()
command = args.command
image_directory = 'img'
if command != "generate":
print(f"Error: Unknown command '{command}'. Use 'generate'")
return
random_image = get_random_image(image_directory)
image_path = os.path.join(image_directory, random_image)
open_image(image_path)
if __name__ == "__main__":
main()