File size: 1,654 Bytes
dcad101
 
 
 
 
 
8e5893e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from flask import Flask

app = Flask(__name__)

@app.route('/')
def hello():
    return {"hei": "you succesfully deployed"}

@app.route('/get-npy')
def get_npy():
    #     # Get the 'img_url' from the query parameters
    #     img_url = request.args.get('img_url', '') # Default to empty string if not provided
        
    #     if not img_url:
    #         return jsonify({"error": "No img_url provided"}), 400
        
    #     raw_image = Image.open(requests.get(img_url, stream=True).raw).convert("RGB")
    #     # Convert the PIL Image to a NumPy array
    #     image_array = np.array(raw_image)
    #     # Since OpenCV expects BGR, convert RGB to BGR
    #     image = image_array[:, :, ::-1]

    #     if image is None:
    #         raise ValueError("Image not found or unable to read.")
        
    #     predictor.set_image(image)
    #     image_embedding = predictor.get_image_embedding().cpu().numpy()
        
    #     # Convert the embedding array to bytes
    #     buffer = io.BytesIO()
    #     np.save(buffer, image_embedding)
    #     buffer.seek(0)
        
    #     # Create a response with the correct MIME type
    #     return send_file(buffer, mimetype='application/octet-stream', as_attachment=True, download_name='embedding.npy')
    # except Exception as e:
    #     # Log the error message if needed
    #     print(f"Error processing the image: {e}")
    #     # Return a JSON response with the error message and a 400 Bad Request status
    #     return jsonify({"error": "Error processing the image", "details": str(e)}), 400
    return {"hei": "gotnpy"}

if __name__ == '__main__':
    app.run(debug=True)