yuragoithf commited on
Commit
58b426c
·
1 Parent(s): 2b32190

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -15,9 +15,9 @@ import keras.backend as K
15
  resized_shape = (768, 768, 3)
16
  IMG_SCALING = (1, 1)
17
 
18
- def get_opencv_img_from_buffer(buffer, flags=cv2.IMREAD_COLOR):
19
- bytes_as_np_array = np.frombuffer(buffer.read(), dtype=np.uint8)
20
- return cv2.imdecode(bytes_as_np_array, flags)
21
 
22
  # Download the model file
23
  def download_model():
@@ -52,14 +52,14 @@ def dice_coef(y_true, y_pred, smooth=1):
52
  # Load the model
53
  seg_model = tf.keras.models.load_model('seg_unet_model.h5', custom_objects={'Combo_loss': Combo_loss, 'dice_coef': dice_coef})
54
 
55
- inputs = gr.inputs.Image(type="pil", label="Upload an image", source="upload")
56
  image_output = gr.outputs.Image(type="numpy", label="Output Image")
57
  # outputs = gr.outputs.HTML() #uncomment for single class output
58
 
59
  def gen_pred(img=inputs, model=seg_model):
60
  # rgb_path = os.path.join(test_image_dir,img)
61
  # img = cv2.imread(rgb_path)
62
- img = cv2.imread("./003e2c95d.jpg")
63
  img = img[::IMG_SCALING[0], ::IMG_SCALING[1]]
64
  img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
65
  img = img/255
 
15
  resized_shape = (768, 768, 3)
16
  IMG_SCALING = (1, 1)
17
 
18
+ # def get_opencv_img_from_buffer(buffer, flags=cv2.IMREAD_COLOR):
19
+ # bytes_as_np_array = np.frombuffer(buffer.read(), dtype=np.uint8)
20
+ # return cv2.imdecode(bytes_as_np_array, flags)
21
 
22
  # Download the model file
23
  def download_model():
 
52
  # Load the model
53
  seg_model = tf.keras.models.load_model('seg_unet_model.h5', custom_objects={'Combo_loss': Combo_loss, 'dice_coef': dice_coef})
54
 
55
+ inputs = gr.inputs.Image(type="numpy", label="Upload an image", source="upload")
56
  image_output = gr.outputs.Image(type="numpy", label="Output Image")
57
  # outputs = gr.outputs.HTML() #uncomment for single class output
58
 
59
  def gen_pred(img=inputs, model=seg_model):
60
  # rgb_path = os.path.join(test_image_dir,img)
61
  # img = cv2.imread(rgb_path)
62
+ # img = cv2.imread("./003e2c95d.jpg")
63
  img = img[::IMG_SCALING[0], ::IMG_SCALING[1]]
64
  img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
65
  img = img/255