from ultralytics import YOLO from flask import Flask, request, jsonify app = Flask(__name__) model = YOLO('best.pt') @app.route('/predict', methods=['POST']) def predict(): image = request.files['file'].read() results = model(image) return jsonify(results.pandas().xyxy[0].to_json(orient="records")) if __name__ == '__main__': app.run(host='0.0.0.0', port=8080)