Download Time_test.py from friedeggy/Lab5.1: direct link, hf CLI and curl.
- Browser
- Download file 1.81 kB
-
https://huggingface.co/spaces/friedeggy/Lab5.1/resolve/main/Time_test.py
- Command line
-
hf download hf://spaces/friedeggy/Lab5.1/Time_test.py
-
curl -L -o Time_test.py https://huggingface.co/spaces/friedeggy/Lab5.1/resolve/main/Time_test.py
1.81 kB
| from PIL import Image | |
| import mosaic_generator as mg | |
| import time | |
| def run(): | |
| """ | |
| Runs the effient mosiac generator | |
| Returns: | |
| runtimes: List | |
| 2D list of runtimes for different mosiac generator parameters | |
| """ | |
| runtimes = [] | |
| for _ in range(0, 3): | |
| runtimes.append([]) | |
| path = "tiles" | |
| img256 = Image.open("test_images\\256x256.png") | |
| start = time.time() | |
| mg.create_mosaic(img256, path, (16,16)) | |
| end = time.time() | |
| runtimes[0].append(end - start) | |
| start = time.time() | |
| mg.create_mosaic(img256, path, (32,32)) | |
| end = time.time() | |
| runtimes[0].append(end - start) | |
| start = time.time() | |
| mg.create_mosaic(img256, path, (64,64)) | |
| end = time.time() | |
| runtimes[0].append(end - start) | |
| # 512 pixel square image | |
| img512 = Image.open("test_images\\512x512.png") | |
| start = time.time() | |
| mg.create_mosaic(img512, path, (16,16)) | |
| end = time.time() | |
| runtimes[1].append(end - start) | |
| start = time.time() | |
| mg.create_mosaic(img512, path, (32,32)) | |
| end = time.time() | |
| runtimes[1].append(end - start) | |
| start = time.time() | |
| mg.create_mosaic(img512, path, (64,64)) | |
| end = time.time() | |
| runtimes[1].append(end - start) | |
| # 1024 pixel square image | |
| img1024 = Image.open("test_images\\1024x1024.png") | |
| start = time.time() | |
| mg.create_mosaic(img1024, path, (16,16)) | |
| end = time.time() | |
| runtimes[2].append(end - start) | |
| start = time.time() | |
| mg.create_mosaic(img1024, path, (32,32)) | |
| end = time.time() | |
| runtimes[2].append(end - start) | |
| start = time.time() | |
| mg.create_mosaic(img1024, path, (64,64)) | |
| end = time.time() | |
| runtimes[2].append(end - start) | |
| print(runtimes) | |
| run() | |