Spaces:
Running on Zero
Running on Zero
update app
Browse files
app.py
CHANGED
|
@@ -7,37 +7,57 @@ import torch
|
|
| 7 |
import random
|
| 8 |
from PIL import Image
|
| 9 |
from typing import Iterable
|
| 10 |
-
from gradio.themes import
|
| 11 |
from gradio.themes.utils import colors, fonts, sizes
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
| 26 |
)
|
| 27 |
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
def __init__(
|
| 30 |
self,
|
| 31 |
*,
|
| 32 |
-
primary_hue: colors.Color | str = colors.
|
| 33 |
-
secondary_hue: colors.Color | str = colors.
|
| 34 |
-
neutral_hue: colors.Color | str = colors.
|
| 35 |
-
text_size: sizes.Size | str = sizes.
|
| 36 |
font: fonts.Font | str | Iterable[fonts.Font | str] = (
|
| 37 |
-
|
| 38 |
),
|
| 39 |
font_mono: fonts.Font | str | Iterable[fonts.Font | str] = (
|
| 40 |
-
|
| 41 |
),
|
| 42 |
):
|
| 43 |
super().__init__(
|
|
@@ -49,34 +69,60 @@ class OrangeRedTheme(Soft):
|
|
| 49 |
font_mono=font_mono,
|
| 50 |
)
|
| 51 |
super().set(
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
button_primary_text_color="white",
|
| 57 |
button_primary_text_color_hover="white",
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
color_accent_soft="
|
| 76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
)
|
| 78 |
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 82 |
|
|
@@ -109,6 +155,9 @@ except Exception as e:
|
|
| 109 |
|
| 110 |
MAX_SEED = np.iinfo(np.int32).max
|
| 111 |
|
|
|
|
|
|
|
|
|
|
| 112 |
def update_dimensions_on_upload(image):
|
| 113 |
if image is None:
|
| 114 |
return 1024, 1024
|
|
@@ -129,6 +178,7 @@ def update_dimensions_on_upload(image):
|
|
| 129 |
|
| 130 |
return new_width, new_height
|
| 131 |
|
|
|
|
| 132 |
@spaces.GPU
|
| 133 |
def infer(
|
| 134 |
images,
|
|
@@ -195,6 +245,7 @@ def infer(
|
|
| 195 |
gc.collect()
|
| 196 |
torch.cuda.empty_cache()
|
| 197 |
|
|
|
|
| 198 |
@spaces.GPU
|
| 199 |
def infer_example(images, prompt):
|
| 200 |
if not images:
|
|
@@ -215,18 +266,284 @@ def infer_example(images, prompt):
|
|
| 215 |
)
|
| 216 |
return result, seed
|
| 217 |
|
|
|
|
|
|
|
|
|
|
| 218 |
css = """
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 219 |
#col-container {
|
| 220 |
margin: 0 auto;
|
| 221 |
max-width: 1000px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 222 |
}
|
| 223 |
-
#main-title h1 {font-size: 2.4em !important;}
|
| 224 |
"""
|
| 225 |
|
| 226 |
-
|
|
|
|
|
|
|
| 227 |
with gr.Column(elem_id="col-container"):
|
| 228 |
gr.Markdown("# **FireRed-Image-Edit-1.0-Fast**", elem_id="main-title")
|
| 229 |
-
gr.Markdown(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 230 |
|
| 231 |
with gr.Row(equal_height=True):
|
| 232 |
with gr.Column():
|
|
@@ -248,13 +565,29 @@ with gr.Blocks() as demo:
|
|
| 248 |
run_button = gr.Button("Edit Image", variant="primary")
|
| 249 |
|
| 250 |
with gr.Column():
|
| 251 |
-
output_image = gr.Image(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
|
| 253 |
with gr.Accordion("Advanced Settings", open=False, visible=False):
|
| 254 |
-
seed = gr.Slider(
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 258 |
|
| 259 |
run_button.click(
|
| 260 |
fn=infer,
|
|
@@ -263,4 +596,8 @@ with gr.Blocks() as demo:
|
|
| 263 |
)
|
| 264 |
|
| 265 |
if __name__ == "__main__":
|
| 266 |
-
demo.queue(max_size=30).launch(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
import random
|
| 8 |
from PIL import Image
|
| 9 |
from typing import Iterable
|
| 10 |
+
from gradio.themes import Base
|
| 11 |
from gradio.themes.utils import colors, fonts, sizes
|
| 12 |
|
| 13 |
+
# ββ Windows 98 Color Palettes βββββββββββββββββββββββββββββββββββββββββββ
|
| 14 |
+
|
| 15 |
+
colors.win98_blue = colors.Color(
|
| 16 |
+
name="win98_blue",
|
| 17 |
+
c50="#E6E6F5",
|
| 18 |
+
c100="#CCCCEB",
|
| 19 |
+
c200="#9999D6",
|
| 20 |
+
c300="#6666C2",
|
| 21 |
+
c400="#3333AD",
|
| 22 |
+
c500="#000080",
|
| 23 |
+
c600="#000073",
|
| 24 |
+
c700="#000066",
|
| 25 |
+
c800="#000059",
|
| 26 |
+
c900="#00004D",
|
| 27 |
+
c950="#000040",
|
| 28 |
)
|
| 29 |
|
| 30 |
+
colors.win98_gray = colors.Color(
|
| 31 |
+
name="win98_gray",
|
| 32 |
+
c50="#F5F5F5",
|
| 33 |
+
c100="#EBEBEB",
|
| 34 |
+
c200="#D6D6D6",
|
| 35 |
+
c300="#C0C0C0",
|
| 36 |
+
c400="#A8A8A8",
|
| 37 |
+
c500="#808080",
|
| 38 |
+
c600="#696969",
|
| 39 |
+
c700="#555555",
|
| 40 |
+
c800="#404040",
|
| 41 |
+
c900="#2D2D2D",
|
| 42 |
+
c950="#1A1A1A",
|
| 43 |
+
)
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
# ββ Windows 98 Theme ββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 47 |
+
|
| 48 |
+
class Windows98Theme(Base):
|
| 49 |
def __init__(
|
| 50 |
self,
|
| 51 |
*,
|
| 52 |
+
primary_hue: colors.Color | str = colors.win98_gray,
|
| 53 |
+
secondary_hue: colors.Color | str = colors.win98_blue,
|
| 54 |
+
neutral_hue: colors.Color | str = colors.win98_gray,
|
| 55 |
+
text_size: sizes.Size | str = sizes.text_md,
|
| 56 |
font: fonts.Font | str | Iterable[fonts.Font | str] = (
|
| 57 |
+
"Tahoma", "MS Sans Serif", "Arial", "sans-serif",
|
| 58 |
),
|
| 59 |
font_mono: fonts.Font | str | Iterable[fonts.Font | str] = (
|
| 60 |
+
"Courier New", "Fixedsys", "monospace",
|
| 61 |
),
|
| 62 |
):
|
| 63 |
super().__init__(
|
|
|
|
| 69 |
font_mono=font_mono,
|
| 70 |
)
|
| 71 |
super().set(
|
| 72 |
+
# ββ Body ββ
|
| 73 |
+
body_background_fill="#c0c0c0",
|
| 74 |
+
body_background_fill_dark="#c0c0c0",
|
| 75 |
+
background_fill_primary="#c0c0c0",
|
| 76 |
+
background_fill_primary_dark="#c0c0c0",
|
| 77 |
+
background_fill_secondary="#d4d0c8",
|
| 78 |
+
background_fill_secondary_dark="#d4d0c8",
|
| 79 |
+
|
| 80 |
+
# ββ Blocks ββ
|
| 81 |
+
block_background_fill="#c0c0c0",
|
| 82 |
+
block_border_width="2px",
|
| 83 |
+
block_shadow="none",
|
| 84 |
+
block_title_text_weight="bold",
|
| 85 |
+
block_label_background_fill="#c0c0c0",
|
| 86 |
+
|
| 87 |
+
# ββ Primary Button (Navy Blue) ββ
|
| 88 |
+
button_primary_background_fill="#000080",
|
| 89 |
+
button_primary_background_fill_hover="#0000a0",
|
| 90 |
+
button_primary_background_fill_dark="#000080",
|
| 91 |
+
button_primary_background_fill_hover_dark="#0000a0",
|
| 92 |
button_primary_text_color="white",
|
| 93 |
button_primary_text_color_hover="white",
|
| 94 |
+
button_primary_shadow="none",
|
| 95 |
+
|
| 96 |
+
# ββ Secondary Button (Gray) ββ
|
| 97 |
+
button_secondary_background_fill="#c0c0c0",
|
| 98 |
+
button_secondary_background_fill_hover="#d4d0c8",
|
| 99 |
+
button_secondary_background_fill_dark="#c0c0c0",
|
| 100 |
+
button_secondary_background_fill_hover_dark="#d4d0c8",
|
| 101 |
+
button_secondary_text_color="#000000",
|
| 102 |
+
button_secondary_text_color_hover="#000000",
|
| 103 |
+
|
| 104 |
+
button_large_padding="6px 16px",
|
| 105 |
+
|
| 106 |
+
# ββ Slider ββ
|
| 107 |
+
slider_color="#000080",
|
| 108 |
+
slider_color_dark="#000080",
|
| 109 |
+
|
| 110 |
+
# ββ Accent ββ
|
| 111 |
+
color_accent_soft="#d4d0c8",
|
| 112 |
+
|
| 113 |
+
# ββ Input ββ
|
| 114 |
+
input_background_fill="#ffffff",
|
| 115 |
+
input_background_fill_dark="#ffffff",
|
| 116 |
+
|
| 117 |
+
# ββ Text ββ
|
| 118 |
+
body_text_color="#000000",
|
| 119 |
+
body_text_color_dark="#000000",
|
| 120 |
)
|
| 121 |
|
| 122 |
+
|
| 123 |
+
windows_98_theme = Windows98Theme()
|
| 124 |
+
|
| 125 |
+
# ββ Device & Model Setup ββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 126 |
|
| 127 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 128 |
|
|
|
|
| 155 |
|
| 156 |
MAX_SEED = np.iinfo(np.int32).max
|
| 157 |
|
| 158 |
+
|
| 159 |
+
# ββ Helper Functions ββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 160 |
+
|
| 161 |
def update_dimensions_on_upload(image):
|
| 162 |
if image is None:
|
| 163 |
return 1024, 1024
|
|
|
|
| 178 |
|
| 179 |
return new_width, new_height
|
| 180 |
|
| 181 |
+
|
| 182 |
@spaces.GPU
|
| 183 |
def infer(
|
| 184 |
images,
|
|
|
|
| 245 |
gc.collect()
|
| 246 |
torch.cuda.empty_cache()
|
| 247 |
|
| 248 |
+
|
| 249 |
@spaces.GPU
|
| 250 |
def infer_example(images, prompt):
|
| 251 |
if not images:
|
|
|
|
| 266 |
)
|
| 267 |
return result, seed
|
| 268 |
|
| 269 |
+
|
| 270 |
+
# ββ CSS ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 271 |
+
|
| 272 |
css = """
|
| 273 |
+
/* βββββββββββββββββββββββββββββββββββββββββββββββ
|
| 274 |
+
WINDOWS 98 RETRO THEME
|
| 275 |
+
βββββββββββββββββββββββββββββββββββββββββββββββ */
|
| 276 |
+
|
| 277 |
+
/* ββ Global Reset ββ */
|
| 278 |
+
*, *::before, *::after {
|
| 279 |
+
border-radius: 0px !important;
|
| 280 |
+
}
|
| 281 |
+
|
| 282 |
+
.gradio-container {
|
| 283 |
+
background: #c0c0c0 !important;
|
| 284 |
+
}
|
| 285 |
+
|
| 286 |
+
/* ββ Window Frame ββ */
|
| 287 |
#col-container {
|
| 288 |
margin: 0 auto;
|
| 289 |
max-width: 1000px;
|
| 290 |
+
background: #c0c0c0;
|
| 291 |
+
border-top: 2px solid #ffffff;
|
| 292 |
+
border-left: 2px solid #ffffff;
|
| 293 |
+
border-right: 2px solid #404040;
|
| 294 |
+
border-bottom: 2px solid #404040;
|
| 295 |
+
box-shadow: 1px 1px 0 0 #000000;
|
| 296 |
+
padding: 2px;
|
| 297 |
+
}
|
| 298 |
+
|
| 299 |
+
/* ββ Title Bar ββ */
|
| 300 |
+
#main-title {
|
| 301 |
+
background: linear-gradient(90deg, #000080, #1084d0) !important;
|
| 302 |
+
padding: 3px 8px !important;
|
| 303 |
+
margin: 0 !important;
|
| 304 |
+
border: none !important;
|
| 305 |
+
box-shadow: none !important;
|
| 306 |
+
position: relative;
|
| 307 |
+
}
|
| 308 |
+
|
| 309 |
+
#main-title h1 {
|
| 310 |
+
font-size: 13px !important;
|
| 311 |
+
color: white !important;
|
| 312 |
+
font-weight: bold !important;
|
| 313 |
+
margin: 0 !important;
|
| 314 |
+
padding: 1px 0 !important;
|
| 315 |
+
text-shadow: 1px 1px 0px rgba(0,0,0,0.5);
|
| 316 |
+
font-family: "Tahoma", "MS Sans Serif", sans-serif !important;
|
| 317 |
+
}
|
| 318 |
+
|
| 319 |
+
/* Faux Window Controls */
|
| 320 |
+
#main-title::after {
|
| 321 |
+
content: "β β‘ β";
|
| 322 |
+
position: absolute;
|
| 323 |
+
right: 4px;
|
| 324 |
+
top: 3px;
|
| 325 |
+
color: #000000;
|
| 326 |
+
font-size: 9px;
|
| 327 |
+
letter-spacing: 2px;
|
| 328 |
+
background: #c0c0c0;
|
| 329 |
+
border-top: 2px solid #ffffff;
|
| 330 |
+
border-left: 2px solid #ffffff;
|
| 331 |
+
border-right: 2px solid #808080;
|
| 332 |
+
border-bottom: 2px solid #808080;
|
| 333 |
+
padding: 0 5px;
|
| 334 |
+
font-family: "Tahoma", sans-serif;
|
| 335 |
+
line-height: 15px;
|
| 336 |
+
}
|
| 337 |
+
|
| 338 |
+
/* ββ Description / Menu Bar ββ */
|
| 339 |
+
#desc-text {
|
| 340 |
+
background: #c0c0c0 !important;
|
| 341 |
+
border: none !important;
|
| 342 |
+
border-bottom: 1px solid #808080 !important;
|
| 343 |
+
padding: 4px 6px !important;
|
| 344 |
+
margin: 0 0 4px 0 !important;
|
| 345 |
+
box-shadow: none !important;
|
| 346 |
+
}
|
| 347 |
+
|
| 348 |
+
#desc-text p {
|
| 349 |
+
font-size: 11px !important;
|
| 350 |
+
margin: 2px 0 !important;
|
| 351 |
+
color: #000000 !important;
|
| 352 |
+
}
|
| 353 |
+
|
| 354 |
+
#desc-text a {
|
| 355 |
+
color: #000080 !important;
|
| 356 |
+
text-decoration: underline !important;
|
| 357 |
+
}
|
| 358 |
+
|
| 359 |
+
/* ββ Raised Panels / Blocks ββ */
|
| 360 |
+
.block, .form {
|
| 361 |
+
border-top: 2px solid #ffffff !important;
|
| 362 |
+
border-left: 2px solid #ffffff !important;
|
| 363 |
+
border-right: 2px solid #808080 !important;
|
| 364 |
+
border-bottom: 2px solid #808080 !important;
|
| 365 |
+
background: #c0c0c0 !important;
|
| 366 |
+
box-shadow: none !important;
|
| 367 |
+
}
|
| 368 |
+
|
| 369 |
+
/* ββ Sunken Text Inputs ββ */
|
| 370 |
+
textarea,
|
| 371 |
+
input[type="text"],
|
| 372 |
+
input[type="number"],
|
| 373 |
+
input[type="search"] {
|
| 374 |
+
border-top: 2px solid #808080 !important;
|
| 375 |
+
border-left: 2px solid #808080 !important;
|
| 376 |
+
border-right: 2px solid #ffffff !important;
|
| 377 |
+
border-bottom: 2px solid #ffffff !important;
|
| 378 |
+
background: #ffffff !important;
|
| 379 |
+
box-shadow: none !important;
|
| 380 |
+
font-family: "Tahoma", "MS Sans Serif", sans-serif !important;
|
| 381 |
+
outline: none !important;
|
| 382 |
+
}
|
| 383 |
+
|
| 384 |
+
textarea:focus,
|
| 385 |
+
input[type="text"]:focus,
|
| 386 |
+
input[type="number"]:focus {
|
| 387 |
+
border-top: 2px solid #808080 !important;
|
| 388 |
+
border-left: 2px solid #808080 !important;
|
| 389 |
+
border-right: 2px solid #ffffff !important;
|
| 390 |
+
border-bottom: 2px solid #ffffff !important;
|
| 391 |
+
box-shadow: none !important;
|
| 392 |
+
outline: none !important;
|
| 393 |
+
}
|
| 394 |
+
|
| 395 |
+
/* ββ Sunken Image / Gallery Frames ββ */
|
| 396 |
+
.image-frame {
|
| 397 |
+
border-top: 2px solid #808080 !important;
|
| 398 |
+
border-left: 2px solid #808080 !important;
|
| 399 |
+
border-right: 2px solid #ffffff !important;
|
| 400 |
+
border-bottom: 2px solid #ffffff !important;
|
| 401 |
+
background: #ffffff !important;
|
| 402 |
+
}
|
| 403 |
+
|
| 404 |
+
/* ββ Upload Area ββ */
|
| 405 |
+
.upload-area {
|
| 406 |
+
border-top: 2px solid #808080 !important;
|
| 407 |
+
border-left: 2px solid #808080 !important;
|
| 408 |
+
border-right: 2px solid #ffffff !important;
|
| 409 |
+
border-bottom: 2px solid #ffffff !important;
|
| 410 |
+
background: #ffffff !important;
|
| 411 |
+
}
|
| 412 |
+
|
| 413 |
+
/* ββ Buttons (Raised) ββ */
|
| 414 |
+
button {
|
| 415 |
+
border-top: 2px solid #ffffff !important;
|
| 416 |
+
border-left: 2px solid #ffffff !important;
|
| 417 |
+
border-right: 2px solid #808080 !important;
|
| 418 |
+
border-bottom: 2px solid #808080 !important;
|
| 419 |
+
box-shadow: none !important;
|
| 420 |
+
font-family: "Tahoma", "MS Sans Serif", sans-serif !important;
|
| 421 |
+
}
|
| 422 |
+
|
| 423 |
+
button:active {
|
| 424 |
+
border-top: 2px solid #808080 !important;
|
| 425 |
+
border-left: 2px solid #808080 !important;
|
| 426 |
+
border-right: 2px solid #ffffff !important;
|
| 427 |
+
border-bottom: 2px solid #ffffff !important;
|
| 428 |
+
}
|
| 429 |
+
|
| 430 |
+
/* ββ Checkbox (Sunken) ββ */
|
| 431 |
+
input[type="checkbox"] {
|
| 432 |
+
border-top: 2px solid #808080 !important;
|
| 433 |
+
border-left: 2px solid #808080 !important;
|
| 434 |
+
border-right: 2px solid #ffffff !important;
|
| 435 |
+
border-bottom: 2px solid #ffffff !important;
|
| 436 |
+
background: #ffffff !important;
|
| 437 |
+
}
|
| 438 |
+
|
| 439 |
+
/* ββ Slider ββ */
|
| 440 |
+
input[type="range"] {
|
| 441 |
+
border: none !important;
|
| 442 |
+
background: transparent !important;
|
| 443 |
+
}
|
| 444 |
+
|
| 445 |
+
/* ββ Select / Dropdown (Sunken) ββ */
|
| 446 |
+
select {
|
| 447 |
+
border-top: 2px solid #808080 !important;
|
| 448 |
+
border-left: 2px solid #808080 !important;
|
| 449 |
+
border-right: 2px solid #ffffff !important;
|
| 450 |
+
border-bottom: 2px solid #ffffff !important;
|
| 451 |
+
background: #ffffff !important;
|
| 452 |
+
}
|
| 453 |
+
|
| 454 |
+
/* ββ Accordion (Group Box) ββ */
|
| 455 |
+
.accordion {
|
| 456 |
+
border: 2px groove #c0c0c0 !important;
|
| 457 |
+
box-shadow: none !important;
|
| 458 |
+
}
|
| 459 |
+
|
| 460 |
+
/* ββ Labels ββ */
|
| 461 |
+
.block-label, .label-wrap {
|
| 462 |
+
background: #c0c0c0 !important;
|
| 463 |
+
}
|
| 464 |
+
|
| 465 |
+
/* ββ Tab Nav (if present) ββ */
|
| 466 |
+
.tab-nav button {
|
| 467 |
+
border-top: 2px solid #ffffff !important;
|
| 468 |
+
border-left: 2px solid #ffffff !important;
|
| 469 |
+
border-right: 2px solid #808080 !important;
|
| 470 |
+
border-bottom: none !important;
|
| 471 |
+
background: #c0c0c0 !important;
|
| 472 |
+
margin-right: 1px !important;
|
| 473 |
+
}
|
| 474 |
+
|
| 475 |
+
.tab-nav button.selected {
|
| 476 |
+
border-bottom: 2px solid #c0c0c0 !important;
|
| 477 |
+
position: relative;
|
| 478 |
+
z-index: 2;
|
| 479 |
+
}
|
| 480 |
+
|
| 481 |
+
/* ββ Scrollbars (Classic Win98) ββ */
|
| 482 |
+
::-webkit-scrollbar {
|
| 483 |
+
width: 16px;
|
| 484 |
+
height: 16px;
|
| 485 |
+
}
|
| 486 |
+
|
| 487 |
+
::-webkit-scrollbar-track {
|
| 488 |
+
background: #c0c0c0;
|
| 489 |
+
}
|
| 490 |
+
|
| 491 |
+
::-webkit-scrollbar-thumb {
|
| 492 |
+
background: #c0c0c0;
|
| 493 |
+
border-top: 2px solid #ffffff;
|
| 494 |
+
border-left: 2px solid #ffffff;
|
| 495 |
+
border-right: 2px solid #808080;
|
| 496 |
+
border-bottom: 2px solid #808080;
|
| 497 |
+
}
|
| 498 |
+
|
| 499 |
+
::-webkit-scrollbar-button {
|
| 500 |
+
display: block;
|
| 501 |
+
height: 16px;
|
| 502 |
+
width: 16px;
|
| 503 |
+
background: #c0c0c0;
|
| 504 |
+
border-top: 2px solid #ffffff;
|
| 505 |
+
border-left: 2px solid #ffffff;
|
| 506 |
+
border-right: 2px solid #808080;
|
| 507 |
+
border-bottom: 2px solid #808080;
|
| 508 |
+
}
|
| 509 |
+
|
| 510 |
+
::-webkit-scrollbar-corner {
|
| 511 |
+
background: #c0c0c0;
|
| 512 |
+
}
|
| 513 |
+
|
| 514 |
+
/* ββ Progress Bar ββ */
|
| 515 |
+
.progress-bar {
|
| 516 |
+
background: #000080 !important;
|
| 517 |
+
}
|
| 518 |
+
|
| 519 |
+
/* ββ Toast / Error Dialogs ββ */
|
| 520 |
+
.toast-wrap, .toast-body {
|
| 521 |
+
border-top: 2px solid #ffffff !important;
|
| 522 |
+
border-left: 2px solid #ffffff !important;
|
| 523 |
+
border-right: 2px solid #808080 !important;
|
| 524 |
+
border-bottom: 2px solid #808080 !important;
|
| 525 |
+
background: #c0c0c0 !important;
|
| 526 |
+
color: #000000 !important;
|
| 527 |
+
}
|
| 528 |
+
|
| 529 |
+
/* ββ Footer ββ */
|
| 530 |
+
footer {
|
| 531 |
+
border-top: 1px solid #808080 !important;
|
| 532 |
+
background: #c0c0c0 !important;
|
| 533 |
}
|
|
|
|
| 534 |
"""
|
| 535 |
|
| 536 |
+
# ββ Gradio Interface βββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 537 |
+
|
| 538 |
+
with gr.Blocks(css=css, theme=windows_98_theme) as demo:
|
| 539 |
with gr.Column(elem_id="col-container"):
|
| 540 |
gr.Markdown("# **FireRed-Image-Edit-1.0-Fast**", elem_id="main-title")
|
| 541 |
+
gr.Markdown(
|
| 542 |
+
"Perform image edits using "
|
| 543 |
+
"[FireRed-Image-Edit-1.0](https://huggingface.co/FireRedTeam/FireRed-Image-Edit-1.0) "
|
| 544 |
+
"with 4-step fast inference.",
|
| 545 |
+
elem_id="desc-text"
|
| 546 |
+
)
|
| 547 |
|
| 548 |
with gr.Row(equal_height=True):
|
| 549 |
with gr.Column():
|
|
|
|
| 565 |
run_button = gr.Button("Edit Image", variant="primary")
|
| 566 |
|
| 567 |
with gr.Column():
|
| 568 |
+
output_image = gr.Image(
|
| 569 |
+
label="Output Image",
|
| 570 |
+
interactive=False,
|
| 571 |
+
format="png",
|
| 572 |
+
height=395
|
| 573 |
+
)
|
| 574 |
|
| 575 |
with gr.Accordion("Advanced Settings", open=False, visible=False):
|
| 576 |
+
seed = gr.Slider(
|
| 577 |
+
label="Seed", minimum=0,
|
| 578 |
+
maximum=MAX_SEED, step=1, value=0
|
| 579 |
+
)
|
| 580 |
+
randomize_seed = gr.Checkbox(
|
| 581 |
+
label="Randomize Seed", value=True
|
| 582 |
+
)
|
| 583 |
+
guidance_scale = gr.Slider(
|
| 584 |
+
label="Guidance Scale", minimum=1.0,
|
| 585 |
+
maximum=10.0, step=0.1, value=1.0
|
| 586 |
+
)
|
| 587 |
+
steps = gr.Slider(
|
| 588 |
+
label="Inference Steps", minimum=1,
|
| 589 |
+
maximum=50, step=1, value=4
|
| 590 |
+
)
|
| 591 |
|
| 592 |
run_button.click(
|
| 593 |
fn=infer,
|
|
|
|
| 596 |
)
|
| 597 |
|
| 598 |
if __name__ == "__main__":
|
| 599 |
+
demo.queue(max_size=30).launch(
|
| 600 |
+
mcp_server=True,
|
| 601 |
+
ssr_mode=False,
|
| 602 |
+
show_error=True
|
| 603 |
+
)
|