#๐Ÿ”’ Machine learning problem

6 messages ยท Page 1 of 1 (latest)

rocky wraithBOT
#

@spare gull

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

#

Hey @spare gull!

Please edit your message to use a code block

You are using the wrong character instead of backticks. Use ```, not """.

Also, add a py after the three backticks.

```py
print('Hello, world!')
```

This will result in the following:

print('Hello, world!')```
spare gull
#
import time
import time
import numpy as np
from tensorflow.keras.models import loadmodel

capturas= cv.VideoCapture("prueba 1.mp4")
def prediction(image, model):
    img= cv.resize(image,(28,28))
    img=img/255
    img=img.reshape(1,28,28,1)
    predict=model.predict(img)
    prob= np.amax(predict)
    class_index=model.predict.classes(img)
    result= class_index[0]
    if prob<.75:
        result=0
        prob=0
        return result,prob


"""templates = {}
for i in range(10):
    template_path = os.path.join("templates", f"{i}.png")
    template_image = cv.imread(template_path, cv.IMREAD_GRAYSCALE)
    template_image = cv.resize(template_image, (40, 60))
    templates[i] = template_image"""

model= load_model("model,digits.h5")

while True:
    ret, frame = capturas.read()
    if not ret:
        break

    
    cv.rectangle(frame, (20,100), (260,20), (255,0,0), 2)
    cv.rectangle(frame, (1090,100), (1325,20), (0,0,255), 2)
    blue_alliance=frame[20:100, 20:260]
    red_alliance=frame[20:100, 1090:1325]
    
    blue_gray = cv.cvtColor(blue_alliance, cv.COLOR_BGR2GRAY)

    blue_thresh = cv.threshold(blue_gray, 150, 255, cv.THRESH_BINARY_INV)

    result,prob=prediction(blue_thresh,model)
    print(result,prob)

    cv.imshow("video", frame)
    cv.imshow("xd",blue_alliance)
    cv.imshow("xd2",red_alliance)

    if cv.waitKey(1) == 27:
        break


capturas.release()
cv.destroyAllWindows()
stuck grotto
#

If nothing is printed, I imagine that ret is False

rocky wraithBOT
#
Python help channel closed using Discord native close action

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.