Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sometimes does not match label file name and picture file name and resize picture #35

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.7.13
Binary file added Images/001/1.aoi.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/001/2.member_chiaki_aoi.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/001/2.shimarin_nadeshiko.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/001/3_member_chiaki_aoi_nadeshiko.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Images/001/test.JPEG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Images/001/test2.JPEG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Images/001/test3.JPEG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/output/1.aoi.JPEG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/output/2.member_chiaki_aoi.JPEG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/output/2.shimarin_nadeshiko.JPEG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/output/3_member_chiaki_aoi_nadeshiko.JPEG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/output/test.JPEG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/output/test2.JPEG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/output/test3.JPEG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions Labels/001/3.member.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
3
20 69 87 164
100 72 169 167
171 75 238 184
3 changes: 3 additions & 0 deletions Labels/001/4.chiaki.aoi.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
2
41 68 131 179
114 20 200 128
6 changes: 6 additions & 0 deletions Labels/001/all_member.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
5
6 29 54 124
53 10 105 134
103 18 148 129
147 15 205 115
208 23 246 125
3 changes: 3 additions & 0 deletions Labels/001/simarin_and_nadeshiko.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
2
29 62 118 208
114 83 199 236
3 changes: 1 addition & 2 deletions Labels/001/test2.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
1
129 42 389 235
0
3 changes: 1 addition & 2 deletions Labels/001/test3.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
1
74 73 171 170
0
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ LabelTool
|--Labels/ *# direcotry for the labeling results*
|
|--Examples/ *# direcotry for the example bboxes*
|
|--rename_resize/ *# rename and resize Image file

Environment
----------
Expand All @@ -40,3 +42,14 @@ Usage
- To delete all existing bounding boxes in the image, simply click `ClearAll`.
3. After finishing one image, click `Next` to advance. Likewise, click `Prev` to reverse. Or, input an image id and click `Go` to navigate to the speficied image.
- Be sure to click `Next` after finishing a image, or the result won't be saved.

Usage resize_convert
-------
BBox tool's picture ext is "*.JPEG". But some jpeg file's ext is "*.jpg" "*.jpeg" "*.jpe". And, deeplearning framework has image sizes limit.

0. To check framework's image sizes limit.
1. Resize class's first argument is width, second argument is height.
2. Default resize size is 256 * 256. If you need it, you need to change
3. When you run this python file need 2 argument. 1st argument is path to image file. 2nd argument is path to output folder.

Convert and resize output sample exists to Images/output .
3 changes: 2 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ def loadImage(self):

# load labels
self.clearBBox()
self.imagename = os.path.split(imagepath)[-1].split('.')[0]
f_name = os.path.basename(imagepath)
self.imagename, ext = os.path.splitext(f_name)
labelname = self.imagename + '.txt'
self.labelfilename = os.path.join(self.outDir, labelname)
bbox_cnt = 0
Expand Down
43 changes: 43 additions & 0 deletions resize_convert/resize_rename.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import os
import sys
import glob
from PIL import Image

args = sys.argv
imagepath = os.path.abspath(args[1])
outpath = os.path.abspath(args[2])
imageList = []

if os.path.exists(os.path.abspath(outpath)) == False:
os.makedirs(os.path.abspath(outpath))

class Resize:
def __init__(self, width=256, height=256):
self.width = width
self.height = height
self.picture_size = (self.width, self.height)

def load_imagefile(self):
extlist = ["*.jpg", "*.jpeg", "*.JPEG", "*.jpe"]
for e in extlist:
filelist = glob.glob(os.path.join(imagepath, e))
imageList.extend(filelist)

def resize_imagefile(self):
for img in imageList:
resized_img = Image.open(img)
image = resized_img.resize(self.picture_size)
basename = os.path.basename(img)
name, ext = os.path.splitext(basename)

if ext is not ".JPEG":
ext = ".JPEG"

imgname = name + ext
image.save(os.path.join(outpath, imgname))


if __name__=='__main__':
resize = Resize(416, 416)
resize.load_imagefile()
resize.resize_imagefile()