Spaces:
Sleeping
Sleeping
Sync from GitHub via hub-sync
Browse files- schemas/inpaint_request.py +0 -1
- services/model_manager.py +10 -6
- tasks.py +0 -3
schemas/inpaint_request.py
CHANGED
|
@@ -6,5 +6,4 @@ from pydantic import BaseModel, Field
|
|
| 6 |
class InpaintRequest(BaseModel):
|
| 7 |
mode: Literal["blur", "remove", "diffusion"] = "blur"
|
| 8 |
positive_prompt: str = ""
|
| 9 |
-
negative_prompt: str = ""
|
| 10 |
num_inference_steps: int = Field(default=4, ge=4, le=15)
|
|
|
|
| 6 |
class InpaintRequest(BaseModel):
|
| 7 |
mode: Literal["blur", "remove", "diffusion"] = "blur"
|
| 8 |
positive_prompt: str = ""
|
|
|
|
| 9 |
num_inference_steps: int = Field(default=4, ge=4, le=15)
|
services/model_manager.py
CHANGED
|
@@ -39,12 +39,16 @@ def get_inpaintor_model(MODELS: dict):
|
|
| 39 |
str(model_source),
|
| 40 |
**kwargs,
|
| 41 |
)
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
pipe.compile()
|
| 49 |
MODELS["inpaintor"] = pipe
|
| 50 |
return MODELS["inpaintor"]
|
|
|
|
| 39 |
str(model_source),
|
| 40 |
**kwargs,
|
| 41 |
)
|
| 42 |
+
|
| 43 |
+
# ❌ REMOVE OR COMMENT OUT THIS ENTIRE BLOCK ❌
|
| 44 |
+
# pipe.reshape(
|
| 45 |
+
# batch_size=1,
|
| 46 |
+
# height=config.INPAINTOR_IMAGE_SIZE,
|
| 47 |
+
# width=config.INPAINTOR_IMAGE_SIZE,
|
| 48 |
+
# num_images_per_prompt=1,
|
| 49 |
+
# )
|
| 50 |
+
|
| 51 |
+
# Keep compile!
|
| 52 |
pipe.compile()
|
| 53 |
MODELS["inpaintor"] = pipe
|
| 54 |
return MODELS["inpaintor"]
|
tasks.py
CHANGED
|
@@ -102,7 +102,6 @@ def inpaint(
|
|
| 102 |
job_id: str,
|
| 103 |
mode: str = "blur",
|
| 104 |
positive_prompt: str = "",
|
| 105 |
-
negative_prompt: str = "",
|
| 106 |
num_inference_steps: int = 4,
|
| 107 |
) -> bool:
|
| 108 |
job_path = config.UPLOAD_DIR / job_id
|
|
@@ -118,7 +117,6 @@ def inpaint(
|
|
| 118 |
model_size = (config.INPAINTOR_IMAGE_SIZE, config.INPAINTOR_IMAGE_SIZE)
|
| 119 |
generated = model(
|
| 120 |
prompt=positive_prompt,
|
| 121 |
-
negative_prompt=negative_prompt,
|
| 122 |
image=orig_img.resize(model_size),
|
| 123 |
mask_image=mask_img.resize(model_size, Image.Resampling.NEAREST),
|
| 124 |
num_inference_steps=num_inference_steps,
|
|
@@ -163,7 +161,6 @@ if __name__ == "__main__":
|
|
| 163 |
job_id=config.DEBUG_JOB_ID,
|
| 164 |
mode="diffusion",
|
| 165 |
positive_prompt="red hat high quality",
|
| 166 |
-
negative_prompt="blurry, messy, bad looking",
|
| 167 |
num_inference_steps=4,
|
| 168 |
) # type: ignore
|
| 169 |
|
|
|
|
| 102 |
job_id: str,
|
| 103 |
mode: str = "blur",
|
| 104 |
positive_prompt: str = "",
|
|
|
|
| 105 |
num_inference_steps: int = 4,
|
| 106 |
) -> bool:
|
| 107 |
job_path = config.UPLOAD_DIR / job_id
|
|
|
|
| 117 |
model_size = (config.INPAINTOR_IMAGE_SIZE, config.INPAINTOR_IMAGE_SIZE)
|
| 118 |
generated = model(
|
| 119 |
prompt=positive_prompt,
|
|
|
|
| 120 |
image=orig_img.resize(model_size),
|
| 121 |
mask_image=mask_img.resize(model_size, Image.Resampling.NEAREST),
|
| 122 |
num_inference_steps=num_inference_steps,
|
|
|
|
| 161 |
job_id=config.DEBUG_JOB_ID,
|
| 162 |
mode="diffusion",
|
| 163 |
positive_prompt="red hat high quality",
|
|
|
|
| 164 |
num_inference_steps=4,
|
| 165 |
) # type: ignore
|
| 166 |
|