Forums

mediapipe on pythonanywhere

I'm new on pythonanywhere, does anyone can help me with the following code which encounting permission denied problem and tensorflow issues. thank you.

import cv2 as cv
import mediapipe as mp
import numpy as np
from flask import Flask, request
#from mysql import id, name

# Link the website to open
app = Flask(__name__)
app.config

# Delclare variables
mpHands = mp.solutions.hands
hands = mpHands.Hands()
nailID = [4, 8, 12, 16, 20]
nailImg = ""

@app.route("/", methods=["GET", "POST"])
# Image processing (OpenCV)


def imgProc(img):
    gray = cv.cvtColor(img, cv.COLOR_BGR2RGB)
    handDet = hands.process(gray)
    return handDet


# Run functions
def main():
    vidCap = cv.VideoCapture(0)
    while True:
        # Capture and display camera screen
        cam, frame = vidCap.read()
        handDet = imgProc(frame)
        imgRender(frame, handDet)
        cv.imshow("Try On!", frame)

        if cv.waitKey(1) == ord('q'):
            vidCap.release()
            cv.destroyAllWindows()

if __name__ == "__main__":
    # app.run(debug=True)
    app.run(debug=True,port=80)
    main()

[edit by admin: formatting]

What are the problem and issues?

There is the problem of 'Permission denied. Do I need change the default default wsgi.py? thanks,

Could you give us the full error message, including the stacktrace?

error

2023-06-27 16:26:35.851140: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: li
bcudart.so.11.0: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /home/tryon/.local/lib/python3.10/site-packages/cv2/../../lib6
4:
2023-06-27 16:26:35.851173: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machin
e.
 * Serving Flask app 'nailD' (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: on
Permission denied
INFO: Created TensorFlow Lite XNNPACK delegate for CPU.

[edit by admin: formatting]

Unfortunately Tensorflow won't work in website code on PythonAnywhere. If you're using Keras with a TensorFlow backend, you can work around the issue -- just switch to using the Theano backend instead.

Do you have any suggestion for that? Is there any resources or documentations I can reference? Many thanks

Take a look at https://help.pythonanywhere.com/pages/MachineLearningInWebsiteCode