forked from Alex-Lekov/yolov8-fastapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_inference2.py
30 lines (23 loc) · 976 Bytes
/
test_inference2.py
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
import asyncio
from PIL import Image
import os
from app import get_model_predict, model
async def test_keypoints():
# List of test images
test_images = ['test.jpg', 'test2.jpg', 'test3.jpg']
for image_name in test_images:
print(f"\nProcessing {image_name}...")
try:
# Load the local image
input_image = Image.open(image_name)
# Process the image
keypoints, confidence = get_model_predict(model, input_image)
# Print keypoints and confidence
print("Keypoints detected:")
for i, kp in enumerate(keypoints):
print(f"Keypoint {i}: x={kp[0]:.1f}, y={kp[1]:.1f}, confidence={kp[2]:.2f}")
print(f"Average confidence: {confidence:.2f}")
except Exception as e:
print(f"Error processing {image_name}: {e}")
if __name__ == "__main__":
asyncio.run(test_keypoints())