905saini commited on
Commit
3864753
·
1 Parent(s): 506a29e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -9,10 +9,10 @@ threshold = 0.75
9
  model = tf.saved_model.load("best_saved_model") #Loading the saved model
10
 
11
  def process_img(img):
12
- img = img.resize((640,640)) # resize the image as reqired for the model input
13
- img = np.array(img)
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
@@ -35,7 +35,7 @@ if file_name is not None:
35
  if confidance[i] >= threshold:
36
  x1,y1,x2,y2 = bbox[i]*640
37
  class_name = labels[int(classes[i])]
38
- st.text(class_name+" : "+str(confidance[i])+"%")
39
  if class_name =="Header":
40
  color = (0,0,255) #Blue color
41
  cv2.rectangle(copy_img, (int(x1), int(y1)), (int(x2), int(y2)),color, 2)
 
9
  model = tf.saved_model.load("best_saved_model") #Loading the saved model
10
 
11
  def process_img(img):
12
+ img = img.resize((640,640)) # resize the image as reqired for the model input
13
+ img = np.array(img) # Convert Pil Object into numpy array
14
+ copy_img = img.copy() # Save a copy for backup
15
+ img = img/255 # Normalizing the pixel 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
 
35
  if confidance[i] >= threshold:
36
  x1,y1,x2,y2 = bbox[i]*640
37
  class_name = labels[int(classes[i])]
38
+ st.text(class_name+" : "+str(int(confidance[i]*100))+"%")
39
  if class_name =="Header":
40
  color = (0,0,255) #Blue color
41
  cv2.rectangle(copy_img, (int(x1), int(y1)), (int(x2), int(y2)),color, 2)