Muthukamalan commited on
Commit
0a04b24
·
verified ·
1 Parent(s): fece07d

Upload folder using huggingface_hub

Browse files
Files changed (5) hide show
  1. .devcontainer/devcontainer.json +17 -0
  2. Dockerfile +20 -13
  3. README.md +7 -1
  4. app.py +11 -14
  5. requirements.txt +33 -33
.devcontainer/devcontainer.json ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ // Add Dev containers configuration files => Add configuration user data folder => From Dockerfile => no checkbox => no checkbox => OKay
3
+
4
+ // For format details, see https://aka.ms/devcontainer.json. For config options, see the
5
+ // README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile
6
+ {
7
+ "name": "dogsbreadcontainer",
8
+ "build": {
9
+ // Sets the run context to one level up instead of the .devcontainer folder.
10
+ "context": "..",
11
+ // Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
12
+ "dockerfile": "../Dockerfile"
13
+ },
14
+ "forwardPorts": [
15
+ 7860
16
+ ]
17
+ }
Dockerfile CHANGED
@@ -1,18 +1,25 @@
1
- FROM public.ecr.aws/docker/library/python:3.11.10-slim
 
 
 
2
 
3
- # Install AWS Lambda Web Adapter
4
- COPY --from=public.ecr.aws/awsguru/aws-lambda-adapter:0.8.4 /lambda-adapter /opt/extensions/lambda-adapter
 
 
5
 
6
- WORKDIR /var/task
7
-
8
- # Copy and install requirements
9
- COPY requirements.txt ./
10
  RUN pip install -r requirements.txt
11
 
12
- # Copy application code and model
13
- COPY app.py ./
14
- COPY best_model.pt ./
15
- COPY examples/ ./examples/
 
 
 
 
 
 
 
16
 
17
- # Set command
18
- CMD ["python3", "app.py"]
 
1
+ FROM python:3.9-slim-buster AS build
2
+
3
+ RUN apt-get update -y && apt install -y --no-install-recommends git build-essential\
4
+ && pip install --no-cache-dir -U pip
5
 
6
+ COPY requirements.txt .
7
+ # Create the virtual environment.
8
+ RUN python3 -m venv /venv
9
+ ENV PATH=/venv/bin:$PATH
10
 
 
 
 
 
11
  RUN pip install -r requirements.txt
12
 
13
+ # Stage 2: Runtime
14
+ FROM python:3.9-slim-buster
15
+ RUN apt-get update -y && apt install -y --no-install-recommends build-essential
16
+ COPY --from=build /venv /venv
17
+ ENV PATH=/venv/bin:$PATH
18
+
19
+ WORKDIR /code
20
+
21
+ COPY . .
22
+
23
+ EXPOSE 7860
24
 
25
+ CMD [ "python","app.py" ]
 
README.md CHANGED
@@ -9,4 +9,10 @@ pinned: true
9
  ---
10
 
11
 
12
- # DogBreedsClassifier
 
 
 
 
 
 
 
9
  ---
10
 
11
 
12
+ # DogBreedsClassifier
13
+
14
+
15
+ ```bash
16
+ docker build -t dogsbreedsgradio:latest .
17
+ docker run --rm -it -p 7860:7860 dogsbreedsgradio:latest
18
+ ```
app.py CHANGED
@@ -1,7 +1,5 @@
1
  import os
2
- from numpy.lib.type_check import imag
3
  import torch
4
- import lightning as pl
5
  import gradio as gr
6
  from PIL import Image
7
  from torchvision import transforms
@@ -15,7 +13,6 @@ device = torch.device("cpu")
15
  torch.set_default_device(device=device)
16
  # torch.autocast(enabled=True, dtype="float16", device_type="cuda")
17
 
18
- pl.seed_everything(123, workers=True)
19
 
20
  TEST_TRANSFORMS = transforms.Compose([
21
  transforms.Resize((224, 224)),
@@ -23,16 +20,16 @@ TEST_TRANSFORMS = transforms.Compose([
23
  transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
24
  ])
25
  class_labels = [
26
- 'Beagle',
27
- 'Boxer',
28
- 'Bulldog',
29
- 'Dachshund',
30
- 'German_Shepherd',
31
- 'Golden_Retriever',
32
- 'Labrador_Retriever',
33
- 'Poodle',
34
- 'Rottweiler',
35
- 'Yorkshire_Terrier',
36
  ]
37
 
38
 
@@ -81,4 +78,4 @@ gr.Interface(
81
  cache_examples=True,
82
  flagging_options=[],
83
  flagging_callback=SimpleCSVLogger()
84
- ).launch(share=False, debug=False) # ,server_name="0.0.0.0",server_port=8080,enable_monitoring=None
 
1
  import os
 
2
  import torch
 
3
  import gradio as gr
4
  from PIL import Image
5
  from torchvision import transforms
 
13
  torch.set_default_device(device=device)
14
  # torch.autocast(enabled=True, dtype="float16", device_type="cuda")
15
 
 
16
 
17
  TEST_TRANSFORMS = transforms.Compose([
18
  transforms.Resize((224, 224)),
 
20
  transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
21
  ])
22
  class_labels = [
23
+ "Beagle",
24
+ "Boxer",
25
+ "Bulldog",
26
+ "Dachshund",
27
+ "German_Shepherd",
28
+ "Golden_Retriever",
29
+ "Labrador_Retriever",
30
+ "Poodle",
31
+ "Rottweiler",
32
+ "Yorkshire_Terrier",
33
  ]
34
 
35
 
 
78
  cache_examples=True,
79
  flagging_options=[],
80
  flagging_callback=SimpleCSVLogger()
81
+ ).launch(share=False, debug=False,server_name="0.0.0.0",server_port=7860,enable_monitoring=None)
requirements.txt CHANGED
@@ -1,15 +1,19 @@
 
1
  # --------- pytorch --------- #
2
- timm==1.0.11
3
- torch==2.5.0
4
- torchvision==0.20.0
5
- lightning==2.4.0
6
- torchmetrics==1.4.1
7
- tensorboard==2.17.1
8
- tensorboardX==2.6.2.2
 
 
 
9
 
10
  # --------- hydra --------- #
11
- hydra-core==1.2.0
12
- hydra-colorlog==1.2.0
13
  # hydra-optuna-sweeper==1.2.0
14
 
15
  # --------- loggers --------- #
@@ -19,34 +23,30 @@ hydra-colorlog==1.2.0
19
  # comet-ml
20
 
21
  # --------- others --------- #
22
- pyrootutils # standardizing the project root setup
23
  # pre-commit # hooks for applying linters on commit
24
- rich # beautiful text formatting in terminal
25
  # pytest # tests
26
  # sh # for running bash commands in some tests (linux/macos only)
27
 
28
- # --------- deployment --------- #
29
- gradio==4.44.1
30
 
31
  # ---------- pytest ------------- #
32
- pytest==8.3.3
33
- pytest-cov==5.0.0
34
 
35
- kaggle
36
- rootutils
37
- loguru
38
- scikit-image==0.22.0
39
- scikit-learn==1.3.1
40
- hydra-optuna-sweeper==1.2.0
41
- optuna==2.10.1
42
- hydra-joblib-launcher==1.2.0
43
- joblib==1.3.2
44
- dvc==3.55.2
45
- dvc-data==3.16.6
46
- dvc-gdrive==3.0.1
47
- dvc-http==2.32.0
48
- dvc-objects==5.1.0
49
- dvc-render==1.0.2
50
- dvc-s3==3.2.0
51
- dvc-studio-client==0.21.0
52
- dvc-task==0.40.1
 
1
+ --extra-index-url https://download.pytorch.org/whl/cpu
2
  # --------- pytorch --------- #
3
+ # timm==1.0.11
4
+ torch==2.4.0
5
+ torchvision==0.19.0
6
+ # lightning==2.4.0
7
+ # torchmetrics==1.4.1
8
+ # tensorboard==2.17.1
9
+ # tensorboardX==2.6.2.2
10
+
11
+ # --------- deployment --------- #
12
+ gradio #==3.45.0
13
 
14
  # --------- hydra --------- #
15
+ # hydra-core==1.2.0
16
+ # hydra-colorlog==1.2.0
17
  # hydra-optuna-sweeper==1.2.0
18
 
19
  # --------- loggers --------- #
 
23
  # comet-ml
24
 
25
  # --------- others --------- #
26
+ # pyrootutils # standardizing the project root setup
27
  # pre-commit # hooks for applying linters on commit
28
+ # rich # beautiful text formatting in terminal
29
  # pytest # tests
30
  # sh # for running bash commands in some tests (linux/macos only)
31
 
 
 
32
 
33
  # ---------- pytest ------------- #
34
+ # pytest==8.3.3
35
+ # pytest-cov==5.0.0
36
 
37
+ # rootutils
38
+ # loguru
39
+ # scikit-image==0.22.0
40
+ # scikit-learn==1.3.1
41
+ # hydra-optuna-sweeper==1.2.0
42
+ # optuna==2.10.1
43
+ # hydra-joblib-launcher==1.2.0
44
+ # joblib==1.3.2
45
+ # dvc==3.55.2
46
+ # dvc-data==3.16.6
47
+ # dvc-http==2.32.0
48
+ # dvc-objects==5.1.0
49
+ # dvc-render==1.0.2
50
+ # dvc-s3==3.2.0
51
+ # dvc-studio-client==0.21.0
52
+ # dvc-task==0.40.1