From daba7da59b93066381ba42ed18cee0cc4fba6489 Mon Sep 17 00:00:00 2001 From: Mews <60406199+Mews@users.noreply.github.com> Date: Mon, 10 Jun 2024 19:11:28 +0100 Subject: [PATCH 1/2] Created config.py Created the configuration file to be loaded by the flask app --- server/config.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 server/config.py diff --git a/server/config.py b/server/config.py new file mode 100644 index 0000000..a709cf7 --- /dev/null +++ b/server/config.py @@ -0,0 +1 @@ +MASK_BACKGROUND_COLOR = (0, 0, 0) \ No newline at end of file From c454c172f369f3d767605d1ea6b1326dc4bafa65 Mon Sep 17 00:00:00 2001 From: Mews <60406199+Mews@users.noreply.github.com> Date: Mon, 10 Jun 2024 19:17:28 +0100 Subject: [PATCH 2/2] Use MASK_BACKGROUND_COLOR in download_image_mask Use the MASK_BACKGROUND_COLOR loaded from config.py in download_image_mask --- server/app.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/app.py b/server/app.py index 5ac1e0c..83bb776 100644 --- a/server/app.py +++ b/server/app.py @@ -18,6 +18,7 @@ from dotenv import load_dotenv app = Flask(__name__) +app.config.from_object("config") # Get the CLIENT_URL environment variable, set a default if not found @@ -341,7 +342,7 @@ def download_image_mask(): response = requests.get(image_url) image = Image.open(BytesIO(response.content)) width, height = image.size - mask = Image.new('RGB', (width, height), (0, 0, 0)) # 'RGB' mode for colored masks + mask = Image.new('RGB', (width, height), app.config["MASK_BACKGROUND_COLOR"]) # 'RGB' mode for colored masks draw = ImageDraw.Draw(mask) for region in image_info.get("regions", []):