multimodalart HF Staff commited on
Commit
14aedbe
·
verified ·
1 Parent(s): ca5f734

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -6,7 +6,6 @@ import spaces
6
  import torch
7
  import gradio as gr
8
  import random
9
- import time
10
 
11
  from mage_flow import MageFlowPipeline
12
  from mage_flow.models.modules._attn_backend import set_attn_backend
@@ -22,10 +21,12 @@ set_attn_backend("sdpa")
22
 
23
 
24
  def _estimate_duration(prompt, negative_prompt, height, width, steps, cfg, seed, *args, **kwargs):
25
- """Estimate GPU time needed based on steps and resolution."""
 
 
26
  pixels = height * width
27
- base = 60
28
- step_time = 3.5 if pixels <= 1024 * 1024 else 6.0
29
  return min(300, base + int(steps * step_time))
30
 
31
 
@@ -77,7 +78,7 @@ CSS = """
77
  .dark .gradio-container { color: var(--body-text-color); }
78
  """
79
 
80
- with gr.Blocks(theme=gr.themes.Citrus(), css=CSS) as demo:
81
  gr.Markdown("# 🎨 Mage-Flow-Base Text-to-Image")
82
  gr.Markdown(
83
  "Generate images with [microsoft/Mage-Flow-Base](https://huggingface.co/microsoft/Mage-Flow-Base), "
@@ -142,4 +143,4 @@ with gr.Blocks(theme=gr.themes.Citrus(), css=CSS) as demo:
142
  api_name="generate",
143
  )
144
 
145
- demo.launch(mcp_server=True)
 
6
  import torch
7
  import gradio as gr
8
  import random
 
9
 
10
  from mage_flow import MageFlowPipeline
11
  from mage_flow.models.modules._attn_backend import set_attn_backend
 
21
 
22
 
23
  def _estimate_duration(prompt, negative_prompt, height, width, steps, cfg, seed, *args, **kwargs):
24
+ """Estimate GPU time needed based on steps and resolution.
25
+ Measured: ~15s for 30 steps at 1024x1024 with SDPA backend + content screening.
26
+ """
27
  pixels = height * width
28
+ base = 20 # content screening + text encoding overhead
29
+ step_time = 0.5 if pixels <= 1024 * 1024 else 1.0
30
  return min(300, base + int(steps * step_time))
31
 
32
 
 
78
  .dark .gradio-container { color: var(--body-text-color); }
79
  """
80
 
81
+ with gr.Blocks() as demo:
82
  gr.Markdown("# 🎨 Mage-Flow-Base Text-to-Image")
83
  gr.Markdown(
84
  "Generate images with [microsoft/Mage-Flow-Base](https://huggingface.co/microsoft/Mage-Flow-Base), "
 
143
  api_name="generate",
144
  )
145
 
146
+ demo.launch(mcp_server=True, theme=gr.themes.Citrus(), css=CSS)