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

Don't install torch by default #472

Merged
merged 3 commits into from
Dec 10, 2024
Merged
Changes from 1 commit
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
Next Next commit
Don't use torch by default
  • Loading branch information
jonchang committed Dec 9, 2024
commit b506593a82f79f18c6f7171e3ba897f34bb23f20
2 changes: 1 addition & 1 deletion OCR/dev-dockerfile
Original file line number Diff line number Diff line change
@@ -12,4 +12,4 @@ COPY ./pyproject.toml /ocr/pyproject.toml
COPY ./poetry.lock /ocr/poetry.lock

WORKDIR /ocr
RUN poetry install && poetry cache list | xargs -n1 poetry cache clear --all
RUN poetry install --without=torch && poetry cache list | xargs -n1 poetry cache clear --all
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@

from pathlib import Path

import torch
import numpy as np
import cv2 as cv
from PIL import Image
@@ -20,6 +19,8 @@ def make_transform(self, distortion_scale: float) -> object:
"""
Create a transformation matrix for a random perspective transform.
"""
import torch

# From torchvision. BSD 3-clause
height = self.image.height
width = self.image.width
2 changes: 1 addition & 1 deletion OCR/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion OCR/pyproject.toml
Original file line number Diff line number Diff line change
@@ -11,11 +11,13 @@ numpy = "^1.26.4"
opencv-python = "^4.9.0.80"
levenshtein = "^0.25.1"
fastapi = {extras = ["standard"], version = "^0.112.1"}
transformers = {extras = ["torch"], version = "^4.45.1"}
pillow = "^10.3.0"
datasets = "^3.0.1"
tesserocr = "^2.7.1"

[tool.poetry.group.torch.dependencies]
transformers = {extras = ["torch"], version = "^4.45.1"}

[tool.poetry.group.dev.dependencies]
lxml = "^5.3.0"
docopt = "^0.6.2"
2 changes: 1 addition & 1 deletion dev-env.yaml
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ services:
volumes:
- ./OCR:/ocr
restart: "no"
command: "/bin/sh -c 'poetry install && poetry run fastapi dev ocr/api.py --host 0.0.0.0 --port 8000'"
command: "/bin/sh -c 'poetry install --without=torch --sync && poetry run fastapi dev ocr/api.py --host 0.0.0.0 --port 8000'"
frontend:
build:
context: ./frontend