Kalbe-x-Bangkit commited on
Commit
ee377c5
1 Parent(s): 153ff5a

Disable resize and normalization for detection. Change function to load_image.

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -33,8 +33,8 @@ enhancement_type = st.sidebar.selectbox(
33
  ["Invert", "High Pass Filter", "Unsharp Masking", "Histogram Equalization", "CLAHE"]
34
  )
35
 
36
- H = 224
37
- W = 224
38
 
39
  @st.cache_resource
40
  def load_model_detection():
@@ -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 = 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]
 
33
  ["Invert", "High Pass Filter", "Unsharp Masking", "Histogram Equalization", "CLAHE"]
34
  )
35
 
36
+ # H = 224
37
+ # W = 224
38
 
39
  @st.cache_resource
40
  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
  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]