Skip to content

Commit 9cb253b

Browse files
committed
docker
1 parent 907e22d commit 9cb253b

File tree

5 files changed

+90
-8
lines changed

5 files changed

+90
-8
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*

.github/workflows/python-publish.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,33 @@ jobs:
2929
with:
3030
user: __token__
3131
password: ${{ secrets.PYPI_API_TOKEN }}
32+
33+
docker-deploy:
34+
runs-on: ubuntu-latest
35+
needs: pypi-deploy
36+
permissions:
37+
contents: read
38+
packages: write
39+
steps:
40+
- name: Git checkout
41+
uses: actions/checkout@v3
42+
- name: Enable buildx
43+
uses: docker/setup-buildx-action@v2
44+
- name: Log in to the Container registry
45+
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
46+
with:
47+
registry: ${{ env.REGISTRY }}
48+
username: ${{ github.actor }}
49+
password: ${{ secrets.GITHUB_TOKEN }}
50+
- name: Extract metadata (tags, labels) for Docker
51+
id: meta
52+
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
53+
with:
54+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
55+
- name: Build and push Docker image
56+
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
57+
with:
58+
context: .
59+
push: true
60+
tags: ${{ steps.meta.outputs.tags }}
61+
labels: ${{ steps.meta.outputs.labels }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ __pycache__/
55
*.tflite
66
*.json
77
_version.py
8+
.bash_history
89
schema.fbs

Dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
FROM ubuntu:22.04
2+
3+
ENV DEBIAN_FRONTEND=noninteractive
4+
5+
SHELL ["/bin/bash", "-c"]
6+
7+
RUN apt-get update \
8+
&& apt-get install -y \
9+
python3-pip \
10+
python-is-python3 \
11+
flatbuffers-compiler \
12+
sudo \
13+
&& pip install -U pip \
14+
&& pip install -U tfliteiorewriter \
15+
&& pip install -U tfliteiorewriter \
16+
&& apt clean \
17+
&& rm -rf /var/lib/apt/lists/*
18+
19+
ENV USERNAME=user
20+
RUN echo "root:root" | chpasswd \
21+
&& useradd \
22+
--create-home \
23+
--home-dir /home/${USERNAME} \
24+
--shell /bin/bash \
25+
--user-group \
26+
--groups adm,sudo \
27+
${USERNAME} \
28+
&& echo "${USERNAME}:${USERNAME}" | chpasswd \
29+
&& cat /dev/null > /etc/sudoers.d/${USERNAME} \
30+
&& echo "%${USERNAME} ALL=(ALL) NOPASSWD: ALL" >> \
31+
/etc/sudoers.d/${USERNAME}
32+
USER ${USERNAME}
33+
WORKDIR /home/${USERNAME}

README.md

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,30 @@ The purpose is to solve the following problems by forcibly rewriting tflite's in
2020
![02](https://github.com/PINTO0309/tflite-input-output-rewriter/assets/33194443/5d73d9e1-cae3-498f-8de6-371a8ddb9ce6)
2121

2222
## Execution
23-
```bash
24-
sudo apt-get update && sudo apt-get install -y flatbuffers-compiler
25-
26-
python tfliteiorewriter/main.py -i xxxx.tflite
27-
```
23+
1. Docker
24+
```
25+
$ docker login ghcr.io
26+
27+
Username (xxxx): {Enter}
28+
Password: {Personal Access Token}
29+
Login Succeeded
30+
31+
$ docker run --rm -it \
32+
-v `pwd`:/home/user \
33+
ghcr.io/pinto0309/tfliteiorewriter:latest
34+
35+
tfliteiorewriter -i xxxx.tflite
36+
```
37+
2. Local
38+
```bash
39+
sudo apt-get update && sudo apt-get install -y flatbuffers-compiler
40+
# Other than debian/ubuntu: https://github.com/google/flatbuffers/releases
41+
pip install -U tfliteiorewriter
42+
43+
tfliteiorewriter -i xxxx.tflite
44+
```
2845
```
29-
usage: main.py [-h] -i INPUT_TFLITE_FILE_PATH [-v] [-o OUTPUT_FOLDER_PATH] [-r RENAME RENAME]
46+
usage: tfliteiorewriter [-h] -i INPUT_TFLITE_FILE_PATH [-v] [-o OUTPUT_FOLDER_PATH] [-r RENAME RENAME]
3047

3148
optional arguments:
3249
-h, --help
@@ -66,7 +83,7 @@ If this tool is run without additional options, it will overwrite the input/outp
6683
6784
## View Mode Result
6885
```bash
69-
python tfliteiorewriter/main.py -i xxxx.tflite -v
86+
tfliteiorewriter -i xxxx.tflite -v
7087
```
7188
![image](https://github.com/PINTO0309/tflite-input-output-rewriter/assets/33194443/0d43d93d-647d-40f1-b464-662e39dcf228)
7289

@@ -78,7 +95,7 @@ Replace with any name by specifying `{From}` and `{To}` in the `--renmae (-r)` o
7895
![image](https://github.com/PINTO0309/tflite-input-output-rewriter/assets/33194443/61195485-a756-4449-8bf2-4d9e83f06feb)
7996

8097
```bash
81-
python tfliteiorewriter/main.py \
98+
tfliteiorewriter \
8299
-i xxxx.tflite \
83100
-r serving_default_input_1:0 aaa \
84101
-r StatefulPartitionedCall:0 bbb

0 commit comments

Comments
 (0)