ksvmuralidhar commited on
Commit
f6bc454
·
verified ·
1 Parent(s): 760f2d2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -9
app.py CHANGED
@@ -16,6 +16,7 @@ import zipfile
16
  with zipfile.ZipFile("Vegetable Images.zip", 'r') as zip_ref:
17
  zip_ref.extractall('.')
18
 
 
19
 
20
  class ImageVectorizer:
21
  '''
@@ -73,14 +74,15 @@ def plot_images(input_image_path: str, similar_img_paths: list):
73
  # display input image
74
  rcParams.update({'figure.autolayout': True})
75
  input_image = load_img(input_image_path, color_mode="rgb", target_size=(224, 224))
76
- st.markdown('<p style="font-size: 20px; font-weight: bold">Input image</p>', unsafe_allow_html=True)
77
- st.image(input_image)
78
-
79
- st.write(' \n')
80
-
81
- # display similar images
82
- st.markdown('<p style="font-size: 20px; font-weight: bold">Similar images</p>', unsafe_allow_html=True)
83
- st.pyplot(fig)
 
84
 
85
 
86
  def find_similar_images(img_path: str, top_n: int=15):
@@ -131,7 +133,7 @@ def main():
131
  st.markdown(desc, unsafe_allow_html=True)
132
  img_url = st.text_input("Paste the image URL of a vegetable and hit Enter:", "")
133
  if img_url:
134
- st.empty()
135
  img_path = process_input_image(img_url)
136
  find_similar_images(img_path, 15)
137
  delete_file(os.path.dirname(img_path))
 
16
  with zipfile.ZipFile("Vegetable Images.zip", 'r') as zip_ref:
17
  zip_ref.extractall('.')
18
 
19
+ placeholder = st.empty()
20
 
21
  class ImageVectorizer:
22
  '''
 
74
  # display input image
75
  rcParams.update({'figure.autolayout': True})
76
  input_image = load_img(input_image_path, color_mode="rgb", target_size=(224, 224))
77
+ with placeholder.container():
78
+ st.markdown('<p style="font-size: 20px; font-weight: bold">Input image</p>', unsafe_allow_html=True)
79
+ st.image(input_image)
80
+
81
+ st.write(' \n')
82
+
83
+ # display similar images
84
+ st.markdown('<p style="font-size: 20px; font-weight: bold">Similar images</p>', unsafe_allow_html=True)
85
+ st.pyplot(fig)
86
 
87
 
88
  def find_similar_images(img_path: str, top_n: int=15):
 
133
  st.markdown(desc, unsafe_allow_html=True)
134
  img_url = st.text_input("Paste the image URL of a vegetable and hit Enter:", "")
135
  if img_url:
136
+ placeholder.empty()
137
  img_path = process_input_image(img_url)
138
  find_similar_images(img_path, 15)
139
  delete_file(os.path.dirname(img_path))