Spaces:
Runtime error
Runtime error
| import wget | |
| import os | |
| import socket | |
| hostname=socket.gethostname() | |
| IPAddr=socket.gethostbyname(hostname) | |
| if os.path.isfile("yolov7.pt") == False: | |
| wget.download("https://github.com/WongKinYiu/yolov7/releases/download/v0.1/yolov7.pt") | |
| import eventlet | |
| import socketio | |
| import base64 | |
| from blur import blur_check | |
| from detect import analyze | |
| sio = socketio.Server(cors_allowed_origins='*') | |
| app = socketio.WSGIApp(sio) | |
| MOCK_AI = os.getenv("MOCK_AI") == "true" | |
| def connect(sid, environ): | |
| print('connect ', sid) | |
| def webcam(sid, data): | |
| if MOCK_AI: | |
| return { | |
| "blurry": False, | |
| "detected": [{ | |
| "type": "person", | |
| "coords": [0,0,0,0], | |
| "conf": 1 | |
| }] | |
| } | |
| detect = analyze(str(data)) | |
| output = { | |
| "blurry": blur_check(data), | |
| "detected": analyze(str(data)) | |
| } | |
| print(output) | |
| return output | |
| def disconnect(sid): | |
| print('disconnect ', sid) | |
| if __name__ == '__main__': | |
| eventlet.wsgi.server(eventlet.listen((IPAddr, 5000)), app) | |