yuragoithf commited on
Commit
b9b64f9
·
1 Parent(s): 0f34bc9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -7
app.py CHANGED
@@ -10,14 +10,10 @@ import keras.backend as K
10
  from PIL import Image
11
  from matplotlib import cm
12
 
13
- #from tensorflow import keras
14
 
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():
@@ -33,7 +29,6 @@ model_file = download_model()
33
  def Combo_loss(y_true, y_pred, eps=1e-9, smooth=1):
34
  targets = tf.dtypes.cast(K.flatten(y_true), tf.float32)
35
  inputs = tf.dtypes.cast(K.flatten(y_pred), tf.float32)
36
-
37
  intersection = K.sum(targets * inputs)
38
  dice = (2. * intersection + smooth) / (K.sum(targets) + K.sum(inputs) + smooth)
39
  inputs = K.clip(inputs, eps, 1.0 - eps)
@@ -52,7 +47,7 @@ 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="pil", label="Output Image")
57
  # outputs = gr.outputs.HTML() #uncomment for single class output
58
 
@@ -84,6 +79,5 @@ gr.Interface(fn=gen_pred,
84
  outputs=image_output,
85
  title=title,
86
  examples=[["003e2c95d.jpg"], ["003b50a15.jpg"], ["003b48a9e.jpg"], ["0038cbe45.jpg"], ["00371aa92.jpg"]],
87
- # css=css_code,
88
  description=description,
89
  enable_queue=True).launch()
 
10
  from PIL import Image
11
  from matplotlib import cm
12
 
 
13
 
14
  resized_shape = (768, 768, 3)
15
  IMG_SCALING = (1, 1)
16
 
 
 
 
17
 
18
  # Download the model file
19
  def download_model():
 
29
  def Combo_loss(y_true, y_pred, eps=1e-9, smooth=1):
30
  targets = tf.dtypes.cast(K.flatten(y_true), tf.float32)
31
  inputs = tf.dtypes.cast(K.flatten(y_pred), tf.float32)
 
32
  intersection = K.sum(targets * inputs)
33
  dice = (2. * intersection + smooth) / (K.sum(targets) + K.sum(inputs) + smooth)
34
  inputs = K.clip(inputs, eps, 1.0 - eps)
 
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")
52
  # outputs = gr.outputs.HTML() #uncomment for single class output
53
 
 
79
  outputs=image_output,
80
  title=title,
81
  examples=[["003e2c95d.jpg"], ["003b50a15.jpg"], ["003b48a9e.jpg"], ["0038cbe45.jpg"], ["00371aa92.jpg"]],
 
82
  description=description,
83
  enable_queue=True).launch()