generated from swiss-ai-center/create-a-new-service-generic-template
-
Notifications
You must be signed in to change notification settings - Fork 0
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
first implementation of the microservice. #1
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,20 @@ | ||
# Create a new service (generic) template | ||
|
||
This repository contains the Python + FastAPI template to create a service | ||
without a model or from an existing model compatible with the Core engine. | ||
|
||
Please read the documentation at | ||
<https://docs.swiss-ai-center.ch/how-to-guides/how-to-create-a-new-service> to | ||
understand how to use this template. | ||
|
||
## Guidelines | ||
|
||
TODO: Add instructions on how to edit this template. | ||
|
||
### Publishing and deploying using a CI/CD pipeline | ||
|
||
This is the recommended way to publish and deploy your service if you have | ||
access to GitHub Actions or GitLab CI. | ||
|
||
TODO | ||
|
||
### Publishing and deploying manually | ||
|
||
This is the recommended way to publish and deploy your service if you do not | ||
have access to GitHub Actions or GitLab CI or do not want to use these services. | ||
|
||
TODO | ||
|
||
## Checklist | ||
|
||
These checklists allow you to ensure everything is set up correctly. | ||
|
||
### Common tasks | ||
|
||
- [ ] Rename the project in the [`pyproject.toml`](./pyproject.toml) file | ||
- [x] Add files that must be ignored to the [`.gitignore`](.gitignore) configuration file | ||
- [ ] TODO | ||
|
||
### Publishing and deploying using a CI/CD pipeline | ||
|
||
> [!NOTE] | ||
> This checklist is specific to the _Publishing and deploying using a CI/CD | ||
> pipeline_ section. | ||
|
||
- [x] Add the environment variables | ||
- [ ] TODO | ||
|
||
### Publishing and deploying manually | ||
|
||
> [!NOTE] | ||
> This checklist is specific to the _Publishing and deploying manually_ section. | ||
|
||
- [x] Edit the [`.env`](.env) configuration file | ||
- [ ] TODO | ||
# Image Draw Bounding Boxes | ||
This microservice draws boxes on an image. It is intended to work with the | ||
text recognition OCR service. The bounding boxes are passed in a JSON file that corresponds to the output of | ||
the text recognition service. Namely, it must have the following structure: | ||
``` | ||
{"boxes":[ | ||
"position":{ | ||
"left": ..., | ||
"top": ..., | ||
"width": ..., | ||
"height": ..., | ||
}, | ||
{"position": ...}, | ||
... | ||
]} | ||
``` | ||
Where the values in "left", "top", "width" and "height" are given in pixels. | ||
The bounding boxes are drawn as red unfilled rectangles at the coordinates specified by the 4 fields above. | ||
|
||
The JSON file may contain additional fields; they will be ignored. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
aiobotocore==2.12.1 | ||
aiofiles==23.2.1 | ||
aiohappyeyeballs==2.4.0 | ||
aiohttp==3.10.5 | ||
aioitertools==0.11.0 | ||
aiosignal==1.3.1 | ||
annotated-types==0.7.0 | ||
anyio==4.4.0 | ||
async-timeout==4.0.3 | ||
attrs==24.2.0 | ||
botocore==1.34.51 | ||
certifi==2024.7.4 | ||
click==8.1.7 | ||
common_code @ git+https://github.com/swiss-ai-center/common-code.git@e8bfec8bc00995aa2a0b022bcac03780d38856af | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be removed |
||
coverage==7.6.1 | ||
dnspython==2.6.1 | ||
email_validator==2.1.1 | ||
exceptiongroup==1.2.2 | ||
fastapi==0.110.0 | ||
flake8==7.0.0 | ||
frozenlist==1.4.1 | ||
h11==0.14.0 | ||
httpcore==1.0.5 | ||
httpx==0.27.0 | ||
idna==3.8 | ||
iniconfig==2.0.0 | ||
jmespath==1.0.1 | ||
MarkupSafe==2.1.5 | ||
mccabe==0.7.0 | ||
multidict==6.0.5 | ||
packaging==24.1 | ||
pillow==10.4.0 | ||
pip==22.0.2 | ||
pluggy==1.5.0 | ||
pycodestyle==2.11.1 | ||
pydantic==2.8.2 | ||
pydantic-settings==2.2.1 | ||
pydantic_core==2.20.1 | ||
pyflakes==3.2.0 | ||
pytest==8.1.1 | ||
pytest-asyncio==0.23.5.post1 | ||
pytest-cov==4.1.0 | ||
pytest_httpserver==1.0.10 | ||
python-dateutil==2.9.0.post0 | ||
python-dotenv==1.0.1 | ||
PyYAML==6.0.1 | ||
setuptools==59.6.0 | ||
six==1.16.0 | ||
sniffio==1.3.1 | ||
starlette==0.36.3 | ||
tomli==2.0.1 | ||
typing_extensions==4.12.2 | ||
urllib3==2.0.7 | ||
uvicorn==0.28.0 | ||
Werkzeug==3.0.4 | ||
wrapt==1.16.0 | ||
yarl==1.9.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
common-code[test] @ git+https://github.com/swiss-ai-center/common-code.git@main | ||
pillow~=10.4.0 | ||
pip~=22.0.2 | ||
setuptools~=59.6.0 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from PIL import Image, ImageDraw | ||
import io | ||
|
||
|
||
def draw_bounding_boxes(image, boxes): | ||
imageStream = io.BytesIO(image) | ||
image = Image.open(imageStream) | ||
image = ImageDraw.Draw(image) | ||
for elt in boxes: | ||
box = elt['position'] | ||
x, y, w, h = box['left'], box['top'], box['width'], box['height'] | ||
shape = [x, y, x + w, y + h] | ||
image.rectangle(shape, fill=None, outline="red") | ||
return image._image |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget to add the
to the README