Skip to content

Commit 826eec2

Browse files
committed
Added: Tensorlfow and PyTorch with separate dockerfiles and builds
1 parent 9768656 commit 826eec2

22 files changed

Lines changed: 603 additions & 154 deletions

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.venv
2+
data

.github/workflows/docker-build-push.yml

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -88,29 +88,3 @@ jobs:
8888
labels: ${{ steps.meta-pytorch.outputs.labels }}
8989
cache-from: type=gha
9090
cache-to: type=gha,mode=max
91-
92-
# Both image
93-
- name: Extract metadata (both)
94-
id: meta-both
95-
uses: docker/metadata-action@v5
96-
with:
97-
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-both
98-
tags: |
99-
type=ref,event=branch
100-
type=ref,event=pr
101-
type=semver,pattern={{version}}
102-
type=semver,pattern={{major}}.{{minor}}
103-
type=semver,pattern={{major}}
104-
type=sha,prefix={{branch}}-
105-
type=raw,value=latest,enable={{is_default_branch}}
106-
107-
- name: Build and push Both image
108-
uses: docker/build-push-action@v5
109-
with:
110-
context: .
111-
file: Dockerfile.both
112-
push: ${{ github.event_name != 'pull_request' }}
113-
tags: ${{ steps.meta-both.outputs.tags }}
114-
labels: ${{ steps.meta-both.outputs.labels }}
115-
cache-from: type=gha
116-
cache-to: type=gha,mode=max

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,7 @@ dmypy.json
143143
model/
144144
logs*
145145
old_data/
146-
test*
146+
test*
147+
148+
149+
data

Dockerfile

Lines changed: 0 additions & 16 deletions
This file was deleted.

Dockerfile.both

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
FROM nvidia/cuda:12.4.0-cudnn-runtime-ubuntu22.04
1+
FROM astral/uv:python3.12-bookworm-slim
22

33
ARG DEBIAN_FRONTEND=noninteractive
44

55
# Install Python and necessary tools
66
RUN apt-get update && apt-get install -y \
7-
python3.10 \
8-
python3-pip \
97
parallel \
108
&& rm -rf /var/lib/apt/lists/*
119

@@ -14,9 +12,10 @@ RUN mkdir /app
1412
WORKDIR /app
1513

1614
# Copy requirements and install dependencies
17-
RUN pip install uv
18-
COPY ./requirements-both.txt /app
19-
RUN uv pip install --no-cache-dir -r requirements-both.txt --system
15+
COPY ./requirements-tensorflow.txt /app
16+
COPY ./requirements-pytorch.txt /app
17+
RUN uv pip install --no-cache-dir -r requirements-tensorflow.txt --system
18+
RUN uv pip install --no-cache-dir -r requirements-pytorch.txt --system
2019

2120
# Copy application files
2221
COPY . /app

Dockerfile.pytorch

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM pytorch/pytorch:2.5.1-cuda12.4-cudnn9-runtime
1+
FROM astral/uv:python3.12-bookworm-slim
22

33
ARG DEBIAN_FRONTEND=noninteractive
44

@@ -9,7 +9,6 @@ RUN mkdir /app
99
WORKDIR /app
1010
COPY ./requirements-pytorch.txt /app
1111

12-
RUN pip install uv
1312
RUN uv pip install -r requirements-pytorch.txt --system
1413
COPY . /app
1514

Dockerfile.tensorflow

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM tensorflow/tensorflow:2.18.0-gpu
1+
FROM astral/uv:python3.12-bookworm-slim
22

33
ARG DEBIAN_FRONTEND=noninteractive
44

@@ -9,7 +9,6 @@ RUN mkdir /app
99
WORKDIR /app
1010
COPY ./requirements-tensorflow.txt /app
1111

12-
RUN pip install uv
1312
RUN uv pip install -r requirements-tensorflow.txt --system
1413
COPY . /app
1514

FRAMEWORK_GUIDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Select from:
8282
### PyTorch
8383
Enable/disable using the checkbox:
8484
- Unchecked: Full Precision (FP32)
85-
- Checked: Automatic Mixed Precision (AMP) using torch.cuda.amp
85+
- Checked: Automatic Mixed Precision (AMP) using torch.amp
8686

8787
## Docker Images
8888

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,46 @@ The above is just used for development and by no means is necessary to run this
150150
   └── *.jpg
151151
```
152152

153+
### Using Preset Datasets (quick start)
154+
155+
If you don't have your own dataset ready, the toolkit supports downloading common image classification datasets (CIFAR10, CIFAR100, MNIST, FashionMNIST, STL10) and preparing them in the required folder-per-class layout.
156+
157+
Example (Streamlit UI progress integration):
158+
159+
```python
160+
import streamlit as st
161+
from core.data_loader_pytorch import ImageClassificationDataLoaderPyTorch
162+
from utils.add_ons_pytorch import make_streamlit_progress_callback
163+
164+
st.title('Preset Dataset Download')
165+
cb = make_streamlit_progress_callback(prefix='Downloading dataset')
166+
# This will download CIFAR10 into ./data/CIFAR10 (if not present) and show progress in Streamlit
167+
dl = ImageClassificationDataLoaderPyTorch(
168+
data_dir='./data/CIFAR10',
169+
image_dims=(224,224),
170+
preset_name='CIFAR10',
171+
preset_target_dir='./data/CIFAR10',
172+
progress_callback=cb,
173+
)
174+
175+
st.write('Dataset ready at:', dl.data_dir)
176+
```
177+
178+
Or use from Python (no Streamlit callback):
179+
180+
```python
181+
from core.data_loader_pytorch import ImageClassificationDataLoaderPyTorch
182+
183+
# download into ./data/MNIST and prepare folder layout automatically
184+
dl = ImageClassificationDataLoaderPyTorch(
185+
data_dir='./data/MNIST',
186+
preset_name='MNIST',
187+
preset_target_dir='./data/MNIST',
188+
)
189+
190+
dataloader, dataset = dl.create_dataloader(batch_size=32, augment=False)
191+
```
192+
153193
4. **Choose your Docker image** based on your needs:
154194

155195
**Option A: Pull from Docker Hub (when available)**

build-all.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,4 @@ echo "All images built successfully!"
2424
echo ""
2525
echo "Available images:"
2626
echo " - ghcr.io/animikhaich/zero-code-classifier:tensorflow (TensorFlow only)"
27-
echo " - ghcr.io/animikhaich/zero-code-classifier:pytorch (PyTorch only)"
28-
echo " - ghcr.io/animikhaich/zero-code-classifier:both (TensorFlow + PyTorch)"
29-
echo " - ghcr.io/animikhaich/zero-code-classifier:latest (same as tensorflow)"
27+
echo " - ghcr.io/animikhaich/zero-code-classifier:pytorch (PyTorch only)"

0 commit comments

Comments
 (0)