Test basic GitBase functionality.
()
| 61 | |
| 62 | |
| 63 | def test_basic_functionality(): |
| 64 | """Test basic GitBase functionality.""" |
| 65 | print("=" * 60) |
| 66 | print("TESTING BASIC GITBASE FUNCTIONALITY") |
| 67 | print("=" * 60) |
| 68 | |
| 69 | test_images = create_test_images() |
| 70 | |
| 71 | # Test with CPU first for compatibility |
| 72 | print("\n--- Testing CPU Implementation ---") |
| 73 | captioner_cpu = GitBaseCaptioner(dtype=torch.float32, device="cpu", use_compile=False, use_channels_last=False) |
| 74 | |
| 75 | for name, image in list(test_images.items())[:2]: # Test first 2 images |
| 76 | try: |
| 77 | start_time = time.time() |
| 78 | caption = captioner_cpu.caption_image(image) |
| 79 | elapsed = time.time() - start_time |
| 80 | |
| 81 | print(f"Image: {name}") |
| 82 | print(f"Caption: {caption}") |
| 83 | print(f"Time: {elapsed:.3f}s") |
| 84 | print() |
| 85 | |
| 86 | assert isinstance(caption, str) |
| 87 | assert len(caption) > 0 |
| 88 | |
| 89 | except Exception as e: |
| 90 | print(f"ERROR with {name}: {e}") |
| 91 | import traceback |
| 92 | |
| 93 | traceback.print_exc() |
| 94 | |
| 95 | print("✅ Basic CPU functionality test passed!") |
| 96 | |
| 97 | |
| 98 | def test_gpu_optimizations(): |
no test coverage detected