Spaces:
Running on Zero
Running on Zero
AndranikSargsyan commited on
Commit Β·
ed49d3d
1
Parent(s): 27d4dcc
fix arXiv link
Browse files
README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
---
|
| 2 |
title: FlowDIS
|
| 3 |
emoji: π
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 6.3.0
|
| 8 |
python_version: 3.12
|
|
|
|
| 1 |
---
|
| 2 |
title: FlowDIS
|
| 3 |
emoji: π
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: pink
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 6.3.0
|
| 8 |
python_version: 3.12
|
app.py
CHANGED
|
@@ -6,13 +6,13 @@ import shutil
|
|
| 6 |
from copy import deepcopy
|
| 7 |
from pathlib import Path
|
| 8 |
|
| 9 |
-
# Set up logging
|
| 10 |
-
logging.basicConfig(
|
| 11 |
-
level=logging.INFO,
|
| 12 |
-
format="%(asctime)s | %(levelname)s | %(message)s",
|
| 13 |
-
datefmt="%Y-%m-%d %H:%M:%S",
|
| 14 |
-
)
|
| 15 |
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
# Set Gradio temp directory BEFORE importing gradio to avoid permission issues
|
| 18 |
TEMP_DIR = Path(__file__).parent / "gradio_temp"
|
|
@@ -74,6 +74,7 @@ def process_image(image, prompt, expand_prompt_enabled, resolution, num_inferenc
|
|
| 74 |
if isinstance(image, np.ndarray):
|
| 75 |
image = Image.fromarray(image)
|
| 76 |
|
|
|
|
| 77 |
logger.info(f"Original prompt: {prompt}")
|
| 78 |
if prompt != "" and expand_prompt_enabled:
|
| 79 |
prompt = expand_prompt(image, prompt)
|
|
@@ -94,9 +95,15 @@ def process_image(image, prompt, expand_prompt_enabled, resolution, num_inferenc
|
|
| 94 |
uid = uuid.uuid4().hex
|
| 95 |
png_path = TEMP_DIR / f"{uid}.png"
|
| 96 |
transparent_png.save(png_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
return (
|
| 98 |
gr.update(value=[image, transparent_png], key=uid),
|
| 99 |
-
gr.update(value=str(png_path), interactive=True)
|
|
|
|
| 100 |
)
|
| 101 |
|
| 102 |
|
|
@@ -209,7 +216,7 @@ with gr.Blocks(
|
|
| 209 |
button_primary_text_color="#ffffff",
|
| 210 |
button_primary_text_color_dark="#ffffff",
|
| 211 |
),
|
| 212 |
-
delete_cache=(
|
| 213 |
) as demo:
|
| 214 |
gr.HTML(
|
| 215 |
"""
|
|
@@ -325,7 +332,7 @@ with gr.Blocks(
|
|
| 325 |
<div class="flow-title"><span style="color:#C209C1">β¦</span> FlowDIS Demo</div>
|
| 326 |
|
| 327 |
<div class="flow-links">
|
| 328 |
-
<span>π</span><a href="https://arxiv.org/" target="_blank" rel="noopener noreferrer">arXiv</a>
|
| 329 |
<span>π»</span><a href="https://github.com/Picsart-AI-Research/FlowDIS" target="_blank" rel="noopener noreferrer">Code</a>
|
| 330 |
</div>
|
| 331 |
|
|
@@ -427,6 +434,7 @@ with gr.Blocks(
|
|
| 427 |
variant="primary",
|
| 428 |
interactive=False
|
| 429 |
)
|
|
|
|
| 430 |
|
| 431 |
# Connect the submit button to the processing function
|
| 432 |
submit_btn.click(
|
|
@@ -435,7 +443,7 @@ with gr.Blocks(
|
|
| 435 |
).then(
|
| 436 |
fn=process_image,
|
| 437 |
inputs=[input_image, text_input, expand_prompt_check, resolution_slider, steps_slider],
|
| 438 |
-
outputs=[output_image, download_btn]
|
| 439 |
)
|
| 440 |
|
| 441 |
# Optional: Also trigger on text input enter key
|
|
@@ -445,7 +453,7 @@ with gr.Blocks(
|
|
| 445 |
).then(
|
| 446 |
fn=process_image,
|
| 447 |
inputs=[input_image, text_input, expand_prompt_check, resolution_slider, steps_slider],
|
| 448 |
-
outputs=[output_image, download_btn],
|
| 449 |
)
|
| 450 |
|
| 451 |
examples_component = gr.Examples(
|
|
@@ -461,7 +469,7 @@ with gr.Blocks(
|
|
| 461 |
).then(
|
| 462 |
process_image,
|
| 463 |
inputs=[input_image, text_input, expand_prompt_check, resolution_slider, steps_slider],
|
| 464 |
-
outputs=[output_image, download_btn],
|
| 465 |
)
|
| 466 |
|
| 467 |
|
|
|
|
| 6 |
from copy import deepcopy
|
| 7 |
from pathlib import Path
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
logger = logging.getLogger(__name__)
|
| 10 |
+
logger.setLevel(logging.INFO)
|
| 11 |
+
_handler = logging.StreamHandler()
|
| 12 |
+
_handler.setFormatter(logging.Formatter("%(asctime)s | %(levelname)s | %(message)s", datefmt="%Y-%m-%d %H:%M:%S"))
|
| 13 |
+
logger.addHandler(_handler)
|
| 14 |
+
logging.getLogger("qwen").setLevel(logging.INFO)
|
| 15 |
+
logging.getLogger("qwen").addHandler(_handler)
|
| 16 |
|
| 17 |
# Set Gradio temp directory BEFORE importing gradio to avoid permission issues
|
| 18 |
TEMP_DIR = Path(__file__).parent / "gradio_temp"
|
|
|
|
| 74 |
if isinstance(image, np.ndarray):
|
| 75 |
image = Image.fromarray(image)
|
| 76 |
|
| 77 |
+
logger.info("------")
|
| 78 |
logger.info(f"Original prompt: {prompt}")
|
| 79 |
if prompt != "" and expand_prompt_enabled:
|
| 80 |
prompt = expand_prompt(image, prompt)
|
|
|
|
| 95 |
uid = uuid.uuid4().hex
|
| 96 |
png_path = TEMP_DIR / f"{uid}.png"
|
| 97 |
transparent_png.save(png_path)
|
| 98 |
+
input_path = TEMP_DIR / f"{uid}_input.png"
|
| 99 |
+
image.save(input_path)
|
| 100 |
+
logger.info(f"Input image: /file={input_path}")
|
| 101 |
+
logger.info(f"Result PNG: /file={png_path}")
|
| 102 |
+
logger.info("------")
|
| 103 |
return (
|
| 104 |
gr.update(value=[image, transparent_png], key=uid),
|
| 105 |
+
gr.update(value=str(png_path), interactive=True),
|
| 106 |
+
gr.update(value=str(input_path)),
|
| 107 |
)
|
| 108 |
|
| 109 |
|
|
|
|
| 216 |
button_primary_text_color="#ffffff",
|
| 217 |
button_primary_text_color_dark="#ffffff",
|
| 218 |
),
|
| 219 |
+
delete_cache=(14400, 14400)
|
| 220 |
) as demo:
|
| 221 |
gr.HTML(
|
| 222 |
"""
|
|
|
|
| 332 |
<div class="flow-title"><span style="color:#C209C1">β¦</span> FlowDIS Demo</div>
|
| 333 |
|
| 334 |
<div class="flow-links">
|
| 335 |
+
<span>π</span><a href="https://arxiv.org/abs/2605.05077" target="_blank" rel="noopener noreferrer">arXiv</a>
|
| 336 |
<span>π»</span><a href="https://github.com/Picsart-AI-Research/FlowDIS" target="_blank" rel="noopener noreferrer">Code</a>
|
| 337 |
</div>
|
| 338 |
|
|
|
|
| 434 |
variant="primary",
|
| 435 |
interactive=False
|
| 436 |
)
|
| 437 |
+
input_cache = gr.File(visible=False)
|
| 438 |
|
| 439 |
# Connect the submit button to the processing function
|
| 440 |
submit_btn.click(
|
|
|
|
| 443 |
).then(
|
| 444 |
fn=process_image,
|
| 445 |
inputs=[input_image, text_input, expand_prompt_check, resolution_slider, steps_slider],
|
| 446 |
+
outputs=[output_image, download_btn, input_cache]
|
| 447 |
)
|
| 448 |
|
| 449 |
# Optional: Also trigger on text input enter key
|
|
|
|
| 453 |
).then(
|
| 454 |
fn=process_image,
|
| 455 |
inputs=[input_image, text_input, expand_prompt_check, resolution_slider, steps_slider],
|
| 456 |
+
outputs=[output_image, download_btn, input_cache],
|
| 457 |
)
|
| 458 |
|
| 459 |
examples_component = gr.Examples(
|
|
|
|
| 469 |
).then(
|
| 470 |
process_image,
|
| 471 |
inputs=[input_image, text_input, expand_prompt_check, resolution_slider, steps_slider],
|
| 472 |
+
outputs=[output_image, download_btn, input_cache],
|
| 473 |
)
|
| 474 |
|
| 475 |
|