tkinjo1985 / lobe_fastapi Goto Github PK
View Code? Open in Web Editor NEWImage classification API using FastAPI and Lobe models
License: MIT License
Image classification API using FastAPI and Lobe models
License: MIT License
port 8000 is refusing connections from a browser and from command line.
Even on the same device:
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c627fdb99a2e lobefastapi_web "uvicorn main:app --…" 18 minutes ago Up 11 minutes 80/tcp, 0.0.0.0:8000->8000/tcp lobefastapi_web_1
# nc -vz localhost 8000
Connection to localhost 8000 port [tcp/*] succeeded!
# curl localhost:8000/docs
curl: (56) Recv failure: Connection reset by peer
# curl http://127.0.0.1:8000/docs
curl: (56) Recv failure: Connection reset by peer
docker exec -i -t lobefastapi_web_1 bashroot@c627fdb99a2e:/work# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.5 0.2 25972 17624 pts/0 Ss+ 22:15 0:05 /usr/local/bin/python /usr/local/bin/uvicorn main:app --reload --host 0.0.0.0 --port 8000
root 8 0.0 0.1 13156 9864 pts/0 S+ 22:15 0:00 /usr/local/bin/python -c from multiprocessing.resource_tracker import main;main(4)
root 9 0.0 0.0 0 0 pts/0 Z+ 22:15 0:00 [python] <defunct>
root 51 0.0 0.0 5748 3552 pts/1 Ss 22:32 0:00 bash
root 57 0.0 0.0 9388 3096 pts/1 R+ 22:33 0:00 ps aux
root@c627fdb99a2e:/work# curl http://127.0.0.1:8000/docs
curl: (7) Failed to connect to 127.0.0.1 port 8000: Connection refused
Hello there,
I just booted this up to test the functionality with the stated docker commands and it returns me an error when uploading a picture. I have only a couple of minutes of experience with the script but will try to understand what the actual error is.
INFO: 172.19.0.1:40258 - "POST /predict_from_image/ HTTP/1.1" 500 Internal Server Error ERROR: Exception in ASGI application Traceback (most recent call last): File "/usr/local/lib/python3.8/dist-packages/uvicorn/protocols/http/h11_impl.py", line 366, in run_asgi result = await app(self.scope, self.receive, self.send) File "/usr/local/lib/python3.8/dist-packages/uvicorn/middleware/proxy_headers.py", line 75, in __call__ return await self.app(scope, receive, send) File "/usr/local/lib/python3.8/dist-packages/fastapi/applications.py", line 261, in __call__ await super().__call__(scope, receive, send) File "/usr/local/lib/python3.8/dist-packages/starlette/applications.py", line 112, in __call__ await self.middleware_stack(scope, receive, send) File "/usr/local/lib/python3.8/dist-packages/starlette/middleware/errors.py", line 181, in __call__ raise exc File "/usr/local/lib/python3.8/dist-packages/starlette/middleware/errors.py", line 159, in __call__ await self.app(scope, receive, _send) File "/usr/local/lib/python3.8/dist-packages/starlette/exceptions.py", line 82, in __call__ raise exc File "/usr/local/lib/python3.8/dist-packages/starlette/exceptions.py", line 71, in __call__ await self.app(scope, receive, sender) File "/usr/local/lib/python3.8/dist-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__ raise e File "/usr/local/lib/python3.8/dist-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__ await self.app(scope, receive, send) File "/usr/local/lib/python3.8/dist-packages/starlette/routing.py", line 656, in __call__ await route.handle(scope, receive, send) File "/usr/local/lib/python3.8/dist-packages/starlette/routing.py", line 259, in handle await self.app(scope, receive, send) File "/usr/local/lib/python3.8/dist-packages/starlette/routing.py", line 61, in app response = await func(request) File "/usr/local/lib/python3.8/dist-packages/fastapi/routing.py", line 227, in app raw_response = await run_endpoint_function( File "/usr/local/lib/python3.8/dist-packages/fastapi/routing.py", line 160, in run_endpoint_function return await dependant.call(**values) File "/work/./main.py", line 38, in predict label = model.predict(image) File "/work/./model.py", line 50, in predict predict = self.infer(image)['Prediction'][0] KeyError: 'Prediction'
Hello,
something does not work for me using the base64 detection endpoint:
INFO: 172.19.0.1:40262 - "POST /predict_from_base64/ HTTP/1.1" 500 Internal Server Error ERROR: Exception in ASGI application Traceback (most recent call last): File "/usr/local/lib/python3.8/dist-packages/uvicorn/protocols/http/h11_impl.py", line 366, in run_asgi result = await app(self.scope, self.receive, self.send) File "/usr/local/lib/python3.8/dist-packages/uvicorn/middleware/proxy_headers.py", line 75, in __call__ return await self.app(scope, receive, send) File "/usr/local/lib/python3.8/dist-packages/fastapi/applications.py", line 261, in __call__ await super().__call__(scope, receive, send) File "/usr/local/lib/python3.8/dist-packages/starlette/applications.py", line 112, in __call__ await self.middleware_stack(scope, receive, send) File "/usr/local/lib/python3.8/dist-packages/starlette/middleware/errors.py", line 181, in __call__ raise exc File "/usr/local/lib/python3.8/dist-packages/starlette/middleware/errors.py", line 159, in __call__ await self.app(scope, receive, _send) File "/usr/local/lib/python3.8/dist-packages/starlette/exceptions.py", line 82, in __call__ raise exc File "/usr/local/lib/python3.8/dist-packages/starlette/exceptions.py", line 71, in __call__ await self.app(scope, receive, sender) File "/usr/local/lib/python3.8/dist-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__ raise e File "/usr/local/lib/python3.8/dist-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__ await self.app(scope, receive, send) File "/usr/local/lib/python3.8/dist-packages/starlette/routing.py", line 656, in __call__ await route.handle(scope, receive, send) File "/usr/local/lib/python3.8/dist-packages/starlette/routing.py", line 259, in handle await self.app(scope, receive, send) File "/usr/local/lib/python3.8/dist-packages/starlette/routing.py", line 61, in app response = await func(request) File "/usr/local/lib/python3.8/dist-packages/fastapi/routing.py", line 227, in app raw_response = await run_endpoint_function( File "/usr/local/lib/python3.8/dist-packages/fastapi/routing.py", line 160, in run_endpoint_function return await dependant.call(**values) File "/work/./main.py", line 46, in predict_from_base64 decimg = cv2.imdecode(image_np, 1).astype(np.float32) / 225.0 AttributeError: 'NoneType' object has no attribute 'astype
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.