905saini commited on
Commit
b2fe7c6
·
1 Parent(s): f0f9c29

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -7,12 +7,10 @@ labels = ["Column","Header","Table"]
7
  threshold = 0.75
8
  model = tf.saved_model.load("best_saved_model") #Loading the saved model
9
 
10
- def process_img(img_path):
11
- img = cv2.imread(img_path) # reading the image
12
- #copy_img = img.copy() # save a copy of image to plot result
13
- img = cv2.resize(img,(640,640)) # resize the image as reqired for the model input
14
  copy_img = img.copy()
15
- img = img/255 # Normalizing the picel value
16
  img = img.astype("float32") # Convert the format double to format float
17
  img = np.expand_dims(img,axis=0) # exapanding dimension to add batch
18
  return img,copy_img
@@ -22,8 +20,9 @@ file_name = st.file_uploader("Upload a repport image")
22
  print(type(file_name),file_name)
23
  if file_name is not None:
24
  col1, col2 = st.columns(2)
25
-
26
- input_image,copy_image = process_img(file_name)
 
27
  col1.image(input_image, use_column_width=True)
28
 
29
  bbox,confidance,classes,nc = model(input_img)
 
7
  threshold = 0.75
8
  model = tf.saved_model.load("best_saved_model") #Loading the saved model
9
 
10
+ def process_img(img):
11
+ img = img.resize(640,640) # resize the image as reqired for the model input
 
 
12
  copy_img = img.copy()
13
+ img = np.array(img/255) # Normalizing the picel value
14
  img = img.astype("float32") # Convert the format double to format float
15
  img = np.expand_dims(img,axis=0) # exapanding dimension to add batch
16
  return img,copy_img
 
20
  print(type(file_name),file_name)
21
  if file_name is not None:
22
  col1, col2 = st.columns(2)
23
+
24
+ image = Image.open(file_name)
25
+ input_image, copy_img= process_img(image)
26
  col1.image(input_image, use_column_width=True)
27
 
28
  bbox,confidance,classes,nc = model(input_img)