Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -63,22 +63,25 @@ def end_session(req: gr.Request):
|
|
| 63 |
shutil.rmtree(user_dir)
|
| 64 |
|
| 65 |
@spaces.GPU
|
| 66 |
-
def preprocess_image(
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
|
|
|
| 76 |
new_width, new_height = int(width * ratio), int(height * ratio)
|
| 77 |
image = image['composite'].resize((new_width, new_height))
|
| 78 |
image = ImageOps.invert(image)
|
| 79 |
-
print("image:",type(image))
|
|
|
|
| 80 |
prompt, negative_prompt = apply_style(style_name, prompt, negative_prompt)
|
| 81 |
print("params:", prompt, negative_prompt, style_name, num_steps, guidance_scale, controlnet_conditioning_scale)
|
|
|
|
| 82 |
output = pipe_control(
|
| 83 |
prompt=prompt,
|
| 84 |
negative_prompt=negative_prompt,
|
|
@@ -87,9 +90,11 @@ def preprocess_image(image: Image.Image,
|
|
| 87 |
controlnet_conditioning_scale=controlnet_conditioning_scale,
|
| 88 |
guidance_scale=guidance_scale,
|
| 89 |
width=new_width,
|
| 90 |
-
height=new_height
|
|
|
|
|
|
|
| 91 |
processed_image = pipeline.preprocess_image(output)
|
| 92 |
-
return
|
| 93 |
|
| 94 |
def pack_state(gs: Gaussian, mesh: MeshExtractResult) -> dict:
|
| 95 |
return {
|
|
|
|
| 63 |
shutil.rmtree(user_dir)
|
| 64 |
|
| 65 |
@spaces.GPU
|
| 66 |
+
def preprocess_image(
|
| 67 |
+
image: Image.Image,
|
| 68 |
+
prompt: str = "",
|
| 69 |
+
negative_prompt: str = "",
|
| 70 |
+
style_name: str = "",
|
| 71 |
+
num_steps: int = 25,
|
| 72 |
+
guidance_scale: float = 5,
|
| 73 |
+
controlnet_conditioning_scale: float = 1.0,
|
| 74 |
+
) -> Image.Image:
|
| 75 |
+
width, height = image['composite'].size
|
| 76 |
+
ratio = np.sqrt(1024.0 * 1024.0 / (width * height))
|
| 77 |
new_width, new_height = int(width * ratio), int(height * ratio)
|
| 78 |
image = image['composite'].resize((new_width, new_height))
|
| 79 |
image = ImageOps.invert(image)
|
| 80 |
+
print("image:", type(image))
|
| 81 |
+
|
| 82 |
prompt, negative_prompt = apply_style(style_name, prompt, negative_prompt)
|
| 83 |
print("params:", prompt, negative_prompt, style_name, num_steps, guidance_scale, controlnet_conditioning_scale)
|
| 84 |
+
|
| 85 |
output = pipe_control(
|
| 86 |
prompt=prompt,
|
| 87 |
negative_prompt=negative_prompt,
|
|
|
|
| 90 |
controlnet_conditioning_scale=controlnet_conditioning_scale,
|
| 91 |
guidance_scale=guidance_scale,
|
| 92 |
width=new_width,
|
| 93 |
+
height=new_height,
|
| 94 |
+
).images[0]
|
| 95 |
+
|
| 96 |
processed_image = pipeline.preprocess_image(output)
|
| 97 |
+
return processed_image
|
| 98 |
|
| 99 |
def pack_state(gs: Gaussian, mesh: MeshExtractResult) -> dict:
|
| 100 |
return {
|