Spaces:
Sleeping
Sleeping
| import os | |
| import sys | |
| from PIL import Image | |
| import numpy as np | |
| def test_imports(): | |
| try: | |
| import gradio as gr | |
| import google.generativeai as genai | |
| import cv2 | |
| import numpy as np | |
| from PIL import Image | |
| print("β All required imports successful") | |
| return True | |
| except ImportError as e: | |
| print(f"β Import failed: {e}") | |
| return False | |
| def test_app_initialization(): | |
| try: | |
| from app import NanoBananaApp | |
| app = NanoBananaApp() | |
| print("β App initialization successful") | |
| return True | |
| except Exception as e: | |
| print(f"β App initialization failed: {e}") | |
| return False | |
| def test_image_processing(): | |
| try: | |
| test_image = Image.new('RGB', (512, 512), color='white') | |
| from app import NanoBananaApp | |
| app = NanoBananaApp() | |
| resized = app._resize_image_if_needed(test_image) | |
| print(f"β Image processing test passed - size: {resized.size}") | |
| return True | |
| except Exception as e: | |
| print(f"β Image processing test failed: {e}") | |
| return False | |
| def test_gradio_interface(): | |
| try: | |
| from app import demo | |
| print("β Gradio interface created successfully") | |
| return True | |
| except Exception as e: | |
| print(f"β Gradio interface test failed: {e}") | |
| return False | |
| def main(): | |
| print("π§ͺ Testing Nano Banana Deployment") | |
| print("=" * 40) | |
| tests = [ | |
| ("Import Test", test_imports), | |
| ("App Initialization", test_app_initialization), | |
| ("Image Processing", test_image_processing), | |
| ("Gradio Interface", test_gradio_interface) | |
| ] | |
| passed = 0 | |
| for test_name, test_func in tests: | |
| print(f"\n{test_name}:") | |
| if test_func(): | |
| passed += 1 | |
| print("\n" + "=" * 40) | |
| print(f"Results: {passed}/{len(tests)} tests passed") | |
| if passed == len(tests): | |
| print("π All tests passed! Ready for deployment.") | |
| else: | |
| print("β οΈ Some tests failed. Check the issues above.") | |
| return passed == len(tests) | |
| if __name__ == "__main__": | |
| success = main() | |
| sys.exit(0 if success else 1) | |