Spaces:
Running
Running
Commit
•
8cb2d8e
1
Parent(s):
ab072c0
chore: Update inpainting pipeline configuration and parameters
Browse filesFormer-commit-id: 9ccf8e9ea2ff6e8b5d91537a79af334e8ada1c12 [formerly 8312cab660b7e3f1ac5bf3ecf8f3b9aec6883906]
Former-commit-id: 9f6b6308454760669e28550d2edf3e4c42e65ff7
- configs/inpainting.yaml +1 -1
- product_diffusion_api/__pycache__/endpoints.cpython-310.pyc +0 -0
- product_diffusion_api/endpoints.py +3 -2
- product_diffusion_api/routers/__pycache__/painting.cpython-310.pyc +0 -0
- product_diffusion_api/routers/__pycache__/sdxl_text_to_image.cpython-310.pyc +0 -0
- product_diffusion_api/routers/painting.py +20 -5
- product_diffusion_api/yolov8l.pt.REMOVED.git-id +1 -0
- scripts/__pycache__/config.cpython-310.pyc +0 -0
- scripts/__pycache__/inpainting_pipeline.cpython-310.pyc +0 -0
- scripts/__pycache__/s3_manager.cpython-310.pyc +0 -0
- scripts/__pycache__/utils.cpython-310.pyc +0 -0
- scripts/inpainting_pipeline.py +4 -6
configs/inpainting.yaml
CHANGED
@@ -5,7 +5,7 @@ target_width : 2560
|
|
5 |
target_height : 1472
|
6 |
prompt : 'Product on the table 4k ultrarealistic'
|
7 |
negative_prompt : 'low resolution , bad resolution , Deformation , Weird Artifacts, bad quality,blown up image, high brightness , high saturation '
|
8 |
-
roi_scale : 0.
|
9 |
strength : 0.6
|
10 |
guidance_scale : 7
|
11 |
num_inference_steps : 150
|
|
|
5 |
target_height : 1472
|
6 |
prompt : 'Product on the table 4k ultrarealistic'
|
7 |
negative_prompt : 'low resolution , bad resolution , Deformation , Weird Artifacts, bad quality,blown up image, high brightness , high saturation '
|
8 |
+
roi_scale : 0.5
|
9 |
strength : 0.6
|
10 |
guidance_scale : 7
|
11 |
num_inference_steps : 150
|
product_diffusion_api/__pycache__/endpoints.cpython-310.pyc
CHANGED
Binary files a/product_diffusion_api/__pycache__/endpoints.cpython-310.pyc and b/product_diffusion_api/__pycache__/endpoints.cpython-310.pyc differ
|
|
product_diffusion_api/endpoints.py
CHANGED
@@ -34,14 +34,15 @@ logfire.instrument_fastapi(app)
|
|
34 |
@app.get('/')
|
35 |
async def root():
|
36 |
return {
|
37 |
-
'message': 'Welcome to the
|
38 |
'description': 'This API provides endpoints for accessing and managing product diffusion data.',
|
39 |
'version': '1.0.0',
|
40 |
'author': 'Vikramjeet Singh',
|
41 |
'contact': {
|
42 |
'email': 'singh.vikram.1782000@gmail.com',
|
43 |
'github': 'https://github.com/vikramxD',
|
44 |
-
'website': 'https://vikramxd.github.io'
|
|
|
45 |
},
|
46 |
'license': 'MIT',
|
47 |
}
|
|
|
34 |
@app.get('/')
|
35 |
async def root():
|
36 |
return {
|
37 |
+
'message': 'Welcome to the PICPILOT API Page , Develop Visual Stories for your Brand',
|
38 |
'description': 'This API provides endpoints for accessing and managing product diffusion data.',
|
39 |
'version': '1.0.0',
|
40 |
'author': 'Vikramjeet Singh',
|
41 |
'contact': {
|
42 |
'email': 'singh.vikram.1782000@gmail.com',
|
43 |
'github': 'https://github.com/vikramxD',
|
44 |
+
'website': 'https://vikramxd.github.io',
|
45 |
+
'peerlist': 'https://peerlist.io/vikramxd'
|
46 |
},
|
47 |
'license': 'MIT',
|
48 |
}
|
product_diffusion_api/routers/__pycache__/painting.cpython-310.pyc
ADDED
Binary file (5.27 kB). View file
|
|
product_diffusion_api/routers/__pycache__/sdxl_text_to_image.cpython-310.pyc
ADDED
Binary file (7.17 kB). View file
|
|
product_diffusion_api/routers/painting.py
CHANGED
@@ -11,6 +11,8 @@ from PIL import Image
|
|
11 |
import io
|
12 |
from utils import ImageAugmentation
|
13 |
from hydra import compose, initialize
|
|
|
|
|
14 |
|
15 |
router = APIRouter()
|
16 |
|
@@ -106,13 +108,26 @@ def run_inference(cfg: dict, image_path: str, prompt: str, negative_prompt: str,
|
|
106 |
HTTPException: If an error occurs during the inference process.
|
107 |
|
108 |
"""
|
109 |
-
image, mask_image = augment_image(image_path,
|
|
|
|
|
|
|
|
|
|
|
110 |
|
111 |
-
pipeline = AutoPaintingPipeline(model_name=cfg['model'],
|
112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
return pil_to_s3_json(output, file_name="output.png")
|
114 |
|
115 |
-
@router.post("
|
116 |
async def inpainting_inference(image: UploadFile = File(...),
|
117 |
prompt: str = "",
|
118 |
negative_prompt: str = "",
|
@@ -120,7 +135,7 @@ async def inpainting_inference(image: UploadFile = File(...),
|
|
120 |
strength: float = 0.5,
|
121 |
guidance_scale: float = 7.5):
|
122 |
"""
|
123 |
-
Run the inpainting inference pipeline.
|
124 |
"""
|
125 |
try:
|
126 |
image_bytes = await image.read()
|
|
|
11 |
import io
|
12 |
from utils import ImageAugmentation
|
13 |
from hydra import compose, initialize
|
14 |
+
import lightning.pytorch as pl
|
15 |
+
pl.seed_everything(42)
|
16 |
|
17 |
router = APIRouter()
|
18 |
|
|
|
108 |
HTTPException: If an error occurs during the inference process.
|
109 |
|
110 |
"""
|
111 |
+
image, mask_image = augment_image(image_path,
|
112 |
+
cfg['target_width'],
|
113 |
+
cfg['target_height'],
|
114 |
+
cfg['roi_scale'],
|
115 |
+
cfg['segmentation_model'],
|
116 |
+
cfg['detection_model'])
|
117 |
|
118 |
+
pipeline = AutoPaintingPipeline(model_name=cfg['model'],
|
119 |
+
image=image,
|
120 |
+
mask_image=mask_image,
|
121 |
+
target_height=cfg['target_height'],
|
122 |
+
target_width=cfg['target_width'])
|
123 |
+
output = pipeline.run_inference(prompt=prompt,
|
124 |
+
negative_prompt=negative_prompt,
|
125 |
+
num_inference_steps=num_inference_steps,
|
126 |
+
strength=strength,
|
127 |
+
guidance_scale=guidance_scale)
|
128 |
return pil_to_s3_json(output, file_name="output.png")
|
129 |
|
130 |
+
@router.post("kandinskyv2.2_inpainting")
|
131 |
async def inpainting_inference(image: UploadFile = File(...),
|
132 |
prompt: str = "",
|
133 |
negative_prompt: str = "",
|
|
|
135 |
strength: float = 0.5,
|
136 |
guidance_scale: float = 7.5):
|
137 |
"""
|
138 |
+
Run the inpainting/outpainting inference pipeline.
|
139 |
"""
|
140 |
try:
|
141 |
image_bytes = await image.read()
|
product_diffusion_api/yolov8l.pt.REMOVED.git-id
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
4b11a02a7599e520f9f14a4703f4991237d6ce50
|
scripts/__pycache__/config.cpython-310.pyc
CHANGED
Binary files a/scripts/__pycache__/config.cpython-310.pyc and b/scripts/__pycache__/config.cpython-310.pyc differ
|
|
scripts/__pycache__/inpainting_pipeline.cpython-310.pyc
ADDED
Binary file (3.2 kB). View file
|
|
scripts/__pycache__/s3_manager.cpython-310.pyc
CHANGED
Binary files a/scripts/__pycache__/s3_manager.cpython-310.pyc and b/scripts/__pycache__/s3_manager.cpython-310.pyc differ
|
|
scripts/__pycache__/utils.cpython-310.pyc
CHANGED
Binary files a/scripts/__pycache__/utils.cpython-310.pyc and b/scripts/__pycache__/utils.cpython-310.pyc differ
|
|
scripts/inpainting_pipeline.py
CHANGED
@@ -1,15 +1,14 @@
|
|
1 |
import torch
|
2 |
-
from diffusers import AutoPipelineForInpainting
|
3 |
from diffusers.utils import load_image
|
4 |
from utils import (accelerator, ImageAugmentation, clear_memory)
|
5 |
import hydra
|
6 |
from omegaconf import DictConfig
|
7 |
from PIL import Image
|
8 |
-
|
9 |
-
#pl.seed_everything(1234)
|
10 |
-
|
11 |
|
12 |
|
|
|
13 |
class AutoPaintingPipeline:
|
14 |
"""
|
15 |
AutoPaintingPipeline class represents a pipeline for auto painting using an inpainting model from diffusers.
|
@@ -41,7 +40,7 @@ class AutoPaintingPipeline:
|
|
41 |
Returns:
|
42 |
Image: The output image after inpainting.
|
43 |
"""
|
44 |
-
|
45 |
image = load_image(self.image)
|
46 |
mask_image = load_image(self.mask_image)
|
47 |
output = self.pipeline(prompt=prompt,negative_prompt=negative_prompt,image=image,mask_image=mask_image,num_inference_steps=num_inference_steps,strength=strength,guidance_scale=guidance_scale, height = self.target_height ,width = self.target_width).images[0]
|
@@ -63,7 +62,6 @@ def inference(cfg: DictConfig):
|
|
63 |
extended_image = augmenter.extend_image(image)
|
64 |
mask_image = augmenter.generate_mask_from_bbox(extended_image, cfg.segmentation_model, cfg.detection_model)
|
65 |
mask_image = augmenter.invert_mask(mask_image)
|
66 |
-
#mask_image = cv2.GaussianBlur(np.array(mask_image), (7,7), 0)
|
67 |
prompt = cfg.prompt
|
68 |
negative_prompt = cfg.negative_prompt
|
69 |
num_inference_steps = cfg.num_inference_steps
|
|
|
1 |
import torch
|
2 |
+
from diffusers import AutoPipelineForInpainting,DiffusionPipeline
|
3 |
from diffusers.utils import load_image
|
4 |
from utils import (accelerator, ImageAugmentation, clear_memory)
|
5 |
import hydra
|
6 |
from omegaconf import DictConfig
|
7 |
from PIL import Image
|
8 |
+
from functools import lru_cache
|
|
|
|
|
9 |
|
10 |
|
11 |
+
@lru_cache(maxsize=1)
|
12 |
class AutoPaintingPipeline:
|
13 |
"""
|
14 |
AutoPaintingPipeline class represents a pipeline for auto painting using an inpainting model from diffusers.
|
|
|
40 |
Returns:
|
41 |
Image: The output image after inpainting.
|
42 |
"""
|
43 |
+
|
44 |
image = load_image(self.image)
|
45 |
mask_image = load_image(self.mask_image)
|
46 |
output = self.pipeline(prompt=prompt,negative_prompt=negative_prompt,image=image,mask_image=mask_image,num_inference_steps=num_inference_steps,strength=strength,guidance_scale=guidance_scale, height = self.target_height ,width = self.target_width).images[0]
|
|
|
62 |
extended_image = augmenter.extend_image(image)
|
63 |
mask_image = augmenter.generate_mask_from_bbox(extended_image, cfg.segmentation_model, cfg.detection_model)
|
64 |
mask_image = augmenter.invert_mask(mask_image)
|
|
|
65 |
prompt = cfg.prompt
|
66 |
negative_prompt = cfg.negative_prompt
|
67 |
num_inference_steps = cfg.num_inference_steps
|