sieci.md
This commit is contained in:
parent
0b6b08f7ae
commit
ec0d6b9aa0
28
sieci.md
28
sieci.md
@ -63,26 +63,22 @@ trenuję model za pomocą funkcji fit()
|
||||
# Integracja z projektem
|
||||
Tworzę model i ładuję wagi nauczonego modelu.
|
||||
|
||||
image_cl = Sequential()
|
||||
ImageClass(image_cl)
|
||||
image_cl.load_weights('model_weights.h5')
|
||||
nmodel = Sequential()
|
||||
imageClass(nmodel)
|
||||
nmodel.load_weights('model_weights.h5')
|
||||
|
||||
Po podniesieniu paczki odpalana jest funkcja imgSkan(), która z czytuje ręcznie napisaną cyfrę i wpisuje nr producenta paczki.
|
||||
|
||||
def imgSkan():
|
||||
img = files.upload()
|
||||
!ls
|
||||
img_path = '2.png'
|
||||
img = image.load_img(img_path, target_size=(28, 28), color_mode = "grayscale")
|
||||
plt.imshow(img.convert('RGBA'))
|
||||
plt.show()
|
||||
x = image.img_to_array(img)
|
||||
x = np.expand_dims(x, axis=0)
|
||||
x = 255 - x
|
||||
x /= 255
|
||||
prediction = model.predict(x)
|
||||
prediction = np.argmax(prediction)
|
||||
print("Cyfra:", prediction)
|
||||
img_width, img_height = 28, 28
|
||||
new_image = load_img('cyfra.png', target_size=(img_width, img_height), color_mode = "grayscale")
|
||||
new_image = img_to_array(new_image)
|
||||
new_image = new_image.reshape((1,) + new_image.shape)
|
||||
|
||||
prediction = nmodel.predict(new_image)
|
||||
prediction = numpy.argmax(prediction)
|
||||
print("Producent:", prediction)
|
||||
producent.append(prediction)
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user