Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -177,24 +177,20 @@ def prediction(image_id_main, local_image_path, model_path):
|
|
| 177 |
results_list.append(result)
|
| 178 |
|
| 179 |
submission_det = pd.DataFrame(results_list, columns=['image_id', 'PredictionString'])
|
| 180 |
-
|
| 181 |
-
submission_det.
|
| 182 |
-
|
| 183 |
-
return submission_det_path
|
| 184 |
|
| 185 |
@app.route('/predict', methods=['POST'])
|
| 186 |
def predict():
|
| 187 |
-
image_id = request.form['image_id']
|
| 188 |
image_file = request.files['image']
|
|
|
|
| 189 |
model_path = request.form['model_path']
|
| 190 |
-
|
| 191 |
-
local_image_path = os.path.join("
|
| 192 |
-
os.makedirs("input_images", exist_ok=True)
|
| 193 |
image_file.save(local_image_path)
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
return send_file(submission_det_path, as_attachment=True)
|
| 198 |
|
| 199 |
if __name__ == '__main__':
|
| 200 |
app.run(host='0.0.0.0', port=8000)
|
|
|
|
| 177 |
results_list.append(result)
|
| 178 |
|
| 179 |
submission_det = pd.DataFrame(results_list, columns=['image_id', 'PredictionString'])
|
| 180 |
+
submission_det.to_csv("submission_det.csv", index=False)
|
| 181 |
+
return "submission_det.csv"
|
|
|
|
|
|
|
| 182 |
|
| 183 |
@app.route('/predict', methods=['POST'])
|
| 184 |
def predict():
|
|
|
|
| 185 |
image_file = request.files['image']
|
| 186 |
+
image_id = request.form['image_id']
|
| 187 |
model_path = request.form['model_path']
|
| 188 |
+
|
| 189 |
+
local_image_path = os.path.join("/tmp", image_file.filename)
|
|
|
|
| 190 |
image_file.save(local_image_path)
|
| 191 |
+
|
| 192 |
+
result_path = prediction(image_id, local_image_path, model_path)
|
| 193 |
+
return send_file(result_path, as_attachment=True)
|
|
|
|
| 194 |
|
| 195 |
if __name__ == '__main__':
|
| 196 |
app.run(host='0.0.0.0', port=8000)
|