wjm55
Refactor app.py to remove model caching and initialize model per request. Update root endpoint and modify predict function to handle uploaded images. Change test.py to use variable for local app URL.
4160d5b
raw
history blame
849 Bytes
import requests
# Path to your image
image_path = "/Users/wjm55/yale/weaviate-test/yolov11_output/valid/images/Paris_BnF_Velins_611_00003.jpg"
hf_app = "https://wjbmattingly-medieval-yolo-api.hf.space"
local_app = "http://localhost"
# Open the image file
with open(image_path, 'rb') as f:
# Create the files parameter for the POST request
files = {'image': f}
# Optional parameters (using defaults from the API)
params = {
'model_id': 'YOLOv11-Nano', # default model
'conf': 0.25, # confidence threshold
'iou': 0.7 # IoU threshold
}
# Send POST request to the endpoint
response = requests.post(local_app + ':7860/predict',
files=files,
params=params)
# Print the results
print(response.json())