gchhablani commited on
Commit
b2f8c9b
1 Parent(s): 06cb314

Add resized images

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. resize_images.py +22 -0
  2. resized_images/val2014/COCO_val2014_000000000757.jpg +0 -0
  3. resized_images/val2014/COCO_val2014_000000013466.jpg +0 -0
  4. resized_images/val2014/COCO_val2014_000000015517.jpg +0 -0
  5. resized_images/val2014/COCO_val2014_000000017018.jpg +0 -0
  6. resized_images/val2014/COCO_val2014_000000023899.jpg +0 -0
  7. resized_images/val2014/COCO_val2014_000000029465.jpg +0 -0
  8. resized_images/val2014/COCO_val2014_000000032901.jpg +0 -0
  9. resized_images/val2014/COCO_val2014_000000036607.jpg +0 -0
  10. resized_images/val2014/COCO_val2014_000000046269.jpg +0 -0
  11. resized_images/val2014/COCO_val2014_000000050165.jpg +0 -0
  12. resized_images/val2014/COCO_val2014_000000066973.jpg +0 -0
  13. resized_images/val2014/COCO_val2014_000000068411.jpg +0 -0
  14. resized_images/val2014/COCO_val2014_000000074646.jpg +0 -0
  15. resized_images/val2014/COCO_val2014_000000079837.jpg +0 -0
  16. resized_images/val2014/COCO_val2014_000000084533.jpg +0 -0
  17. resized_images/val2014/COCO_val2014_000000090255.jpg +0 -0
  18. resized_images/val2014/COCO_val2014_000000095805.jpg +0 -0
  19. resized_images/val2014/COCO_val2014_000000099177.jpg +0 -0
  20. resized_images/val2014/COCO_val2014_000000109055.jpg +0 -0
  21. resized_images/val2014/COCO_val2014_000000109316.jpg +0 -0
  22. resized_images/val2014/COCO_val2014_000000111546.jpg +0 -0
  23. resized_images/val2014/COCO_val2014_000000117328.jpg +0 -0
  24. resized_images/val2014/COCO_val2014_000000117374.jpg +0 -0
  25. resized_images/val2014/COCO_val2014_000000121031.jpg +0 -0
  26. resized_images/val2014/COCO_val2014_000000132042.jpg +0 -0
  27. resized_images/val2014/COCO_val2014_000000144935.jpg +0 -0
  28. resized_images/val2014/COCO_val2014_000000151393.jpg +0 -0
  29. resized_images/val2014/COCO_val2014_000000153011.jpg +0 -0
  30. resized_images/val2014/COCO_val2014_000000156532.jpg +0 -0
  31. resized_images/val2014/COCO_val2014_000000163348.jpg +0 -0
  32. resized_images/val2014/COCO_val2014_000000163640.jpg +0 -0
  33. resized_images/val2014/COCO_val2014_000000167353.jpg +0 -0
  34. resized_images/val2014/COCO_val2014_000000169143.jpg +0 -0
  35. resized_images/val2014/COCO_val2014_000000171255.jpg +0 -0
  36. resized_images/val2014/COCO_val2014_000000187565.jpg +0 -0
  37. resized_images/val2014/COCO_val2014_000000190585.jpg +0 -0
  38. resized_images/val2014/COCO_val2014_000000190689.jpg +0 -0
  39. resized_images/val2014/COCO_val2014_000000197716.jpg +0 -0
  40. resized_images/val2014/COCO_val2014_000000208971.jpg +0 -0
  41. resized_images/val2014/COCO_val2014_000000209602.jpg +0 -0
  42. resized_images/val2014/COCO_val2014_000000230561.jpg +0 -0
  43. resized_images/val2014/COCO_val2014_000000238537.jpg +0 -0
  44. resized_images/val2014/COCO_val2014_000000242610.jpg +0 -0
  45. resized_images/val2014/COCO_val2014_000000246717.jpg +0 -0
  46. resized_images/val2014/COCO_val2014_000000260094.jpg +0 -0
  47. resized_images/val2014/COCO_val2014_000000261758.jpg +0 -0
  48. resized_images/val2014/COCO_val2014_000000270381.jpg +0 -0
  49. resized_images/val2014/COCO_val2014_000000277440.jpg +0 -0
  50. resized_images/val2014/COCO_val2014_000000295574.jpg +0 -0
resize_images.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import cv2
2
+ import os
3
+
4
+
5
+ # A function to resize the images with longer side to 500 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 = 500
15
+ new_width = int(width * new_height / height)
16
+ else:
17
+ new_width = 500
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')
resized_images/val2014/COCO_val2014_000000000757.jpg ADDED
resized_images/val2014/COCO_val2014_000000013466.jpg ADDED
resized_images/val2014/COCO_val2014_000000015517.jpg ADDED
resized_images/val2014/COCO_val2014_000000017018.jpg ADDED
resized_images/val2014/COCO_val2014_000000023899.jpg ADDED
resized_images/val2014/COCO_val2014_000000029465.jpg ADDED
resized_images/val2014/COCO_val2014_000000032901.jpg ADDED
resized_images/val2014/COCO_val2014_000000036607.jpg ADDED
resized_images/val2014/COCO_val2014_000000046269.jpg ADDED
resized_images/val2014/COCO_val2014_000000050165.jpg ADDED
resized_images/val2014/COCO_val2014_000000066973.jpg ADDED
resized_images/val2014/COCO_val2014_000000068411.jpg ADDED
resized_images/val2014/COCO_val2014_000000074646.jpg ADDED
resized_images/val2014/COCO_val2014_000000079837.jpg ADDED
resized_images/val2014/COCO_val2014_000000084533.jpg ADDED
resized_images/val2014/COCO_val2014_000000090255.jpg ADDED
resized_images/val2014/COCO_val2014_000000095805.jpg ADDED
resized_images/val2014/COCO_val2014_000000099177.jpg ADDED
resized_images/val2014/COCO_val2014_000000109055.jpg ADDED
resized_images/val2014/COCO_val2014_000000109316.jpg ADDED
resized_images/val2014/COCO_val2014_000000111546.jpg ADDED
resized_images/val2014/COCO_val2014_000000117328.jpg ADDED
resized_images/val2014/COCO_val2014_000000117374.jpg ADDED
resized_images/val2014/COCO_val2014_000000121031.jpg ADDED
resized_images/val2014/COCO_val2014_000000132042.jpg ADDED
resized_images/val2014/COCO_val2014_000000144935.jpg ADDED
resized_images/val2014/COCO_val2014_000000151393.jpg ADDED
resized_images/val2014/COCO_val2014_000000153011.jpg ADDED
resized_images/val2014/COCO_val2014_000000156532.jpg ADDED
resized_images/val2014/COCO_val2014_000000163348.jpg ADDED
resized_images/val2014/COCO_val2014_000000163640.jpg ADDED
resized_images/val2014/COCO_val2014_000000167353.jpg ADDED
resized_images/val2014/COCO_val2014_000000169143.jpg ADDED
resized_images/val2014/COCO_val2014_000000171255.jpg ADDED
resized_images/val2014/COCO_val2014_000000187565.jpg ADDED
resized_images/val2014/COCO_val2014_000000190585.jpg ADDED
resized_images/val2014/COCO_val2014_000000190689.jpg ADDED
resized_images/val2014/COCO_val2014_000000197716.jpg ADDED
resized_images/val2014/COCO_val2014_000000208971.jpg ADDED
resized_images/val2014/COCO_val2014_000000209602.jpg ADDED
resized_images/val2014/COCO_val2014_000000230561.jpg ADDED
resized_images/val2014/COCO_val2014_000000238537.jpg ADDED
resized_images/val2014/COCO_val2014_000000242610.jpg ADDED
resized_images/val2014/COCO_val2014_000000246717.jpg ADDED
resized_images/val2014/COCO_val2014_000000260094.jpg ADDED
resized_images/val2014/COCO_val2014_000000261758.jpg ADDED
resized_images/val2014/COCO_val2014_000000270381.jpg ADDED
resized_images/val2014/COCO_val2014_000000277440.jpg ADDED
resized_images/val2014/COCO_val2014_000000295574.jpg ADDED