GithubHelp home page GithubHelp logo

Comments (25)

l02i08u avatar l02i08u commented on August 24, 2024 7

I tested in this way on windows, and it worked.
In labelFile.py
def save(...): with open(filename, 'wb') as f: if six.Py3: imagedata=b64encode(imageData.decode('utf-8') should be with open(filename, 'w') as f: if six.Py3: imagedata=str(b64encode(imageData), 'utf-8')

from labelme.

ibadami avatar ibadami commented on August 24, 2024 3

@wkentaro @jjdblast @patrickcgray
So I found two problems with the encoding bug.
in labelFile.py in def save(self, filename, shapes, imagePath, imageData, lineColor=None, fillColor=None):
1.with open(filename, 'wb') as f: should be with open(filename, 'w') as f: because not all the data we would like to save in json is in binary.
2. imageData = b64encode(imageData.encode('utf-8')) should be imageData = b64encode(imageData).decode('ascii') this will convert the binary image to string.

As a final step one must correct the load function as well.
this will save the json file with ascii image data in base64.
This is suggested for python3, I am sure the change in python2 is similar.

from labelme.

y-wan avatar y-wan commented on August 24, 2024 3

Thanks, @l02i08u 's way works for me as well while saving a file (Python 3.6 on Windows). However, when opening a json file saved in this way, the following code in labelFile.py should also be modified, otherwise similar encoding issues would occur:
(under def load(self, filename):)

  • with open(filename, 'rb') as f: should be with open(filename, 'r') as f:
  • imageData = b64decode(data['imageData']).decode('utf-8') should be imageData = b64decode(bytes(data['imageData'], 'utf-8'))

from labelme.

runforever avatar runforever commented on August 24, 2024 2

os: windows 10
python: 3.6.4
pyqt5

change labelFile.py file save method

with open(filename, 'w') as f: 
    if six.Py3:
       imagedata=str(b64encode(imageData), 'utf-8')

change labelFile.py file load method

with open(filename, 'r') as f:
    if six.PY3:
        imageData = b64decode(bytes(data['imageData'], 'utf-8'))

works

thanks @l02i08u @y-wan , you are life saver

from labelme.

peyman-sabouri avatar peyman-sabouri commented on August 24, 2024 1

I used the following and solved the problem:

$ pip3 install SIP
$ pip3 install pyqt5
$ pip install labelme ( it did not worked with pip3)

from labelme.

jjdblast avatar jjdblast commented on August 24, 2024

I also meet this problem, the error message exactly the same with patrick's

my environment :

Ubuntu 16.04, Anaconda 4, Python 2.7

from labelme.

landiaokafeiyan avatar landiaokafeiyan commented on August 24, 2024

Hi,Thanks for sharing the code,I find a BUG that when I use the tool,if i sliding mouse,the tool will exit。what i have to do if i want to run the code and fix the bug?

from labelme.

wkentaro avatar wkentaro commented on August 24, 2024

I tested in below environment, and they all works. Could you please specify the version again?

with labelme==2.6.2

  • python2.7 + pyqt5 + linux (work)
  • python2.7 + pyqt4 + linux (work)
  • python3.6 + pyqt5 + linux (work)
  • python3.6 + pyqt4 + linux (work)
  • python2.7 + pyqt5 + mac (not tested)
  • python2.7 + pyqt4 + mac (not tested)
  • python3.5 + pyqt5 + mac (work)
  • python3.5 + pyqt4 + mac (work)

from labelme.

ibadami avatar ibadami commented on August 24, 2024

Could it be that this problem is platform specific? I am also running on mac OS and I faced the same problem.
Did you test it on mac?

from labelme.

landiaokafeiyan avatar landiaokafeiyan commented on August 24, 2024

@kentaro Wad i can install labelme on windows and ubuntu sucessfully. the problem is that when i use labeme to label the image, i will exit the GUI when i slide the mouse pulley.

from labelme.

wkentaro avatar wkentaro commented on August 24, 2024

@landiaokafeiyan Your problem is different from the topic in this issue, right? If so, could you please open a new issue?

from labelme.

landiaokafeiyan avatar landiaokafeiyan commented on August 24, 2024

@ibadami i can install labelme on windows and ubuntu sucessfully. i have not test it on Mac

from labelme.

landiaokafeiyan avatar landiaokafeiyan commented on August 24, 2024

@wkentaro ok sure could you please fix the bug?

from labelme.

wkentaro avatar wkentaro commented on August 24, 2024

@landiaokafeiyan I think so.

from labelme.

landiaokafeiyan avatar landiaokafeiyan commented on August 24, 2024

@wkentaro many thanks

from labelme.

wkentaro avatar wkentaro commented on August 24, 2024

@ibadami I also tested on mac also, and it works. (fyi I use conda)

from labelme.

ibadami avatar ibadami commented on August 24, 2024

I too used conda.
I am using pyqt5 and python 3.5 and you tested on them as well.
This is very surprising.

from labelme.

ibadami avatar ibadami commented on August 24, 2024

What I do not understand is. When you read the image data using read function in app.py it is read as a binary data. Then how can you encode that binary data in utf-8 during saving. When I googled the error message, I found that this error occurs because the binary data cannot be further encoded.

from labelme.

artstreltsov avatar artstreltsov commented on August 24, 2024

+1, same problem

from labelme.

wangchenghan avatar wangchenghan commented on August 24, 2024

Thanks for sharing this code.
I also meet this problem on windows with python3.6 and pyqt5

from labelme.

hgs1217 avatar hgs1217 commented on August 24, 2024

@l02i08u 's way works on my windows with Python 3.6. Thanks for his way.

from labelme.

MischaSchwendy avatar MischaSchwendy commented on August 24, 2024

Thank you @l02i08u + @y-wan ! These changes solved the problem for me, too! (also Python 3.6 on Windows)

from labelme.

blakeliu avatar blakeliu commented on August 24, 2024

@y-wan
My os is windows 10 ,and anaconda 3 with python 3.5.4
def load(self, filename): try: with open(filename, 'r') as f: data = json.load(f) imagePath = data['imagePath'] if six.PY3: imageData = b64decode(bytes(data['imageData'], 'utf-8')) elif six.PY2: imageData = b64decode(data['imageData'])

def save(self, filename, shapes, imagePath, imageData, lineColor=None, fillColor=None): try: with open(filename, 'w') as f: if six.PY3: imageData = str(b64encode(imageData), 'utf-8') #b64encode(imageData.encode('utf-8')) elif six.PY2: imageData = b64encode(imageData)
When I load json file:
Traceback (most recent call last):
File "C:\Anaconda3\lib\site-packages\labelme-2.6.4-py3.5.egg\labelme\app.py", line 780, in openFile
File "C:\Anaconda3\lib\site-packages\labelme-2.6.4-py3.5.egg\labelme\app.py", line 665, in loadFile
AttributeError: 'bytes' object has no attribute 'encode'

from labelme.

wkentaro avatar wkentaro commented on August 24, 2024

Sorry for late, but I confirmed this issue on Python3.
#61 should fix this.

from labelme.

rafaelvalero avatar rafaelvalero commented on August 24, 2024

you may try insted of encode, decode.

from labelme.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.