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

chore(example): convert image mode to RGB for sam generator #52

Merged
merged 1 commit into from
Nov 8, 2023
Merged
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
4 changes: 2 additions & 2 deletions advanced/segment-anything/sam.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def predict_url(self, url: str) -> LeptonPickled:
# urllib to do this. Note that this is just an example - you can use any method
# to download the image.
try:
raw_img = np.asarray(Image.open(io.BytesIO(urlopen(url).read())))
raw_img = np.asarray(Image.open(io.BytesIO(urlopen(url).read())).convert("RGB"))
except Exception as e:
# HTTPException is a special exception that will be translated to a proper
# http error by fastAPI and return to the user side. In this case, we will
Expand Down Expand Up @@ -203,7 +203,7 @@ def generate_mask(self, url: str) -> PNGResponse:
masks.
"""
try:
raw_img = np.asarray(Image.open(io.BytesIO(urlopen(url).read())))
raw_img = np.asarray(Image.open(io.BytesIO(urlopen(url).read())).convert("RGB"))
except Exception as e:
raise HTTPException(
status_code=400,
Expand Down
Loading