Kalbe-x-Bangkit commited on
Commit
5b11650
·
verified ·
1 Parent(s): ee377c5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -52,12 +52,12 @@ def load_model_detection():
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
 
@@ -467,7 +467,7 @@ if uploaded_file is not None:
467
  image = cv2.imdecode(file_bytes, 1)
468
  if st.button('Auto Detect'):
469
  st.write("Processing...")
470
- input_image = load_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]
 
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=320, H=320))
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
 
 
467
  image = cv2.imdecode(file_bytes, 1)
468
  if st.button('Auto Detect'):
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]