Skip to content

Commit

Permalink
Renaming im2mml to img2mml (#87)
Browse files Browse the repository at this point in the history
Co-authored-by: Adarsh Pyarelal <adarsh@arizona.edu>
  • Loading branch information
Adarsh Pyarelal and adarshp authored Jan 20, 2023
1 parent f7b1520 commit 4d7a1b9
Showing 16 changed files with 46 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .drone.yml
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ steps:
- apt-get -y install build-essential graphviz libgraphviz-dev
- pip install -e .[dev]
- pip install pytest-cov pytest-xdist
- pytest --cov=skema --ignore=skema/im2mml skema/program_analysis/tests
- pytest --cov=skema --ignore=skema/img2mml skema/program_analysis/tests
when:
paths:
- pyproject.toml
File renamed without changes.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -15,12 +15,12 @@ coexist peacefully.
At the top level, we have the following files and directories:

- `Dockerfile.code2fn`: Dockerfile for the Code2FN service.
- `Dockerfile.im2mml`: Dockerfile for the Im2MML service.
- `Dockerfile.img2mml`: Dockerfile for the Im2MML service.
- `LICENSE.txt`: License for the software components in this repository.
- `README.md`: This README file.
- `data`: Data for testing.
- `docker-compose.code2fn.yml`: Docker Compose file for the Code2FN service.
- `docker-compose.im2mml.yml`: Docker Compose file for the Im2MML service.
- `docker-compose.img2mml.yml`: Docker Compose file for the Im2MML service.
- `docs`: Source code for the project website.
- `notebooks`: Jupyter notebooks for demoing SKEMA functionality.
- `scripts`: Miscellaneous scripts
@@ -35,10 +35,10 @@ The `skema` directory contains two different types of directories:
- `model_assembly`
- `text_reading`
- `code2fn`: Web service for converting code to GroMEt function networks.
- `im2mml`: Web service for extracting equations from images.
- `img2mml`: Web service for extracting equations from images.
- `moviz`: Visualization interface for GroMEt function networks.

Of the Python subpackages, the last three (`code2fn`, `im2mml`, `moviz`) are
Of the Python subpackages, the last three (`code2fn`, `img2mml`, `moviz`) are
currently the most 'outward/user-facing' components. The `program_analysis`,
`gromet`, and `model_assembly` directories are comprised primarily of library
code that is used by the `code2fn` service.
@@ -83,9 +83,9 @@ docker-compose -f docker-compose.code2fn.yml up --build
To run the Im2MML Dockerized service, run

```
docker-compose -f docker-compose.im2mml.yml up --build
docker-compose -f docker-compose.img2mml.yml up --build
```

(make sure the appropriate im2mml model is in the
`skema/im2mml/trained_models` directory - see the `README.md` file in
`skema/im2mml` for details)
(make sure the appropriate img2mml model is in the
`skema/img2mml/trained_models` directory - see the `README.md` file in
`skema/img2mml` for details)
11 changes: 0 additions & 11 deletions docker-compose.im2mml.yml

This file was deleted.

11 changes: 11 additions & 0 deletions docker-compose.img2mml.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Docker Compose file for the img2mml service
version: "3"
services:
img2mml:
image: img2mml:latest
build:
context: .
dockerfile: Dockerfile.img2mml
entrypoint: uvicorn img2mml:app --host=0.0.0.0 --reload
ports:
- "8000:8000"
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -34,9 +34,9 @@ dev = ["fastapi", "requests", "uvicorn", "pytest", "black", "pygraphviz"]
# the skema/moviz directory).
moviz = ["flask", "graphviz"]

# Im2MML dependencies. The im2mml service converts equation images to MathML.
# See the skema/im2mml directory.
im2mml = ["fastapi", "requests", "uvicorn", "torch", "torchvision", "python-multipart"]
# Im2MML dependencies. The img2mml service converts equation images to MathML.
# See the skema/img2mml directory.
img2mml = ["fastapi", "requests", "uvicorn", "torch", "torchvision", "python-multipart"]

[tool.setuptools.packages]
find = {} # Scan the project directory with the default parameters
16 changes: 8 additions & 8 deletions skema/im2mml/README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# im2mml
# img2mml

This directory contains the code for the im2mml service, which processes images
This directory contains the code for the img2mml service, which processes images
of equations and returns presentation MathML corresponding to those equations.

The model was developed by Gaurav Sharma and Clay Morrison, and this wrapper
service was developed by Deepsana Shahi and Adarsh Pyarelal.

The model itself is not checked into the repository, but you can get it from
here:
https://kraken.sista.arizona.edu/skema/im2mml/models/cnn_xfmer_OMML-90K_best_model_RPimage.pt.
https://kraken.sista.arizona.edu/skema/img2mml/models/cnn_xfmer_OMML-90K_best_model_RPimage.pt.

Place the model file in the `trained_models` directory.

The curl command below should do the trick.

```
curl -L https://kraken.sista.arizona.edu/skema/im2mml/models/cnn_xfmer_OMML-90K_best_model_RPimage.pt > trained_models/cnn_xfmer_OMML-90K_best_model_RPimage.pt
curl -L https://kraken.sista.arizona.edu/skema/img2mml/models/cnn_xfmer_OMML-90K_best_model_RPimage.pt > trained_models/cnn_xfmer_OMML-90K_best_model_RPimage.pt
```

Then, run the invocation below to launch the Dockerized service:
@@ -25,18 +25,18 @@ docker-compose up --build
```

To test the service without Docker (e.g., for development purposes), ensure
that you have installed the required packages (run `pip install -e .[im2mml]`
that you have installed the required packages (run `pip install -e .[img2mml]`
in the root of the repository).

Then, run the following command to launch the im2mml server program:
Then, run the following command to launch the img2mml server program:

```
uvicorn im2mml:app --reload
uvicorn img2mml:app --reload
```

An example test program is provided as well, which you can invoke with:
Make sure that you are in generate_mathml folder.

```
python im2mml_demo.py
python img2mml_demo.py
```
2 changes: 1 addition & 1 deletion skema/im2mml/api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
from pathlib import Path
from skema.im2mml.translate import Image2Tensor, render_mml
from skema.img2mml.translate import Image2Tensor, render_mml


def get_mathml_from_bytes(data: bytes):
2 changes: 1 addition & 1 deletion skema/im2mml/im2mml.py
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

from typing import List
from fastapi import FastAPI, File
from skema.im2mml.api import get_mathml_from_bytes
from skema.img2mml.api import get_mathml_from_bytes


# Create a web app using FastAPI
2 changes: 1 addition & 1 deletion skema/im2mml/im2mml_demo.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python

"""Example Python client program to work with the im2mml web service."""
"""Example Python client program to work with the img2mml web service."""

import argparse
import requests
4 changes: 2 additions & 2 deletions skema/im2mml/models/decoders/xfmer_decoder.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import torch, math
import torch.nn as nn
from skema.im2mml.utils import generate_square_subsequent_mask
from skema.im2mml.models.encoding.positional_encoding_for_xfmer import (
from skema.img2mml.utils import generate_square_subsequent_mask
from skema.img2mml.models.encoding.positional_encoding_for_xfmer import (
PositionalEncoding,
)

4 changes: 2 additions & 2 deletions skema/im2mml/models/encoders/cnn_encoder.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import torch
import torch.nn as nn
from skema.im2mml.models.encoding.positional_features_for_cnn_encoder import (
from skema.img2mml.models.encoding.positional_features_for_cnn_encoder import (
add_positional_features,
)
from skema.im2mml.models.encoding.row_encoding import RowEncoding
from skema.img2mml.models.encoding.row_encoding import RowEncoding


class CNN_Encoder(nn.Module):
4 changes: 2 additions & 2 deletions skema/im2mml/models/encoders/xfmer_encoder.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import torch, math
import torch.nn as nn
from skema.im2mml.utils import generate_square_subsequent_mask
from skema.im2mml.models.encoding.positional_encoding_for_xfmer import (
from skema.img2mml.utils import generate_square_subsequent_mask
from skema.img2mml.models.encoding.positional_encoding_for_xfmer import (
PositionalEncoding,
)

2 changes: 1 addition & 1 deletion skema/im2mml/tests/test_im2mml.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pathlib import Path
from skema.im2mml.api import get_mathml_from_file
from skema.img2mml.api import get_mathml_from_file

def test_get_mathml():
cwd = Path(__file__).parents[0]
2 changes: 1 addition & 1 deletion skema/im2mml/trained_models/README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
This directory contains trained models for the im2mml pipeline.
This directory contains trained models for the img2mml pipeline.
8 changes: 4 additions & 4 deletions skema/im2mml/translate.py
Original file line number Diff line number Diff line change
@@ -14,12 +14,12 @@
import torch.multiprocessing as mp
from torchvision import transforms
from PIL import Image
from skema.im2mml.models.encoders.cnn_encoder import CNN_Encoder
from skema.im2mml.models.image2mml_xfmer_for_inference import (
from skema.img2mml.models.encoders.cnn_encoder import CNN_Encoder
from skema.img2mml.models.image2mml_xfmer_for_inference import (
Image2MathML_Xfmer,
)
from skema.im2mml.models.encoders.xfmer_encoder import Transformer_Encoder
from skema.im2mml.models.decoders.xfmer_decoder import Transformer_Decoder
from skema.img2mml.models.encoders.xfmer_encoder import Transformer_Encoder
from skema.img2mml.models.decoders.xfmer_decoder import Transformer_Decoder
import io
from typing import List

0 comments on commit 4d7a1b9

Please sign in to comment.