File size: 673 Bytes
bb2a012
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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()