Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update on line no. 34 for resizing the input (new image) #10

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async def ping():
return "Hello, I am alive"

def read_file_as_image(data) -> np.ndarray:
image = np.array(Image.open(BytesIO(data)))
image = np.array(Image.open(BytesIO(data)).resize(256, 256))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image = np.array(Image.open(BytesIO(data)).resize((256,256)))

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IDK why but when I tried, resize worked only with double brackets around 256,256

Copy link

@qaixerabbas qaixerabbas Jan 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.resize() accepts a tuple. Therefore we need to provide double brackets. One for function call and one for the tuple.
Example:
imsize = (256,256)
#now call the function with following
im.resize(imsize) # here imsize already has brackets in previous line. So its good to separate the code for better understanding.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, @jainharshit3107 You have to call resize method the image variable in the main.py file in api folder as @JKS46 showed.

return image

@app.post("/predict")
Expand Down