Comments (25)
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.
@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.
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 bewith open(filename, 'r') as f:
imageData = b64decode(data['imageData']).decode('utf-8')
should beimageData = b64decode(bytes(data['imageData'], 'utf-8'))
from labelme.
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.
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.
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.
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.
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.
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.
@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.
@landiaokafeiyan Your problem is different from the topic in this issue, right? If so, could you please open a new issue?
from labelme.
@ibadami i can install labelme on windows and ubuntu sucessfully. i have not test it on Mac
from labelme.
@wkentaro ok sure could you please fix the bug?
from labelme.
@landiaokafeiyan I think so.
from labelme.
@wkentaro many thanks
from labelme.
@ibadami I also tested on mac also, and it works. (fyi I use conda)
from labelme.
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.
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.
+1, same problem
from labelme.
Thanks for sharing this code.
I also meet this problem on windows with python3.6 and pyqt5
from labelme.
@l02i08u 's way works on my windows with Python 3.6. Thanks for his way.
from labelme.
Thank you @l02i08u + @y-wan ! These changes solved the problem for me, too! (also Python 3.6 on Windows)
from labelme.
@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.
Sorry for late, but I confirmed this issue on Python3.
#61 should fix this.
from labelme.
you may try insted of encode, decode.
from labelme.
Related Issues (20)
- Copy/Paste shortcut (Ctrl+C/Ctrl+V) doesn't work on 5.4.0
- The software can be opened normally, but it will crash when the next image is displayed HOT 2
- LabelMe Crashes with SegmentAnything Model (Speed Version) for Automatic Annotation
- Installation fails in python 3.12.1
- The program will automatically exit after a certain period of time
- ValueError: <labelme.shape.Shape object at 0x000001BFA54D6310> is not in list HOT 4
- Tupple index out of range and Invalid base64-encoded string: number of data characters cannot be 1 more than a multiple of 4
- Add two fingers zoom on touch screens
- Cant edit Group Id with string instead of int
- JSON file integration
- Suggest customizing the model directory
- Labelme can´t handle 32-bit tiff
- ADE20K dataset image file not open labelme version:5.4.1
- There seems to be an issue with certain objects in the label images generated by <labelme_export_json> when opened with PIL.Image.open, where the labels and pixels don't match up correctly.
- Running labelme2coco.py on Rectangle Annotations Sometimes Results in a ValueError in PIL: "y1 must be greater than or equal to y0"
- Display the total number of images
- no focus when lauched from wsl / win10
- labels.txt not able to read the label 'car'
- Getting core dump issue due to QT library
- Label Chinese input
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from labelme.