CoolFace
Apppublic

Carloss203/deepvision-backend

sourceHugging Facemitupdated 10mo agoView on Hugging Face
0likes
app.py31 linesDownload Raw Back to root
1# backend/app.py2from flask import Flask, request, jsonify3from flask_cors import CORS4from model import DualModelDetector5from PIL import Image6 7app = Flask(__name__)8CORS(app, resources={r"/api/*": {"origins": "*"}})9 10# Initialize the Dual Expert11detector = DualModelDetector()12 13@app.route('/api/predict', methods=['POST'])14def predict():15    if 'image' not in request.files:16        return jsonify({'error': 'No image uploaded'}), 40017 18    file = request.files['image']19    20    try:21        image = Image.open(file.stream)22        # Returns the combined analysis23        result = detector.predict(image)24        return jsonify(result)25 26    except Exception as e:27        print(f"Server Error: {e}")28        return jsonify({'error': str(e)}), 50029 30if __name__ == '__main__':31    app.run(host='0.0.0.0', port=5000, debug=True)