Lab-5 / preload_tiles.py
Teoman21's picture
feat: Implement mosaic generation pipeline with performance analysis
b68205e
#!/usr/bin/env python3
"""
Script to pre-load tiles for faster first-time mosaic generation.
"""
import time
from src.config import Config
from src.tiles import TileManager
def preload_tiles():
"""Pre-load tiles to cache them for faster subsequent use."""
print("πŸ”„ Pre-loading tiles for faster mosaic generation...")
print("This will download a small set of tiles from Hugging Face.")
# Create configuration with default settings
config = Config(
grid=32,
tile_size=32,
hf_limit=50 # Load 50 tiles for good variety
)
# Create tile manager - this will trigger the loading
start_time = time.time()
tile_manager = TileManager(config)
# Force tile loading by calling get_tile_count
tile_count = tile_manager.get_tile_count()
loading_time = time.time() - start_time
print(f"βœ… Successfully loaded {tile_count} tiles in {loading_time:.2f} seconds")
print("πŸŽ‰ Tiles are now cached! Mosaic generation will be much faster.")
print("\nYou can now run the app with:")
print(" python app.py")
if __name__ == "__main__":
preload_tiles()