Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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(
|
| 11 |
-
img =
|
| 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 |
-
|
|
|
|
| 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)
|