nishantguvvada commited on
Commit
343c9a4
·
1 Parent(s): 0cca7e5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -12
app.py CHANGED
@@ -3,6 +3,7 @@ import tensorflow as tf
3
  import cv2
4
  import numpy as np
5
  from PIL import Image, ImageOps
 
6
  #from io import BytesIO
7
 
8
  @st.cache_resource()
@@ -19,19 +20,19 @@ st.write("""
19
 
20
  file = st.file_uploader("Upload an X-ray image", type= ['png', 'jpg'])
21
 
 
 
 
 
 
 
 
 
22
 
23
  def model_prediction(image, model):
24
- resize = tf.image.resize(image, (256,256))
25
- yhat = model.predict(np.expand_dims(resize/255, 0))
26
- if(yhat>0.5):
27
- result = "Prediction is loose"
28
- else:
29
- result = "Prediction is control"
30
- return result
31
-
32
- def model_prediction(image, model):
33
- resize = tf.image.resize(image, (256,256))
34
- yhat = model.predict(np.expand_dims(resize/255, 0))
35
  if(yhat>0.5):
36
  result = "Prediction is loose"
37
  else:
@@ -45,7 +46,8 @@ def on_click():
45
  else:
46
  image = Image.open(file)
47
  st.image(image, use_column_width=True)
48
- predictions = model_prediction(image, model)
 
49
  st.write(prediction)
50
  print(
51
  "This image most likely belongs to {}."
 
3
  import cv2
4
  import numpy as np
5
  from PIL import Image, ImageOps
6
+ import imageio.v3 as iio
7
  #from io import BytesIO
8
 
9
  @st.cache_resource()
 
20
 
21
  file = st.file_uploader("Upload an X-ray image", type= ['png', 'jpg'])
22
 
23
+ # def model_prediction(image, model):
24
+ # resize = tf.image.resize(image, (256,256))
25
+ # yhat = model.predict(np.expand_dims(resize/255, 0))
26
+ # if(yhat>0.5):
27
+ # result = "Prediction is loose"
28
+ # else:
29
+ # result = "Prediction is control"
30
+ # return result
31
 
32
  def model_prediction(image, model):
33
+
34
+ item = cv2.resize(image,dsize=(256,256), interpolation=cv2.INTER_CUBIC)
35
+ yhat = model.predict(np.expand_dims(item/255, 0))
 
 
 
 
 
 
 
 
36
  if(yhat>0.5):
37
  result = "Prediction is loose"
38
  else:
 
46
  else:
47
  image = Image.open(file)
48
  st.image(image, use_column_width=True)
49
+ img = iio.imread(file)
50
+ predictions = model_prediction(img, model)
51
  st.write(prediction)
52
  print(
53
  "This image most likely belongs to {}."