Giter VIP home page Giter VIP logo

Comments (6)

frankherfert avatar frankherfert commented on August 24, 2024 2

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.

khangprolxag avatar khangprolxag commented on August 24, 2024

I'm using python 3 and then got this error

from how_to_deploy_a_keras_model_to_production.

khangprolxag avatar khangprolxag commented on August 24, 2024

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.

kashyap32 avatar kashyap32 commented on August 24, 2024

OK, Thanks @frankherfert . Problem solved.

from how_to_deploy_a_keras_model_to_production.

HemantBelwal avatar HemantBelwal commented on August 24, 2024

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.

fi000 avatar fi000 commented on August 24, 2024

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)

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.