yuragoithf commited on
Commit
88d04c7
·
1 Parent(s): 1899d85

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -4
app.py CHANGED
@@ -9,6 +9,7 @@ from transformers import pipeline
9
 
10
  from PIL import Image
11
  from matplotlib import cm
 
12
 
13
 
14
  resized_shape = (768, 768, 3)
@@ -45,7 +46,7 @@ def dice_coef(y_true, y_pred, smooth=1):
45
  return K.mean((2 * intersection + smooth) / (union + smooth), axis=0)
46
 
47
  # Load the model
48
- seg_model = tf.keras.models.load_model('seg_unet_model.h5', custom_objects={'Combo_loss': Combo_loss, 'dice_coef': dice_coef})
49
 
50
  inputs = gr.inputs.Image(type="pil", label="Upload an image")
51
  image_output = gr.outputs.Image(type="pil", label="Output Image")
@@ -57,9 +58,6 @@ def gen_pred(img, model=seg_model):
57
  # open_cv_image = np.array(pil_image)
58
  # img = open_cv_image[:, :, ::-1].copy()
59
  # # img = cv2.imread("./003e2c95d.jpg")
60
- img_byte_arr = io.BytesIO()
61
- img.save(img_byte_arr, format='JPEG', subsampling=0, quality=100)
62
- img = img_byte_arr.getvalue()
63
  img = img[::IMG_SCALING[0], ::IMG_SCALING[1]]
64
  img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
65
  img = img/255
 
9
 
10
  from PIL import Image
11
  from matplotlib import cm
12
+ from tensorflow import keras
13
 
14
 
15
  resized_shape = (768, 768, 3)
 
46
  return K.mean((2 * intersection + smooth) / (union + smooth), axis=0)
47
 
48
  # Load the model
49
+ seg_model = keras.models.load_model('seg_unet_model.h5', custom_objects={'Combo_loss': Combo_loss, 'dice_coef': dice_coef})
50
 
51
  inputs = gr.inputs.Image(type="pil", label="Upload an image")
52
  image_output = gr.outputs.Image(type="pil", label="Output Image")
 
58
  # open_cv_image = np.array(pil_image)
59
  # img = open_cv_image[:, :, ::-1].copy()
60
  # # img = cv2.imread("./003e2c95d.jpg")
 
 
 
61
  img = img[::IMG_SCALING[0], ::IMG_SCALING[1]]
62
  img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
63
  img = img/255