Kalbe-x-Bangkit commited on
Commit
2ed76b8
1 Parent(s): 834264e

Input add resize.

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -348,7 +348,7 @@ def redirect_button(url):
348
 
349
  def predict(model, image):
350
  """ Predict bounding box and label for the input image. """
351
- pred_bbox, pred_class = model.predict(enhancement_type)
352
  pred_label_confidence = np.max(pred_class, axis=1)[0]
353
  pred_label = np.argmax(pred_class, axis=1)[0]
354
  return pred_bbox[0], pred_label, pred_label_confidence
@@ -462,7 +462,10 @@ if uploaded_file is not None:
462
  if st.button('Auto Detect'):
463
  st.write("Processing...")
464
  # input_image = preprocess_image(image)
465
- input_image = enhancement_type
 
 
 
466
  pred_bbox, pred_label, pred_label_confidence = predict(model, input_image)
467
 
468
  # Updated label mapping based on the dataset
 
348
 
349
  def predict(model, image):
350
  """ Predict bounding box and label for the input image. """
351
+ pred_bbox, pred_class = model.predict(image)
352
  pred_label_confidence = np.max(pred_class, axis=1)[0]
353
  pred_label = np.argmax(pred_class, axis=1)[0]
354
  return pred_bbox[0], pred_label, pred_label_confidence
 
462
  if st.button('Auto Detect'):
463
  st.write("Processing...")
464
  # input_image = preprocess_image(image)
465
+ # input_image = enhancement_type
466
+ input_image = cv2.resize(enhanced_image, (W, H)) # Resize the enhanced image to the required input size
467
+ input_image = (input_image - 127.5) / 127.5 # Normalize to [-1, +1]
468
+ input_image = np.expand_dims(input_image, axis=0).astype(np.float32) # Expand dimensions and convert to float32
469
  pred_bbox, pred_label, pred_label_confidence = predict(model, input_image)
470
 
471
  # Updated label mapping based on the dataset