Comments (6)
Python 3 doesn't handle base64 encoding (which is a pure ASCII encoding) the same way as Python 2.
You can use this function instead:
import base64
def convertImage(imgData1):
imgstr = re.search(b'data:image/png;base64,(.*)', imgData1).group(1)
with open('output.png', 'wb') as output:
output.write(base64.b64decode(imgstr))
If you pass the image to Python through the "Predict" button, something like this gets returned:
b'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAARgAAAEYCAYAAACHjumMAAAdlklEQVR4Xu2de2jX1RvHH295XWppKAbOFDQvqJFibEwNpgZBin+UWOiwkChzpqKx2VxqKrm8VGSgTUElQ0ihUFfkbSPUnIrWjLxGorHBnNeVU388Xz
With the regex, you remove the part before the actual image data.
You also need to change the paths in the load.py file if you place your models in a "model" folder.
from how_to_deploy_a_keras_model_to_production.
I'm using python 3 and then got this error
from how_to_deploy_a_keras_model_to_production.
wow! I know the first part of base64 string . but I don't know how to remove it.
Amazing, now I can fix it ✌️ thank you
from how_to_deploy_a_keras_model_to_production.
OK, Thanks @frankherfert . Problem solved.
from how_to_deploy_a_keras_model_to_production.
Traceback (most recent call last):
File "netconf_tool.py", line 18, in
tn.read_until("login: ")
File "C:\lib\telnetlib.py", line 302, in read_until
i = self.cookedq.find(match)
TypeError: a bytes-like object is required, not 'str'
Code snippet:
!/usr/bin/env python
import getpass
import sys
import telnetlib
import re
import pexpect
import base64
OST = str(sys.argv[1])
#user = raw_input("Enter your remote account: ")
#password = getpass.getpass()
user = "gss"
password = "pureethernet"
tn = telnetlib.Telnet(HOST)
tn.read_until("login: ")
tn.write(user + "\n")
if password:
tn.read_until("Password: ")
tn.write(password + "\n")
f = open("C:\djangogirls\blog\templates\startup-config.txt", "rb")
output.write(base64.b64decode(f))
from how_to_deploy_a_keras_model_to_production.
frankherfert: Would you please help me when I have the same error with the following code:
self.kmeans = load(open('data/kmeans_2.dat', 'r'))
from how_to_deploy_a_keras_model_to_production.
Related Issues (10)
- While Deploying the model i am getting this error : HOT 1
- how to reload the model every day?
- missing requirement versions
- Not found: Resource localhost/dense_2/bias/class tensorflow::Var does not exist.
- Invalid Syntax in file app.py
- what version of python do you use? HOT 2
- cannot use a string pattern on a bytes-like object HOT 3
- Use TF 13 instead of 11
- def index()
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 how_to_deploy_a_keras_model_to_production.