Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -215,11 +215,15 @@ def inpainting_run(input_image_editor,
|
|
| 215 |
):
|
| 216 |
with tempfile.NamedTemporaryFile(suffix=".png", delete=False) as temp_file:
|
| 217 |
# hr_image.save(temp_file.name)
|
| 218 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 219 |
temp_file_path = temp_file.name #картинка
|
| 220 |
print("background", temp_file_path)
|
| 221 |
with tempfile.NamedTemporaryFile(suffix=".png", delete=False) as temp_file2:
|
| 222 |
-
|
| 223 |
temp_file_path2 = temp_file2.name # маска
|
| 224 |
print("маска", temp_file_path2)
|
| 225 |
|
|
@@ -241,27 +245,6 @@ def inpainting_run(input_image_editor,
|
|
| 241 |
return result
|
| 242 |
|
| 243 |
|
| 244 |
-
# client = Client("https://pair-hd-painter.hf.space/--replicas/0l7ng/")
|
| 245 |
-
# result = client.predict(
|
| 246 |
-
# model_name, # str (Option from: [('Dreamshaper Inpainting V8', 'Dreamshaper Inpainting V8'), ('Stable-Inpainting 2.0', 'Stable-Inpainting 2.0'), ('Stable-Inpainting 1.5', 'Stable-Inpainting 1.5')]) in 'Please select a model!' Dropdown component
|
| 247 |
-
# use_rasg, # bool in 'Use RASG' Checkbox component
|
| 248 |
-
# use_painta, # bool in 'Use PAIntA' Checkbox component
|
| 249 |
-
# prompt, # str in 'Inpainting Prompt' Textbox component
|
| 250 |
-
# handle_file(temp_file_path2), # str (filepath on your computer (or URL) of image) in 'Input Image' Image component МАСКА
|
| 251 |
-
# handle_file(temp_file_path), # str (filepath on your computer (or URL) of image) in 'parameter_15' Image component КАРТИНКА
|
| 252 |
-
# seed, # int | float in 'Seed' Number component
|
| 253 |
-
# eta, # int | float (numeric value between 0 and 1) in 'eta' Slider component
|
| 254 |
-
# negative_prompt, # str in 'Negative prompt' Textbox component
|
| 255 |
-
# positive_prompt, # str in 'Positive prompt' Textbox component
|
| 256 |
-
# ddim_steps, # int | float (numeric value between 10 and 100) in 'Number of diffusion steps' Slider component
|
| 257 |
-
# guidance_scale, # int | float (numeric value between 0 and 30) in 'Guidance Scale' Slider component
|
| 258 |
-
# batch_size, # int | float in 'Batch size' Number component
|
| 259 |
-
# session_id, # str in 'parameter_44' Textbox component
|
| 260 |
-
# api_name="/inpaint"
|
| 261 |
-
# )
|
| 262 |
-
# print(result)
|
| 263 |
-
|
| 264 |
-
|
| 265 |
#3d models
|
| 266 |
def hunyuan_client(request: gr.Request):
|
| 267 |
try:
|
|
@@ -395,13 +378,15 @@ with gr.Blocks() as demo:
|
|
| 395 |
with gr.Row(equal_height=True):
|
| 396 |
with gr.Column(scale=5):
|
| 397 |
# inpainting_input = gr.ImageEditor(type="pil", label="Сегмент для Inpainting")
|
|
|
|
| 398 |
imageMask = gr.ImageEditor(
|
| 399 |
label='Сегмент для Inpainting',
|
| 400 |
type='pil',
|
| 401 |
-
sources=["upload", "webcam"],
|
| 402 |
-
image_mode='RGB',
|
| 403 |
-
layers=False,
|
| 404 |
-
brush=gr.Brush(colors=["#FFFFFF"], color_mode="fixed")
|
|
|
|
| 405 |
|
| 406 |
prompt = gr.Textbox(lines=2, label="Введите промпт для Inpainting", placeholder="Enter prompt here...")
|
| 407 |
inpainting_button = gr.Button("Inpainting")
|
|
|
|
| 215 |
):
|
| 216 |
with tempfile.NamedTemporaryFile(suffix=".png", delete=False) as temp_file:
|
| 217 |
# hr_image.save(temp_file.name)
|
| 218 |
+
print("inpainting_run")
|
| 219 |
+
print(len(input_image_editor["layers"]))
|
| 220 |
+
print(input_image_editor["layers"])
|
| 221 |
+
print(input_image_editor["layers"][0])
|
| 222 |
+
input_image_editor["background"].save(temp_file.name)
|
| 223 |
temp_file_path = temp_file.name #картинка
|
| 224 |
print("background", temp_file_path)
|
| 225 |
with tempfile.NamedTemporaryFile(suffix=".png", delete=False) as temp_file2:
|
| 226 |
+
input_image_editor["layers"][0].save(temp_file2.name)
|
| 227 |
temp_file_path2 = temp_file2.name # маска
|
| 228 |
print("маска", temp_file_path2)
|
| 229 |
|
|
|
|
| 245 |
return result
|
| 246 |
|
| 247 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 248 |
#3d models
|
| 249 |
def hunyuan_client(request: gr.Request):
|
| 250 |
try:
|
|
|
|
| 378 |
with gr.Row(equal_height=True):
|
| 379 |
with gr.Column(scale=5):
|
| 380 |
# inpainting_input = gr.ImageEditor(type="pil", label="Сегмент для Inpainting")
|
| 381 |
+
gr.Markdown("У gradio.ImageEditor какой-то странный баг. Если у вас застряла мышка при попытке нарисовать маску - перейдите на 1-й слой. Для маски будет выбран 1-й слой из списка. Для маски используется белый цвет.")
|
| 382 |
imageMask = gr.ImageEditor(
|
| 383 |
label='Сегмент для Inpainting',
|
| 384 |
type='pil',
|
| 385 |
+
# sources=["upload", "webcam"],
|
| 386 |
+
# image_mode='RGB',
|
| 387 |
+
# layers=False,
|
| 388 |
+
brush=gr.Brush(colors=["#FFFFFF"], color_mode="fixed")
|
| 389 |
+
)
|
| 390 |
|
| 391 |
prompt = gr.Textbox(lines=2, label="Введите промпт для Inpainting", placeholder="Enter prompt here...")
|
| 392 |
inpainting_button = gr.Button("Inpainting")
|