File size: 1,149 Bytes
b68205e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
32
33
34
35
36
37
38
39
#!/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()