VikramSingh178 commited on
Commit
d030f4c
β€’
1 Parent(s): f9ed461

chore: Update Dockerfile and requirements.txt, and install additional Python packages

Browse files

Former-commit-id: 3550d7eab461bf64ef3c3c6f764858bee6e7e571
Former-commit-id: ab7f1f05303afa418835763ceae3d49d013d9804

Dockerfile CHANGED
@@ -1,33 +1,45 @@
1
- # Use the official Python base image
2
- FROM python:3.10-slim
3
 
4
- # Set the initial working directory
 
 
 
5
  WORKDIR /app
6
 
7
- # Copy the requirements.txt file from the api directory
8
- COPY ../api/requirements.txt ./
 
 
 
 
 
 
9
 
10
- # Install dependencies specified in requirements.txt
11
- RUN pip install --no-cache-dir -r requirements.txt
12
 
13
- # Create a non-root user and set up the environment
14
- RUN useradd -m -u 1000 user
15
 
16
- USER user
 
17
 
 
18
  ENV HOME=/home/user \
19
- PATH=/home/user/.local/bin:$PATH
20
-
21
- # Set the final working directory
22
- WORKDIR $HOME/app
23
 
 
 
24
 
 
 
25
 
26
- # Copy the entire project into the container, setting the appropriate ownership
27
- COPY --chown=user . $HOME/app
28
 
29
- # Set the working directory to /home/user/app/api
30
- WORKDIR $HOME/app/api
31
 
32
- # Command to run the API
33
- CMD ["python", "endpoints.py"]
 
1
+ # Dockerfile for Python application with dependencies and runtime optimizations
 
2
 
3
+ # Use Python 3.10 slim-buster as base image
4
+ FROM python:3.10-slim-buster
5
+
6
+ # Set working directory in the container
7
  WORKDIR /app
8
 
9
+ # Install system dependencies
10
+ RUN apt-get update \
11
+ && apt-get install -y --no-install-recommends \
12
+ ffmpeg \
13
+ libsm6 \
14
+ libxext6 \
15
+ libgl1-mesa-glx \
16
+ && rm -rf /var/lib/apt/lists/*
17
 
18
+ # Copy everything from the current directory to /app in the container
19
+ COPY . .
20
 
21
+ # Install Python dependencies
22
+ RUN pip install --no-cache-dir -r api/requirements.txt
23
 
24
+ # Create a non-root user to run the application
25
+ RUN useradd -m -u 1000 user
26
 
27
+ # Set environment variables
28
  ENV HOME=/home/user \
29
+ PATH=/home/user/.local/bin:$PATH \
30
+ PYTHONPATH=$HOME/app/scripts
 
 
31
 
32
+ # Set ownership to non-root user
33
+ RUN chown -R user:user /app
34
 
35
+ # Switch to the non-root user
36
+ USER user
37
 
38
+ # Install the application in editable mode
39
+ RUN pip install --no-cache-dir -e /app
40
 
41
+ # Set working directory for the application
42
+ WORKDIR /app/api
43
 
44
+ # Command to run the application
45
+ CMD ["python", "endpoints.py"]
api/requirements.txt CHANGED
@@ -11,3 +11,7 @@ torch
11
  utils==1.0.2
12
  uvicorn==0.30.1
13
  boto3
 
 
 
 
 
11
  utils==1.0.2
12
  uvicorn==0.30.1
13
  boto3
14
+ ultralytics
15
+ transformers
16
+
17
+
api/routers/painting.py CHANGED
@@ -1,5 +1,4 @@
1
- import sys
2
- sys.path.append('../scripts')
3
  import os
4
  import uuid
5
  from typing import List, Tuple, Any, Dict
@@ -7,7 +6,7 @@ from fastapi import APIRouter, File, UploadFile, HTTPException, Form, Depends, B
7
  from pydantic import BaseModel, Field
8
  from PIL import Image
9
  import lightning.pytorch as pl
10
- from utils import pil_to_s3_json, pil_to_b64_json, ImageAugmentation, accelerator
11
  from inpainting_pipeline import AutoPaintingPipeline, load_pipeline
12
  from hydra import compose, initialize
13
  from async_batcher.batcher import AsyncBatcher
@@ -18,7 +17,7 @@ pl.seed_everything(42)
18
  router = APIRouter()
19
 
20
  # Initialize Hydra configuration
21
- with initialize(version_base=None, config_path="../../configs"):
22
  cfg = compose(config_name="inpainting")
23
 
24
  # Load the inpainting pipeline
 
1
+ from pathlib import Path
 
2
  import os
3
  import uuid
4
  from typing import List, Tuple, Any, Dict
 
6
  from pydantic import BaseModel, Field
7
  from PIL import Image
8
  import lightning.pytorch as pl
9
+ from scripts.api_utils import pil_to_s3_json, pil_to_b64_json, ImageAugmentation, accelerator
10
  from inpainting_pipeline import AutoPaintingPipeline, load_pipeline
11
  from hydra import compose, initialize
12
  from async_batcher.batcher import AsyncBatcher
 
17
  router = APIRouter()
18
 
19
  # Initialize Hydra configuration
20
+ with initialize(version_base=None, config_path=Path(__file__).resolve().parent.parent / "configs"):
21
  cfg = compose(config_name="inpainting")
22
 
23
  # Load the inpainting pipeline
api/routers/sdxl_text_to_image.py CHANGED
@@ -1,21 +1,13 @@
1
- import sys
2
- sys.path.append("../scripts") # Path of the scripts directory
3
  import config
4
  from fastapi import APIRouter, HTTPException
5
- from pydantic import BaseModel
6
- import base64
7
- from io import BytesIO
8
  from typing import List
9
- import uuid
10
  from diffusers import DiffusionPipeline
11
  import torch
12
  from functools import lru_cache
13
- from PIL import Image
14
- import io
15
- from scripts.utils import accelerator
16
  from models.sdxl_input import InputFormat
17
  from async_batcher.batcher import AsyncBatcher
18
- from utils import pil_to_b64_json, pil_to_s3_json
19
  torch._inductor.config.conv_1x1_as_mm = True
20
  torch._inductor.config.coordinate_descent_tuning = True
21
  torch._inductor.config.epilogue_fusion = False
 
 
 
1
  import config
2
  from fastapi import APIRouter, HTTPException
 
 
 
3
  from typing import List
 
4
  from diffusers import DiffusionPipeline
5
  import torch
6
  from functools import lru_cache
7
+ from scripts.api_utils import accelerator
 
 
8
  from models.sdxl_input import InputFormat
9
  from async_batcher.batcher import AsyncBatcher
10
+ from scripts.api_utils import pil_to_b64_json, pil_to_s3_json
11
  torch._inductor.config.conv_1x1_as_mm = True
12
  torch._inductor.config.coordinate_descent_tuning = True
13
  torch._inductor.config.epilogue_fusion = False
picpilot.egg-info/PKG-INFO ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ Metadata-Version: 2.1
2
+ Name: picpilot
3
+ Version: 0.1
4
+ License-File: LICENSE
picpilot.egg-info/SOURCES.txt ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ LICENSE
2
+ README.md
3
+ setup.py
4
+ api/__init__.py
5
+ api/endpoints.py
6
+ api/models/__init__.py
7
+ api/models/painting.py
8
+ api/models/sdxl_input.py
9
+ picpilot.egg-info/PKG-INFO
10
+ picpilot.egg-info/SOURCES.txt
11
+ picpilot.egg-info/dependency_links.txt
12
+ picpilot.egg-info/top_level.txt
13
+ scripts/__init__.py
14
+ scripts/api_utils.py
15
+ scripts/config.py
16
+ scripts/inpainting_pipeline.py
17
+ scripts/kandinsky3_inpainting.py
18
+ scripts/load_pipeline.py
19
+ scripts/logger.py
20
+ scripts/products10k_captions.py
21
+ scripts/s3_manager.py
22
+ scripts/sdxl_lora_inference.py
23
+ scripts/sdxl_lora_tuner.py
picpilot.egg-info/dependency_links.txt ADDED
@@ -0,0 +1 @@
 
 
1
+
picpilot.egg-info/top_level.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ api
2
+ scripts
requirements.txt DELETED
File without changes
run.sh CHANGED
@@ -1,3 +1,2 @@
1
- apt-get update && apt-get install python3-dev
2
- uv pip install -r requirements.txt
3
  apt install libgl1-mesa-glx -y
 
1
+ apt-get update && apt-get install python3-dev -y
 
2
  apt install libgl1-mesa-glx -y
scripts/{utils.py β†’ api_utils.py} RENAMED
File without changes
scripts/inpainting_pipeline.py CHANGED
@@ -1,7 +1,7 @@
1
  import torch
2
  from diffusers import AutoPipelineForInpainting
3
  from diffusers.utils import load_image
4
- from utils import accelerator, ImageAugmentation
5
  import hydra
6
  from omegaconf import DictConfig
7
  from PIL import Image
 
1
  import torch
2
  from diffusers import AutoPipelineForInpainting
3
  from diffusers.utils import load_image
4
+ from api_utils import accelerator, ImageAugmentation
5
  import hydra
6
  from omegaconf import DictConfig
7
  from PIL import Image
scripts/kandinsky3_inpainting.py CHANGED
@@ -2,7 +2,7 @@ import sys
2
  import torch
3
  sys.path.append('../')
4
  from Kandinsky.kandinsky3 import get_inpainting_pipeline
5
- from utils import ImageAugmentation
6
  from diffusers.utils import load_image
7
  from PIL import Image
8
 
 
2
  import torch
3
  sys.path.append('../')
4
  from Kandinsky.kandinsky3 import get_inpainting_pipeline
5
+ from api_utils import ImageAugmentation
6
  from diffusers.utils import load_image
7
  from PIL import Image
8
 
setup.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(name='picpilot',
4
+ version='0.1',
5
+ packages=find_packages(),
6
+ )
ui/ui.py CHANGED
@@ -6,9 +6,9 @@ from io import BytesIO
6
 
7
 
8
 
9
- sdxl_inference_endpoint = 'http://127.0.0.1:8000/api/v1/product-diffusion/sdxl_v0_lora_inference'
10
- sdxl_batch_inference_endpoint = 'http://127.0.0.1:8000/api/v1/product-diffusion/sdxl_v0_lora_inference/batch'
11
- kandinsky_inpainting_inference = 'http://127.0.0.1:8000/api/v1/product-diffusion/kandinskyv2.2_inpainting'
12
 
13
  # Define the InpaintingRequest model
14
  class InputRequest(BaseModel):
 
6
 
7
 
8
 
9
+ sdxl_inference_endpoint = 'http://127.0.0.1:7860/api/v1/product-diffusion/sdxl_v0_lora_inference'
10
+ sdxl_batch_inference_endpoint = 'http://127.0.0.1:7860/api/v1/product-diffusion/sdxl_v0_lora_inference/batch'
11
+ kandinsky_inpainting_inference = 'http://127.0.0.1:7860/api/v1/product-diffusion/kandinskyv2.2_inpainting'
12
 
13
  # Define the InpaintingRequest model
14
  class InputRequest(BaseModel):