Skip to content

Commit

Permalink
added color map to the response of configuration download
Browse files Browse the repository at this point in the history
  • Loading branch information
sumn2u committed Jun 17, 2024
1 parent 5c778e0 commit 65e330a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,19 @@ Sample of annotated image along with its mask and settings is show below.
0.6981424148606811
]
}
]
],
"color-map":{
"Orange":[
244,
67,
54
],
"Apple":[
33,
150,
243
]
}
}
]
}
Expand Down
10 changes: 8 additions & 2 deletions server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,15 @@ def save_active_image_info():
return jsonify({"status": "error", "message": "An error occurred while processing the request"}), 500


def create_json_response(image_name):
def create_json_response(image_name, color_map=None):
imagesName = []
base_url = request.host_url + 'uploads/'
# Initialize the main dictionary for storing image information
main_dict = {'image-name': image_name, 'regions': []}

if color_map:
main_dict['color-map'] = color_map

added_region_ids = set() # Set to track added region IDs

for (root, dirs, files) in os.walk(path):
Expand Down Expand Up @@ -240,10 +244,12 @@ def download_configuration():
data = request.get_json()
# Ensure the expected structure of the JSON data
image_name = data.get('image_name')
color_map = data.get("colorMap", None)

if not image_name:
raise ValueError("Invalid JSON data format: 'image_name' not found.")

json_bytes, download_filename = create_json_response(image_name)
json_bytes, download_filename = create_json_response(image_name, color_map)

return send_file(json_bytes, mimetype='application/json', as_attachment=True, download_name=download_filename)

Expand Down

0 comments on commit 65e330a

Please sign in to comment.