| #!/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() | |