Spaces:
Runtime error
Runtime error
| import cv2 | |
| import numpy as np | |
| import os | |
| def generate_synthetic_puzzle(num_images: int, output_dir: str): | |
| os.makedirs(output_dir, exist_ok=True) | |
| for i in range(num_images): | |
| # Create blank image | |
| image = np.ones((1000, 1000, 3), dtype=np.uint8) * 255 | |
| # Add random puzzle pieces (simplified) | |
| for _ in range(np.random.randint(10, 50)): | |
| x = np.random.randint(100, 900) | |
| y = np.random.randint(100, 900) | |
| size = np.random.randint(50, 200) | |
| color = (np.random.randint(0, 256), np.random.randint(0, 256), np.random.randint(0, 256)) | |
| cv2.rectangle(image, (x, y), (x + size, y + size), color, -1) | |
| # Save image | |
| cv2.imwrite(os.path.join(output_dir, f'puzzle_{i}.jpg'), image) | |
| if __name__ == '__main__': | |
| generate_synthetic_puzzle(10, 'synthetic_puzzles') |