github – AttributeError: The object's str & # 39; has no attribute 'shape'

I'm trying to run this script on my image for image classification using the CNN template:

import cv2
import tensorflow as a tf

CATEGORIES = ("Banana", "Bare ground", "Okra", "Sugar cane")

def prepare (file):
IMG_SIZE = 50
img_array = cv2.imread (file, cv2.IMREAD_GRAYSCALE)
new_array = cv2.resize (img_array, (IMG_SIZE, IMG_SIZE))
returns new_array.reshape (-1, IMG_SIZE, IMG_SIZE, 1)

model = tf.keras.models.load_model ("CNN.model")

image = r "C: / Users / admin / Office / Endline dataset / Dataset / Test / one.jpg" #your image path

prediction = model.predict ((image))
prediction = list (prediction (0))
print (CATEGORIES (prediction.index (max (prediction)))))

But, getting the following error:

AttributeError: The object 'str' has no attribute 'shape'

python – The object & # 39; tuple & # 39; AttributeError does not have attribute "pie" – matplotlib

I'm trying to create a pie chart with matplotlib to add it to a tkinter graphical interface, but I get this error.

enter the description of the image here

The code that is

    Labels = 'Pendientes positivas', 'Pendientes negativas', 'Resistencias horizontales'
    sizes = (pendientes_positivas, pendientes_negativas, horizontales)
    graficoTorta = plt.subplots()
    graficoTorta.pie(sizes, labels = Labels)
    canvas = FigureCanvasTkAgg(graficoTorta, frame_Resistencias_M5)
    canvas.get_tk_widget().place(x = 400, y = 60)

Variables in sizes are integers that acquire their values ​​in another part of the program.

In addition, when I open the list of classes, I do not see 'foot & # 39; as an attribute

enter the description of the image here

I do not know if this has anything to do but I imagine that it should be there.
I am based on a code taken from an example of the documentation of matplotlib

import matplotlib.pyplot as plt

# Pie chart, where the slices will be ordered and plotted counter-clockwise:
labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
sizes = (15, 30, 45, 10)
explode = (0, 0.1, 0, 0)  # only "explode" the 2nd slice (i.e. 'Hogs')

fig1, ax1 = plt.subplots()
ax1.pie(sizes, explode=explode, labels=labels, autopct='%1.1f%%',
        shadow=True, startangle=90)
ax1.axis('equal')  # Equal aspect ratio ensures that pie is drawn as a circle.
plt.show()

What does the following chart generate for me?

enter the description of the image here

django – AttributeError in / posts / add / The object PostForm & # 39; does not have attribute 'cleaner_data & # 39;

Display the PostForm class on the metodo which is valid for work formulas, but which is not restored or for the one that is cleaned, but which is already updated:

AttributeError to / posts / add /
The object & # 39; PostForm & # 39; does not have attribute 'cleaner_data & # 39;

postform

PostForm class (forms.Form):
image = forms.ImageField (required = False)
content = forms.CharField (widget = forms.Textarea, required = False)

def is_valid (self):
valid = true
image = self.cleaned_data.get ('image')
content = self.cleaned_data.get ('content')

if the picture is None and the content is None:
self.add_error (& # 39; Only texting precisions / or uma imagem & # 39;)
valid = false

valid return

def add_error (self, message):
errors = self._errors.setdefault (forms.forms.NON_FIELD_ERRORS, forms.utils.ErrorList ())
errors.append (message)

View

@Connection required
def add_post (request):
if request.method == & # 39; POST & # 39 ;:
form = PostForm (request.POST, request.FILES)

if form.is_valid ():
data_form = form.cleaned_data
Post.objects.create (image = data_form['image'], content = data_form['content'], user = request.user)

return the redirection (& # 39; index & # 39;)

other:
return the redirection (& # 39; index & # 39;)

python3 – See & # 39; AttributeError: __enter __ & # 39; when we expect to see the answers of the Rasa bot

I'm trying to follow a post to create and run a Rasa bot.

The steps have already done:
– I could have all the working files
– You have the basic data files
– Nlu and Core trained
– launched action server and command line
– In this case, the wait is that the user enters the entry as "hello or hello", then the robot answers and chases the cat

Actual results: See the error below.

to make cmdline
python -m rasa_core.run -d templates / current / dialog -u templates / current / nlu --endpoints endpoints.yml
C:  Python3.6  lib  site-packages  h5py  __ init__.py:36: FutureWarning: The conversion of the second argument of issubdtype from `float` to` np.floating` is deprecated. In the future, it will be treated as `np.float64 == np.dtype (float) .type`.
from ._conv import register_converters as _register_converters
2019-05-14 17:06:45 INFO root - The Rasa process starts
2019-05-14 17:06:49 INFO rasa_nlu.components - Added 'nlp_spacy' to the component cache. Nlp_spacy-en key.
2019-05-14 17: 07: 18.101829: I have tensorflow / core / platform / cpu_feature_guard.cc: 141]Your CPU supports the instructions that this TensorFlow binary was not compiled for use: AVX2
2019-05-14 17:07:19 INFO root - The Rasa Core server is operational on http: // localhost: 5005
Bot loaded. Type a message and press Enter (use & stop / exit to exit):
Your entry -> hey
127.0.0.1 - - [2019-05-14 17:08:23] "POST / webhooks / rest / webhook? Stream = true & token = HTTP / 1.1" 200 190 0.254340
Exception in thread Thread-1:
Traceback (last most recent call):
"C:  Python3.6  lib  threading.py" file, line 916, in _bootstrap_inner
self.run ()
"C:  Python3.6  lib  threading.py" file, line 864, in progress
self._target (* self._args, ** self._kwargs)
"C:  Python3.6  lib  site-packages  rasa_core  channels  console.py" file, line 114, in record_messages
for the answer in bot_responses:
"C:  Python3.6  lib  site-packages  rasa_core  channels  console.py" file, line 71, in send_message_receive_stream
with requests.post (url, json = payload, flow = true) as r:
AttributeError: __enter__

When doing preliminary searches on forums, it seems like it's a Python code problem. As I understand it, try to get the answers from the robots using the keyword 'WITH'.

Indications on how can I sort it please?
Thanks in advance,
Venky

ios – AttributeError: The "sequential object" does not have the attribute "rfind & # 39;

I'm trying to convert my model using coremltools with the version details below

Python - 2.7
keras - 2.1.6
Tensorflow - 1.9

and other related addictions ..

Get an error below when running the code to convert

sepIndex = p.rfind (sep)
AttributeError: The "sequential object" does not have the attribute "rfind & # 39;

import numpy as np
bone import
from keras.models import model_from_json
import coremltools
path = os.getcwd ()
#path = input ("Enter the saved template path->")
# path = path.strip ()


# Load weights and models
json_file = open (os.path.join (path, LMN.json), & rt; r & # 39;)
model_json = json_file.read ()

model = model_from_json (model_json)
model.load_weights (os.path.join (path, LMN.h5))
# model.compile (optimizer = adam, loss = binary_crossentropy, metrics =['accuracy'])

# convert the template to Core ML
coreml_model = coremltools.converters.keras.convert (template, input_name = "input", output_name = "output")

# define the general metadata of the model
coreml_model.author = & # 39; ABC & # 39;
coreml_model.license = & # 39; XYZ & # 39;
coreml_model.short_description = & # 39; some details & # 39;

# define the model input information
coreml_model.input_description['input'] = & # 39; some details & # 39;

# define the output information of the model
coreml_model.output_description['output'] = & # 39; some details & # 39;

f_name, f_ext = os.path.splitext (template)
coreml_model.save (os.path.join (path, f_name + & # 39; .mlmodel & # 39;))

I went through git and found problems like this but I tried and I am unable to fix it. Need specific help.

AttributeError: The object 'NoneType & # 39; does not have attribute 'scenePos & # 39;

Here is my sample code. I want to print the coordinates of my x, y positions with the help of the mouse press event. I have this error. Please, help me and I want to display the graphic view in the middle of the scrollArea screen.

Below is my code:

since pyface.qt import QtGui, QtCore
import system

MyView class (QtGui.QGraphicsView):
def __init __ (auto):
QtGui.QGraphicsView .__ init __ (self)
self.row = 2
auto.cols = 4
self.scene = QtGui.QGraphicsScene (0,0500,500)
self.List = []

        for i in the range (self.row):
for j in the range (self.cols):
item = self.scene.addRect (QtCore.QRectF (0,0,30,30))
item.setPos (30 + j * 30,500-i * 30-60)
print item.scenePos ()
self.List.append (item)
self.setScene (self.scene)
def mousePressEvent (self, event):
super (MyView, auto) .mousePressEvent (event)
p = QtCore.QPointF (event.pos ())
print "positonnnnnnnnnnnnnnnnn", p
item = self.scene.itemAt (p)
print "@@@@@@@@@@@@@@@@@@@@@@@@@"
print item.scenePos ()
Class Parameters (QtGui.QMainWindow):
def __init __ (self, parent = None):
super (Settings, auto) .__ init __ (parent)
spacer = QtGui.QWidget (auto)
spacer.setSizePolicy (QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
QtGui.QToolTip.setFont (QtGui.QFont (& # 39; SansSerif & # 39 ;, 10))
self.vbox = QtGui.QVBoxLayout ()
self.save = QtGui.QPushButton ("save")
self.open = QtGui.QPushButton ("open")
self.folder = QtGui.QPushButton ("Folder")
self.folder.clicked.connect (self.showSettings)
self.vbox.addWidget (self.save)
self.vbox.addWidget (self.open)
self.vbox.addWidget (self.folder)
self.grid = QtGui.QGridLayout ()
self.grid.addLayout (self.vbox, 0,0)
self.scrollArea = QtGui.QScrollArea ()
self.scrollArea.setBackgroundRole (QtGui.QPalette.Light)
self.scrollArea.setWidgetResizable (True)
self.grid.addWidget (self.scrollArea, 0,1)
self.setCentralWidget (QtGui.QWidget (auto))
self.centralWidget (). setLayout (self.grid)
self.setGeometry (200, 100, 300, 300)
auto.show ()
def showSettings (auto):
self.newwidget = QtGui.QWidget ()
self.glayout = QtGui.QGridLayout (self.newwidget)
self.MyView = MyView ()
self.glayout.addWidget (self.MyView, 0,1)
self.scrollArea.setWidget (self.newwidget)
def ():
app = QtGui.QApplication (sys.argv)
ex = Parameters ()
sys.exit (app.exec_ ())
if __name__ == __ __ hand __:
main ()