zhiweili
commited on
Commit
•
2a2d3ad
1
Parent(s):
ee01755
fix output dir
Browse files- app_base.py +1 -3
- segment_utils.py +8 -1
app_base.py
CHANGED
@@ -30,7 +30,6 @@ def create_demo() -> gr.Blocks:
|
|
30 |
num_steps: int,
|
31 |
start_step: int,
|
32 |
guidance_scale: float,
|
33 |
-
segment_size: int,
|
34 |
generate_size: int,
|
35 |
upscale_prompt: str,
|
36 |
upscale_start_size: int = 256,
|
@@ -73,7 +72,6 @@ def create_demo() -> gr.Blocks:
|
|
73 |
upscale_steps=upscale_steps,
|
74 |
)
|
75 |
run_task_time, time_cost_str = get_time_cost(run_task_time, time_cost_str)
|
76 |
-
enhanced_image = enhanced_image.resize((segment_size, segment_size))
|
77 |
|
78 |
return enhanced_image, res_image, time_cost_str
|
79 |
|
@@ -135,7 +133,7 @@ def create_demo() -> gr.Blocks:
|
|
135 |
).success(
|
136 |
fn=image_to_image,
|
137 |
inputs=[origin_area_image, input_image_prompt, edit_prompt,seed,w1, num_steps, start_step,
|
138 |
-
guidance_scale,
|
139 |
pre_upscale, pre_upscale_start_size, pre_upscale_steps],
|
140 |
outputs=[enhanced_image, generated_image, generated_cost],
|
141 |
).success(
|
|
|
30 |
num_steps: int,
|
31 |
start_step: int,
|
32 |
guidance_scale: float,
|
|
|
33 |
generate_size: int,
|
34 |
upscale_prompt: str,
|
35 |
upscale_start_size: int = 256,
|
|
|
72 |
upscale_steps=upscale_steps,
|
73 |
)
|
74 |
run_task_time, time_cost_str = get_time_cost(run_task_time, time_cost_str)
|
|
|
75 |
|
76 |
return enhanced_image, res_image, time_cost_str
|
77 |
|
|
|
133 |
).success(
|
134 |
fn=image_to_image,
|
135 |
inputs=[origin_area_image, input_image_prompt, edit_prompt,seed,w1, num_steps, start_step,
|
136 |
+
guidance_scale, generate_size, upscale_prompt, upscale_start_size, upscale_steps,
|
137 |
pre_upscale, pre_upscale_start_size, pre_upscale_steps],
|
138 |
outputs=[enhanced_image, generated_image, generated_cost],
|
139 |
).success(
|
segment_utils.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import numpy as np
|
2 |
import mediapipe as mp
|
3 |
import uuid
|
|
|
4 |
|
5 |
from PIL import Image
|
6 |
from mediapipe.tasks import python
|
@@ -29,7 +30,13 @@ def restore_result(croper, category, generated_image):
|
|
29 |
# else:
|
30 |
# extension = 'jpg'
|
31 |
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
restored_image.save(path, quality=95)
|
34 |
|
35 |
return restored_image, path
|
|
|
1 |
import numpy as np
|
2 |
import mediapipe as mp
|
3 |
import uuid
|
4 |
+
import os
|
5 |
|
6 |
from PIL import Image
|
7 |
from mediapipe.tasks import python
|
|
|
30 |
# else:
|
31 |
# extension = 'jpg'
|
32 |
|
33 |
+
tmpPrefix = "/tmp/gradio/"
|
34 |
+
|
35 |
+
targetDir = f"{tmpPrefix}output/"
|
36 |
+
if not os.path.exists(targetDir):
|
37 |
+
os.makedirs(targetDir)
|
38 |
+
|
39 |
+
path = f"{targetDir}{uuid.uuid4()}.{extension}"
|
40 |
restored_image.save(path, quality=95)
|
41 |
|
42 |
return restored_image, path
|