Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -81,7 +81,6 @@ def post_data():
|
|
| 81 |
return jsonify({"error": "Missing required fields: 'imageData' or 'model'"}), 400
|
| 82 |
|
| 83 |
base64_image = data['imageData']
|
| 84 |
-
filename = data.get('filename', 'image.jpg')
|
| 85 |
|
| 86 |
# Decode the image data
|
| 87 |
try:
|
|
@@ -95,8 +94,6 @@ def post_data():
|
|
| 95 |
except IOError as e:
|
| 96 |
return jsonify({"error": "Invalid image data"}), 400
|
| 97 |
|
| 98 |
-
image.save(filename)
|
| 99 |
-
|
| 100 |
# Model prediction logic
|
| 101 |
if data['model'] == 'resnet':
|
| 102 |
transform_img = transform_data_resnet50(image).unsqueeze(0)
|
|
@@ -134,8 +131,7 @@ def post_data():
|
|
| 134 |
|
| 135 |
except Exception as e:
|
| 136 |
# Return an error response if something goes wrong
|
| 137 |
-
return jsonify({"
|
| 138 |
-
|
| 139 |
|
| 140 |
|
| 141 |
@app.route('/test', methods=['POST'])
|
|
|
|
| 81 |
return jsonify({"error": "Missing required fields: 'imageData' or 'model'"}), 400
|
| 82 |
|
| 83 |
base64_image = data['imageData']
|
|
|
|
| 84 |
|
| 85 |
# Decode the image data
|
| 86 |
try:
|
|
|
|
| 94 |
except IOError as e:
|
| 95 |
return jsonify({"error": "Invalid image data"}), 400
|
| 96 |
|
|
|
|
|
|
|
| 97 |
# Model prediction logic
|
| 98 |
if data['model'] == 'resnet':
|
| 99 |
transform_img = transform_data_resnet50(image).unsqueeze(0)
|
|
|
|
| 131 |
|
| 132 |
except Exception as e:
|
| 133 |
# Return an error response if something goes wrong
|
| 134 |
+
return jsonify({"errorg": str(e)}), 500
|
|
|
|
| 135 |
|
| 136 |
|
| 137 |
@app.route('/test', methods=['POST'])
|