update backend
This commit is contained in:
48
app.py
48
app.py
@@ -37,15 +37,59 @@ def get_scene_list():
|
||||
scene_list = [d for d in os.listdir(dataset_path) if os.path.isdir(os.path.join(dataset_path, d))]
|
||||
return jsonify({"scene_list": scene_list, "success": True})
|
||||
|
||||
@app.route('/get_label_list', methods=['POST'])
|
||||
def get_label_list():
|
||||
data = request.json
|
||||
dataset_name = data.get('dataset_name')
|
||||
scene_name = data.get("scene_name")
|
||||
|
||||
scene_dir = os.path.join(ROOT, dataset_name, scene_name)
|
||||
label_dir = os.path.join(scene_dir, "label")
|
||||
|
||||
if not os.path.exists(scene_dir):
|
||||
print(f"Scene not found: {scene_dir}")
|
||||
return jsonify({"error": "Scene not found"}), 404
|
||||
label_list = []
|
||||
global_min_coverage_rate = 1
|
||||
global_max_coverage_rate = 0
|
||||
global_total_coverage_rate = 0
|
||||
for label_file in os.listdir(label_dir):
|
||||
if label_file.endswith(".json"):
|
||||
label_path = os.path.join(label_dir, label_file)
|
||||
with open(label_path, 'r') as f:
|
||||
label_data = json.load(f)
|
||||
max_coveraget_rate = label_data.get('max_coverage_rate')
|
||||
if max_coveraget_rate > global_max_coverage_rate:
|
||||
global_max_coverage_rate = max_coveraget_rate
|
||||
if max_coveraget_rate < global_min_coverage_rate:
|
||||
global_min_coverage_rate = max_coveraget_rate
|
||||
label_list.append({
|
||||
"label_name": label_file,
|
||||
"max_coverage_rate": round(max_coveraget_rate*100,3)
|
||||
})
|
||||
global_total_coverage_rate += max_coveraget_rate
|
||||
if len(label_list) == 0:
|
||||
global_mean_coverage_rate = 0
|
||||
else:
|
||||
global_mean_coverage_rate = global_total_coverage_rate / len(label_list)
|
||||
|
||||
return jsonify({"label_list": label_list,
|
||||
"total_max_coverage_rate": round(global_max_coverage_rate*100, 3),
|
||||
"total_min_coverage_rate": round(global_min_coverage_rate*100, 3),
|
||||
"total_mean_coverage_rate": round(global_mean_coverage_rate*100, 3),
|
||||
"success": True})
|
||||
|
||||
|
||||
@app.route('/get_scene_info', methods=['POST'])
|
||||
def get_scene_info():
|
||||
data = request.json
|
||||
dataset_name = data.get('dataset_name')
|
||||
scene_name = data.get('scene_name')
|
||||
label_name = data.get('label_name')
|
||||
|
||||
scene_path = os.path.join(ROOT, dataset_name, scene_name)
|
||||
camera_params_path = os.path.join(scene_path, 'camera_params')
|
||||
label_json_path = os.path.join(scene_path, 'label.json')
|
||||
label_json_path = os.path.join(scene_path, "label", label_name)
|
||||
|
||||
if not os.path.exists(scene_path) or not os.path.exists(label_json_path):
|
||||
|
||||
@@ -228,4 +272,4 @@ def analysis_inference_result():
|
||||
return jsonify(res)
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(debug=True, port=13333)
|
||||
app.run(debug=True, port=13333,host="0.0.0.0")
|
||||
|
Reference in New Issue
Block a user