Spaces:
Sleeping
Sleeping
Commit
·
25657f4
1
Parent(s):
dce6539
initial
Browse files
main.py
CHANGED
@@ -49,11 +49,13 @@ def get_masks():
|
|
49 |
if image_file.filename == '':
|
50 |
return jsonify({"error": "No image file provided"}), 400
|
51 |
|
52 |
-
|
53 |
-
# Convert the
|
54 |
-
|
55 |
-
|
56 |
-
|
|
|
|
|
57 |
|
58 |
if image is None:
|
59 |
raise ValueError("Image not found or unable to read.")
|
|
|
49 |
if image_file.filename == '':
|
50 |
return jsonify({"error": "No image file provided"}), 400
|
51 |
|
52 |
+
# Read image file using OpenCV-style approach (similar to cv2.imread)s
|
53 |
+
# Convert the image file to a NumPy array using OpenCV
|
54 |
+
file_bytes = np.fromstring(image_file.read(), np.uint8)
|
55 |
+
image = cv2.imdecode(file_bytes, cv2.IMREAD_COLOR)
|
56 |
+
|
57 |
+
# Convert BGR to RGB using OpenCV (similar to cv2.cvtColor)
|
58 |
+
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
59 |
|
60 |
if image is None:
|
61 |
raise ValueError("Image not found or unable to read.")
|