Skip to content

Commit

Permalink
docs: Specified that the API template only supports images for now (#609
Browse files Browse the repository at this point in the history
)

* ci: Change the CI check for API

* docs: Specified that API template only supports images
  • Loading branch information
fg-mindee authored Nov 12, 2021
1 parent eb5db48 commit a792a82
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ jobs:
streamlit --version
screen -dm streamlit run demo/app.py
sleep 10
curl http://localhost:8501
curl http://localhost:8501/docs
6 changes: 3 additions & 3 deletions api/app/routes/detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@

from app.schemas import DetectionOut
from app.vision import det_predictor
from fastapi import APIRouter, File, UploadFile
from fastapi import APIRouter, File, UploadFile, status

from doctr.io import decode_img_as_tensor

router = APIRouter()


@router.post("/", response_model=List[DetectionOut], status_code=200, summary="Perform text detection")
@router.post("/", response_model=List[DetectionOut], status_code=status.HTTP_200_OK, summary="Perform text detection")
async def text_detection(file: UploadFile = File(...)):
"""Runs docTR text detection model to analyze the input"""
"""Runs docTR text detection model to analyze the input image"""
img = decode_img_as_tensor(file.file.read())
boxes, _ = det_predictor([img])[0]
return [DetectionOut(box=box.tolist()) for box in boxes[:, :-1]]
6 changes: 3 additions & 3 deletions api/app/routes/ocr.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@

from app.schemas import OCROut
from app.vision import predictor
from fastapi import APIRouter, File, UploadFile
from fastapi import APIRouter, File, UploadFile, status

from doctr.io import decode_img_as_tensor

router = APIRouter()


@router.post("/", response_model=List[OCROut], status_code=200, summary="Perform OCR")
@router.post("/", response_model=List[OCROut], status_code=status.HTTP_200_OK, summary="Perform OCR")
async def perform_ocr(file: UploadFile = File(...)):
"""Runs docTR OCR model to analyze the input"""
"""Runs docTR OCR model to analyze the input image"""
img = decode_img_as_tensor(file.file.read())
out = predictor([img])

Expand Down
6 changes: 3 additions & 3 deletions api/app/routes/recognition.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@

from app.schemas import RecognitionOut
from app.vision import reco_predictor
from fastapi import APIRouter, File, UploadFile
from fastapi import APIRouter, File, UploadFile, status

from doctr.io import decode_img_as_tensor

router = APIRouter()


@router.post("/", response_model=RecognitionOut, status_code=200, summary="Perform text recognition")
@router.post("/", response_model=RecognitionOut, status_code=status.HTTP_200_OK, summary="Perform text recognition")
async def text_recognition(file: UploadFile = File(...)):
"""Runs docTR text recognition model to analyze the input"""
"""Runs docTR text recognition model to analyze the input image"""
img = decode_img_as_tensor(file.file.read())
out = reco_predictor([img])
return RecognitionOut(value=out[0][0])

0 comments on commit a792a82

Please sign in to comment.