Comments (5)
@Sieboldianus I ran into this issue, it still comes up running the current master
. Can I suggest to keep this issue open until #43 is closed?
from full-stack-fastapi-postgresql.
Thanks for the report and discussion here everyone!
This should be fixed in the current master. 🎉 🚀
So I guess we could close this issue, right @Sieboldianus ?
from full-stack-fastapi-postgresql.
Just noticed that this seems already addressed in PR 43. I've tested the PR and it works! This can be closed..
from full-stack-fastapi-postgresql.
I can confirm I have the same issue running the current master
. Thanks.
Edit:
I can also confirm that #43 seems to address the "Exception in ASGI".
This is awesome! Thanks.
from full-stack-fastapi-postgresql.
Can any one explain where to add the changes ??
i am little bit confused :)
P.S: I am a complete rookie into fastapi
I am using POSTman to upload an image to the server ..but showing internal server error..can anyone help me with this!!
using the latest version of every library .
Error Log:
Started server process [4532]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://localhost:8000 (Press CTRL+C to quit)
INFO: ::1:49810 - "GET /ping HTTP/1.1" 200 OK
INFO: ::1:49811 - "GET /predict HTTP/1.1" 405 Method Not Allowed
INFO: ::1:49819 - "POST /predict HTTP/1.1" 500 Internal Server Error
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "C:\Users\ajith\AppData\Local\Programs\Python\Python310\lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 366, in run_asgi
result = await app(self.scope, self.receive, self.send)
File "C:\Users\ajith\AppData\Local\Programs\Python\Python310\lib\site-packages\uvicorn\middleware\proxy_headers.py", line 75, in call
return await self.app(scope, receive, send)
File "C:\Users\ajith\AppData\Local\Programs\Python\Python310\lib\site-packages\fastapi\applications.py", line 261, in call
await super().call(scope, receive, send)
File "C:\Users\ajith\AppData\Local\Programs\Python\Python310\lib\site-packages\starlette\applications.py", line 112, in call
await self.middleware_stack(scope, receive, send)
File "C:\Users\ajith\AppData\Local\Programs\Python\Python310\lib\site-packages\starlette\middleware\errors.py", line 181, in call
raise exc
File "C:\Users\ajith\AppData\Local\Programs\Python\Python310\lib\site-packages\starlette\middleware\errors.py", line 159, in call
await self.app(scope, receive, _send)
File "C:\Users\ajith\AppData\Local\Programs\Python\Python310\lib\site-packages\starlette\exceptions.py", line 82, in call
raise exc
File "C:\Users\ajith\AppData\Local\Programs\Python\Python310\lib\site-packages\starlette\exceptions.py", line 71, in call
await self.app(scope, receive, sender)
File "C:\Users\ajith\AppData\Local\Programs\Python\Python310\lib\site-packages\fastapi\middleware\asyncexitstack.py", line 21, in call
raise e
File "C:\Users\ajith\AppData\Local\Programs\Python\Python310\lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in call
await self.app(scope, receive, send)
File "C:\Users\ajith\AppData\Local\Programs\Python\Python310\lib\site-packages\starlette\routing.py", line 656, in call
await route.handle(scope, receive, send)
File "C:\Users\ajith\AppData\Local\Programs\Python\Python310\lib\site-packages\starlette\routing.py", line 259, in handle
await self.app(scope, receive, send)
File "C:\Users\ajith\AppData\Local\Programs\Python\Python310\lib\site-packages\starlette\routing.py", line 61, in app
response = await func(request)
File "C:\Users\ajith\AppData\Local\Programs\Python\Python310\lib\site-packages\fastapi\routing.py", line 227, in app
raw_response = await run_endpoint_function(
File "C:\Users\ajith\AppData\Local\Programs\Python\Python310\lib\site-packages\fastapi\routing.py", line 160, in run_endpoint_function
return await dependant.call(**values)
File "C:/Users/ajith/Desktop/Project/api/main.py", line 22, in predict
image = read_file_as_image( file.read())
File "C:/Users/ajith/Desktop/Project/api/main.py", line 16, in read_file_as_image
image = np.array(Image.open(BytesIO(data)))
TypeError: a bytes-like object is required, not 'coroutine'
CODE:
import uvicorn
from fastapi import FastAPI,File,UploadFile
import numpy as np
from io import BytesIO
from PIL import Image
import tensorflow as tf
app = FastAPI()
MODEL = tf.keras.models.load_model("C:/Users/ajith/Desktop/Project/Models/1")
['Healthy', 'Kole Roga']
@app.get("/ping")
async def ping():
return "Hello World:)"
def read_file_as_image(data) -> np.ndarray:
image = np.array(Image.open(BytesIO(data)))
return image
@app.post("/predict")
async def predict( file:UploadFile=File(...) ):
image = read_file_as_image( file.read())
img_batch = np.expand_dims(image, 0)
predictions = MODEL.predict(img_batch)
pass
if name=="main":
uvicorn.run(app, host="localhost", port=8000)
from full-stack-fastapi-postgresql.
Related Issues (20)
- How to start the backend server without using docker?
- FASTAPI
- 🐛 Error in frontend when resetting a password: "The passwords do not match" HOT 1
- Sorry, please ignore.
- backend not working HOT 1
- How do I get this running on local? HOT 3
- Deploying on a machine with nginx HOT 1
- Why React, not Vue?
- Mac M1 Docker error HOT 6
- Bad Gateway returned HOT 5
- [Improvement] Replace Prettier and Eslint with Biome and add pre-commit hooks HOT 1
- Feature Request: Support for GitHub Codespaces Deployment and Development HOT 2
- Login error in Dashboard HOT 5
- Secrets should not be versioned by default HOT 3
- Enable discussion on this repo? HOT 1
- Support the use of dev containers for reproducible dev environment HOT 1
- Embracing Technological Evolution: A Journey Toward Innovation
- Debug Launch Configuration for "Debug Frontend: (...)" does not work on WSL
- Z
- Running task 1 of 1: python .copier/update_dotenv.py /bin/sh: 1: python: not found HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from full-stack-fastapi-postgresql.