gchhablani commited on
Commit
8f0d88e
β€’
1 Parent(s): e1a3400

Resize article image

Browse files
app.py CHANGED
@@ -79,7 +79,7 @@ with st.beta_expander("Article"):
79
  st.write(read_markdown("caveats.md"))
80
  st.write("## Methodology")
81
  st.image(
82
- "./misc/Multilingual-VQA.png",
83
  caption="Masked LM model for Image-text Pretraining.",
84
  )
85
  st.markdown(read_markdown("pretraining.md"))
 
79
  st.write(read_markdown("caveats.md"))
80
  st.write("## Methodology")
81
  st.image(
82
+ "./misc/articles/resized/Multilingual-VQA.png",
83
  caption="Masked LM model for Image-text Pretraining.",
84
  )
85
  st.markdown(read_markdown("pretraining.md"))
misc/{Multilingual-VQA.png β†’ article/Multilingual-VQA.png} RENAMED
File without changes
misc/article/resized/Multilingual-VQA.png ADDED
resize_images.py CHANGED
@@ -2,21 +2,22 @@ import cv2
2
  import os
3
 
4
 
5
- # A function to resize the images with longer side to 300 pixels with cubic interpolation and save to a new directory
6
- def resize_images(path, new_path):
7
  if not os.path.exists(new_path):
8
  os.makedirs(new_path)
9
  for filename in os.listdir(path):
10
- if not filename.startswith('.'):
11
  img = cv2.imread(os.path.join(path, filename))
12
  height, width, channels = img.shape
13
  if height > width:
14
- new_height = 300
15
  new_width = int(width * new_height / height)
16
  else:
17
- new_width = 300
18
  new_height = int(height * new_width / width)
19
  img = cv2.resize(img, (new_width, new_height), interpolation=cv2.INTER_CUBIC)
20
  cv2.imwrite(os.path.join(new_path, filename), img)
21
 
22
- resize_images('./images/val2014', './resized_images/val2014')
 
 
2
  import os
3
 
4
 
5
+ # A function to resize the images with longer side to num_pixels pixels with cubic interpolation and save to a new directory
6
+ def resize_images(path, new_path, num_pixels=300):
7
  if not os.path.exists(new_path):
8
  os.makedirs(new_path)
9
  for filename in os.listdir(path):
10
+ if not filename.startswith('.') and (filename.endswith('.jpg') or filename.endswith('.jpeg') or filename.endswith('.png')):
11
  img = cv2.imread(os.path.join(path, filename))
12
  height, width, channels = img.shape
13
  if height > width:
14
+ new_height = num_pixels
15
  new_width = int(width * new_height / height)
16
  else:
17
+ new_width = num_pixels
18
  new_height = int(height * new_width / width)
19
  img = cv2.resize(img, (new_width, new_height), interpolation=cv2.INTER_CUBIC)
20
  cv2.imwrite(os.path.join(new_path, filename), img)
21
 
22
+ # resize_images('./images/val2014', './resized_images/val2014')
23
+ resize_images('./misc/article', './misc/article/resized', 500)