Spaces:
Running
Running
Commit
•
f419a09
1
Parent(s):
aebb743
chore: Update roi_scale in inpainting.yaml and add gradio UI for SDXL LORA Inpainting
Browse filesFormer-commit-id: b7b92f4bad53cf4a209420d4c71d1c87cdf69869 [formerly fbf9c06519715f33d9c88503d3d72e426703db29]
Former-commit-id: d9b48f2c7818aa2732a3388320ed23afd13b49cd
- configs/inpainting.yaml +1 -1
- gradio-ui/ui.py +52 -0
- product_diffusion_api/__pycache__/endpoints.cpython-310.pyc +0 -0
- product_diffusion_api/endpoints.py +3 -1
- product_diffusion_api/routers/__pycache__/painting.cpython-310.pyc +0 -0
- product_diffusion_api/routers/painting.py +1 -1
- product_diffusion_api/yolov8s.pt.REMOVED.git-id +1 -0
- scripts/__pycache__/inpainting_pipeline.cpython-310.pyc +0 -0
- scripts/inpainting_pipeline.py +1 -1
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.9
|
9 |
strength : 0.6
|
10 |
guidance_scale : 7
|
11 |
num_inference_steps : 150
|
gradio-ui/ui.py
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import requests
|
3 |
+
from pydantic import BaseModel
|
4 |
+
|
5 |
+
# Define your API endpoint
|
6 |
+
SDXL_LORA_API_URL = 'http://127.0.0.1:8000/api/v1/product-diffusion/sdxl_v0_lora_inference'
|
7 |
+
|
8 |
+
# Define the InpaintingRequest model
|
9 |
+
class InpaintingRequest(BaseModel):
|
10 |
+
prompt: str
|
11 |
+
num_inference_steps: int
|
12 |
+
guidance_scale: float
|
13 |
+
negative_prompt: str
|
14 |
+
num_images: int
|
15 |
+
mode: str
|
16 |
+
|
17 |
+
def generate_sdxl_lora_image(prompt, negative_prompt, num_inference_steps, guidance_scale, num_images, mode):
|
18 |
+
# Prepare the payload for SDXL LORA API
|
19 |
+
payload = InpaintingRequest(
|
20 |
+
prompt=prompt,
|
21 |
+
negative_prompt=negative_prompt,
|
22 |
+
num_inference_steps=num_inference_steps,
|
23 |
+
guidance_scale=guidance_scale,
|
24 |
+
num_images=num_images,
|
25 |
+
mode=mode
|
26 |
+
).dict()
|
27 |
+
|
28 |
+
response = requests.post(SDXL_LORA_API_URL, json=payload)
|
29 |
+
if response.status_code == 200:
|
30 |
+
return response.json().get('image')
|
31 |
+
else:
|
32 |
+
return f"Error: {response.json().get('detail', 'Unknown error')}"
|
33 |
+
|
34 |
+
with gr.Blocks() as demo:
|
35 |
+
with gr.Tab("SDXL LORA Inpainting"):
|
36 |
+
gr.Markdown("## SDXL LORA Inpainting")
|
37 |
+
with gr.Row():
|
38 |
+
with gr.Column():
|
39 |
+
gr.Markdown("### Input Parameters")
|
40 |
+
prompt = gr.Textbox(label="Prompt", placeholder="Enter your prompt here")
|
41 |
+
negative_prompt = gr.Textbox(label="Negative Prompt", placeholder="Enter negative prompt here")
|
42 |
+
num_inference_steps = gr.Slider(minimum=1, maximum=100, step=1, value=20, label="Inference Steps")
|
43 |
+
guidance_scale = gr.Slider(minimum=1.0, maximum=20.0, step=0.1, value=7.5, label="Guidance Scale")
|
44 |
+
num_images = gr.Slider(minimum=1, maximum=10, step=1, value=1, label="Number of Images")
|
45 |
+
mode = gr.Dropdown(choices=["s3_json", "default"], value="s3_json", label="Mode")
|
46 |
+
generate_button = gr.Button(value="Generate Image")
|
47 |
+
with gr.Column():
|
48 |
+
gr.Markdown("### Output")
|
49 |
+
output_image = gr.Image(label="Generated Image")
|
50 |
+
generate_button.click(fn=generate_sdxl_lora_image, inputs=[prompt, negative_prompt, num_inference_steps, guidance_scale, num_images, mode], outputs=output_image)
|
51 |
+
|
52 |
+
demo.launch()
|
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
@@ -3,7 +3,7 @@ from fastapi.middleware.cors import CORSMiddleware
|
|
3 |
from routers import sdxl_text_to_image
|
4 |
from routers import painting
|
5 |
import logfire
|
6 |
-
|
7 |
|
8 |
|
9 |
|
@@ -51,3 +51,5 @@ async def root():
|
|
51 |
def check_health():
|
52 |
return {"status": "ok"}
|
53 |
|
|
|
|
|
|
3 |
from routers import sdxl_text_to_image
|
4 |
from routers import painting
|
5 |
import logfire
|
6 |
+
import uvicorn
|
7 |
|
8 |
|
9 |
|
|
|
51 |
def check_health():
|
52 |
return {"status": "ok"}
|
53 |
|
54 |
+
uvicorn.run(app, host="0.0.0.0", port=8000)
|
55 |
+
|
product_diffusion_api/routers/__pycache__/painting.cpython-310.pyc
CHANGED
Binary files a/product_diffusion_api/routers/__pycache__/painting.cpython-310.pyc and b/product_diffusion_api/routers/__pycache__/painting.cpython-310.pyc differ
|
|
product_diffusion_api/routers/painting.py
CHANGED
@@ -127,7 +127,7 @@ def run_inference(cfg: dict, image_path: str, prompt: str, negative_prompt: str,
|
|
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 = "",
|
|
|
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 = "",
|
product_diffusion_api/yolov8s.pt.REMOVED.git-id
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
5f7efb1ee991ebccb1ee9a360066829e6435a168
|
scripts/__pycache__/inpainting_pipeline.cpython-310.pyc
CHANGED
Binary files a/scripts/__pycache__/inpainting_pipeline.cpython-310.pyc and b/scripts/__pycache__/inpainting_pipeline.cpython-310.pyc differ
|
|
scripts/inpainting_pipeline.py
CHANGED
@@ -8,7 +8,7 @@ from PIL import Image
|
|
8 |
from functools import lru_cache
|
9 |
|
10 |
|
11 |
-
|
12 |
class AutoPaintingPipeline:
|
13 |
"""
|
14 |
AutoPaintingPipeline class represents a pipeline for auto painting using an inpainting model from diffusers.
|
|
|
8 |
from functools import lru_cache
|
9 |
|
10 |
|
11 |
+
|
12 |
class AutoPaintingPipeline:
|
13 |
"""
|
14 |
AutoPaintingPipeline class represents a pipeline for auto painting using an inpainting model from diffusers.
|