HumanSignal / labelImg

LabelImg is now part of the Label Studio community. The popular image annotation tool created by Tzutalin is no longer actively being developed, but you can check out Label Studio, the open source data labeling tool for images, text, hypertext, audio, video and time-series data.
https://youtu.be/p0nR2YsCY_U
MIT License
22.77k stars 6.31k forks source link

impossible to save : float division by zero #462

Open lucydjo opened 5 years ago

lucydjo commented 5 years ago

Hi,

Does not want to record labels. I have tried with several versions, nothing works. How to fix ?

I only have two very large images. High-precision satellite photo (15kX15k). I have to get more than 1000 labels per photo

Img: C:\Users\wkn\Documents\IA\ortoIA\images\png5ca3a3d5e5635f000690af6b.png -> Its txt: C:\Users\wkn\Documents\IA\ortoIA\labels\png5ca3a3d5e5635f000690af6b.txt
Traceback (most recent call last):
  File "<string>", line 1291, in saveFile
  File "<string>", line 1320, in _saveFile
  File "<string>", line 808, in saveLabels
  File "Z:\home\darrenl\tmp\labelImg\build-tools\build\labelImg\out00-PYZ.pyz\libs.labelFile", line 83, in saveYoloFormat
  File "Z:\home\darrenl\tmp\labelImg\build-tools\build\labelImg\out00-PYZ.pyz\libs.yolo_io", line 64, in save
  File "Z:\home\darrenl\tmp\labelImg\build-tools\build\labelImg\out00-PYZ.pyz\libs.yolo_io", line 36, in BndBox2YoloLine
ZeroDivisionError: float division by zero

Thx !

erquren commented 5 years ago

can you show your xml file?because its mean your size is zero

DynamicCodes commented 4 years ago

i faced the same problem, this happens due to transparency in the some images, i dnt know what kind of transparency is this,......but it can be solved by opening the image with opencv and saving it again, it worked for me.

i wrote this python file :--

import cv2 import os

def loadImages(path = "."):

return [os.path.join(path, f) for f in os.listdir(path) if f.endswith('.jpg')]

filenames = loadImages() images = [] for file in filenames: images.append(cv2.imread(file, cv2.IMREAD_UNCHANGED))

num = 0 for image in images: cv2.imwrite(str(num)+".jpg",image) num += 1

it will open every file in the directory and save it again!!

kit57 commented 4 years ago

What image format are you labelling? I had the same error when I was labelling .png images. It only worked for me with .jpg images.