Spaces:
Sleeping
Sleeping
File size: 2,295 Bytes
e98d661 |
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
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)
|