Kalbe-x-Bangkit
commited on
Commit
•
153ff5a
1
Parent(s):
96c8bed
Open def preprocess_image(image) again.
Browse files
app.py
CHANGED
@@ -52,12 +52,12 @@ def load_model_detection():
|
|
52 |
)
|
53 |
return model
|
54 |
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
|
62 |
|
63 |
|
@@ -469,9 +469,9 @@ if uploaded_file is not None:
|
|
469 |
st.write("Processing...")
|
470 |
input_image = preprocess_image(image)
|
471 |
# input_image = enhancement_type
|
472 |
-
input_image = cv2.resize(enhanced_image, (W, H)) # Resize the enhanced image to the required input size
|
473 |
-
input_image = (input_image - 127.5) / 127.5 # Normalize to [-1, +1]
|
474 |
-
input_image = np.expand_dims(input_image, axis=0).astype(np.float32) # Expand dimensions and convert to float32
|
475 |
|
476 |
pred_bbox, pred_label, pred_label_confidence = predict(model_detection, input_image)
|
477 |
|
|
|
52 |
)
|
53 |
return model
|
54 |
|
55 |
+
def preprocess_image(image):
|
56 |
+
""" Preprocess the image to the required size and normalization. """
|
57 |
+
image = cv2.resize(image, (W, H))
|
58 |
+
image = (image - 127.5) / 127.5 # Normalize to [-1, +1]
|
59 |
+
image = np.expand_dims(image, axis=0).astype(np.float32)
|
60 |
+
return image
|
61 |
|
62 |
|
63 |
|
|
|
469 |
st.write("Processing...")
|
470 |
input_image = preprocess_image(image)
|
471 |
# input_image = enhancement_type
|
472 |
+
# input_image = cv2.resize(enhanced_image, (W, H)) # Resize the enhanced image to the required input size
|
473 |
+
# input_image = (input_image - 127.5) / 127.5 # Normalize to [-1, +1]
|
474 |
+
# input_image = np.expand_dims(input_image, axis=0).astype(np.float32) # Expand dimensions and convert to float32
|
475 |
|
476 |
pred_bbox, pred_label, pred_label_confidence = predict(model_detection, input_image)
|
477 |
|