Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
Relax serve requirements (#1187)
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanwharris committed Feb 23, 2022
1 parent de4e856 commit 3c06c3f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
3 changes: 3 additions & 0 deletions flash/core/serve/flash_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import Any, Callable, Mapping

import torch
from torch import Tensor

from flash.core.data.batch import _ServeInputProcessor
from flash.core.data.data_module import DataModule
Expand Down Expand Up @@ -41,6 +42,8 @@ def serialize(self, outputs) -> Any: # pragma: no cover
result = self._output(output)
if isinstance(result, Mapping):
result = result[DataKeys.PREDS]
if isinstance(result, Tensor):
result = result.tolist()
results.append(result)
if len(results) == 1:
return results[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
model = ImageClassifier.load_from_checkpoint(
"https://flash-weights.s3.amazonaws.com/0.7.0/image_classification_model.pt"
)
model.serve()
model.serve(output="labels")
12 changes: 3 additions & 9 deletions requirements/serve.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,10 @@ pyyaml
cytoolz
graphviz
tqdm
# until 1.0 release fastapi docs recommend pinning to MINOR releases.
# https://fastapi.tiangolo.com/deployment/#fastapi-versions
fastapi>=0.65.2,<0.66.0
# to have full feature control of fastapi, manually install optional
# dependencies rather than installing fastapi[all]
# https://fastapi.tiangolo.com/#optional-dependencies
pydantic>1.8.1,<2.0.0
fastapi>=0.65.2
pydantic>1.8.1
starlette==0.14.2
uvicorn[standard]>=0.12.0,<0.14.0
uvicorn[standard]>=0.12.0
aiofiles
jinja2
importlib-metadata>=0.12,<3;python_version<"3.8"
torchvision

0 comments on commit 3c06c3f

Please sign in to comment.