AIQuest commited on
Commit
0a2443d
·
1 Parent(s): fdb58ce

Update app.py

Browse files

Remove bugs from custome_image_processing function

Files changed (1) hide show
  1. app.py +4 -6
app.py CHANGED
@@ -7,15 +7,13 @@ import gradio as gr
7
  from keras.models import load_model
8
 
9
  def custom_Image_preprocessing(image_data, target_size=(150, 150)):
10
- img = Image.fromarray((image_data * 255).astype('uint8'))
11
- img = img.resize(target_size)
12
- img_arr = np.array(img)
13
- if img_arr.shape[-1] != 3:
14
- img_arr = np.stack((img_arr,) * 3, axis=-1)
15
  img_arr = np.expand_dims(img_arr, axis=0)
16
  return img_arr
17
 
18
-
19
  # function to predict the custome image
20
 
21
  def image_predict(image_path):
 
7
  from keras.models import load_model
8
 
9
  def custom_Image_preprocessing(image_data, target_size=(150, 150)):
10
+ img = image.array_to_img(image_data, data_format='channels_last')
11
+ img = img.resize(target_size) # Resize the image if needed
12
+ img_arr = image.img_to_array(img)
13
+ img_arr = img_arr * 1./255
 
14
  img_arr = np.expand_dims(img_arr, axis=0)
15
  return img_arr
16
 
 
17
  # function to predict the custome image
18
 
19
  def image_predict(image_path):