| from handler import EndpointHandler | |
| from PIL import Image | |
| import io | |
| def test_endpoint(): | |
| # Initialize the handler | |
| handler = EndpointHandler("openbmb/MiniCPM-V-2_6") | |
| # Load a test image | |
| with open("test_image.jpg", "rb") as image_file: | |
| image_bytes = image_file.read() | |
| # Create a mock request data | |
| mock_data = { | |
| "inputs": { | |
| "image": type('MockFile', (), {'file': io.BytesIO(image_bytes)})(), | |
| "question": "What is in this image?" | |
| } | |
| } | |
| # Call the handler | |
| result = handler(mock_data) | |
| # Print the result | |
| print(result["generated_text"]) | |
| if __name__ == "__main__": | |
| test_endpoint() | |