Spaces:
Runtime error
Runtime error
update app
Browse files
app.py
CHANGED
|
@@ -13,78 +13,7 @@ import zipfile
|
|
| 13 |
from transformers import CLIPTextModel, CLIPTokenizer, T5EncoderModel, T5TokenizerFast
|
| 14 |
|
| 15 |
from typing import Iterable
|
| 16 |
-
from gradio.themes import Soft
|
| 17 |
-
from gradio.themes.utils import colors, fonts, sizes
|
| 18 |
-
|
| 19 |
-
colors.orange_red = colors.Color(
|
| 20 |
-
name="orange_red",
|
| 21 |
-
c50="#FFF0E5",
|
| 22 |
-
c100="#FFE0CC",
|
| 23 |
-
c200="#FFC299",
|
| 24 |
-
c300="#FFA366",
|
| 25 |
-
c400="#FF8533",
|
| 26 |
-
c500="#FF4500",
|
| 27 |
-
c600="#E63E00",
|
| 28 |
-
c700="#CC3700",
|
| 29 |
-
c800="#B33000",
|
| 30 |
-
c900="#992900",
|
| 31 |
-
c950="#802200",
|
| 32 |
-
)
|
| 33 |
-
|
| 34 |
-
class OrangeRedTheme(Soft):
|
| 35 |
-
def __init__(
|
| 36 |
-
self,
|
| 37 |
-
*,
|
| 38 |
-
primary_hue: colors.Color | str = colors.gray,
|
| 39 |
-
secondary_hue: colors.Color | str = colors.orange_red, # Use the new color
|
| 40 |
-
neutral_hue: colors.Color | str = colors.slate,
|
| 41 |
-
text_size: sizes.Size | str = sizes.text_lg,
|
| 42 |
-
font: fonts.Font | str | Iterable[fonts.Font | str] = (
|
| 43 |
-
fonts.GoogleFont("Outfit"), "Arial", "sans-serif",
|
| 44 |
-
),
|
| 45 |
-
font_mono: fonts.Font | str | Iterable[fonts.Font | str] = (
|
| 46 |
-
fonts.GoogleFont("IBM Plex Mono"), "ui-monospace", "monospace",
|
| 47 |
-
),
|
| 48 |
-
):
|
| 49 |
-
super().__init__(
|
| 50 |
-
primary_hue=primary_hue,
|
| 51 |
-
secondary_hue=secondary_hue,
|
| 52 |
-
neutral_hue=neutral_hue,
|
| 53 |
-
text_size=text_size,
|
| 54 |
-
font=font,
|
| 55 |
-
font_mono=font_mono,
|
| 56 |
-
)
|
| 57 |
-
super().set(
|
| 58 |
-
background_fill_primary="*primary_50",
|
| 59 |
-
background_fill_primary_dark="*primary_900",
|
| 60 |
-
body_background_fill="linear-gradient(135deg, *primary_200, *primary_100)",
|
| 61 |
-
body_background_fill_dark="linear-gradient(135deg, *primary_900, *primary_800)",
|
| 62 |
-
button_primary_text_color="white",
|
| 63 |
-
button_primary_text_color_hover="white",
|
| 64 |
-
button_primary_background_fill="linear-gradient(90deg, *secondary_500, *secondary_600)",
|
| 65 |
-
button_primary_background_fill_hover="linear-gradient(90deg, *secondary_600, *secondary_700)",
|
| 66 |
-
button_primary_background_fill_dark="linear-gradient(90deg, *secondary_600, *secondary_700)",
|
| 67 |
-
button_primary_background_fill_hover_dark="linear-gradient(90deg, *secondary_500, *secondary_600)",
|
| 68 |
-
button_secondary_text_color="black",
|
| 69 |
-
button_secondary_text_color_hover="white",
|
| 70 |
-
button_secondary_background_fill="linear-gradient(90deg, *primary_300, *primary_300)",
|
| 71 |
-
button_secondary_background_fill_hover="linear-gradient(90deg, *primary_400, *primary_400)",
|
| 72 |
-
button_secondary_background_fill_dark="linear-gradient(90deg, *primary_500, *primary_600)",
|
| 73 |
-
button_secondary_background_fill_hover_dark="linear-gradient(90deg, *primary_500, *primary_500)",
|
| 74 |
-
slider_color="*secondary_500",
|
| 75 |
-
slider_color_dark="*secondary_600",
|
| 76 |
-
block_title_text_weight="600",
|
| 77 |
-
block_border_width="3px",
|
| 78 |
-
block_shadow="*shadow_drop_lg",
|
| 79 |
-
button_primary_shadow="*shadow_drop_lg",
|
| 80 |
-
button_large_padding="11px",
|
| 81 |
-
color_accent_soft="*primary_100",
|
| 82 |
-
block_label_background_fill="*primary_200",
|
| 83 |
-
)
|
| 84 |
-
|
| 85 |
-
orange_red_theme = OrangeRedTheme()
|
| 86 |
|
| 87 |
-
# ---- CUDA Check ----
|
| 88 |
print("CUDA_VISIBLE_DEVICES=", os.environ.get("CUDA_VISIBLE_DEVICES"))
|
| 89 |
print("torch.__version__ =", torch.__version__)
|
| 90 |
print("torch.version.cuda =", torch.version.cuda)
|
|
@@ -474,12 +403,7 @@ css = '''
|
|
| 474 |
margin: 0 auto !important;
|
| 475 |
}
|
| 476 |
#main-title h1 { font-size: 2.3em !important; }
|
| 477 |
-
|
| 478 |
-
text-align: center;
|
| 479 |
-
}
|
| 480 |
-
footer {
|
| 481 |
-
visibility: hidden;
|
| 482 |
-
}
|
| 483 |
'''
|
| 484 |
|
| 485 |
# Gradio interface
|
|
@@ -609,4 +533,8 @@ with gr.Blocks() as demo:
|
|
| 609 |
)
|
| 610 |
|
| 611 |
if __name__ == "__main__":
|
| 612 |
-
demo.queue(max_size=30).launch(css=css, theme=
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
from transformers import CLIPTextModel, CLIPTokenizer, T5EncoderModel, T5TokenizerFast
|
| 14 |
|
| 15 |
from typing import Iterable
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
|
|
|
| 17 |
print("CUDA_VISIBLE_DEVICES=", os.environ.get("CUDA_VISIBLE_DEVICES"))
|
| 18 |
print("torch.__version__ =", torch.__version__)
|
| 19 |
print("torch.version.cuda =", torch.version.cuda)
|
|
|
|
| 403 |
margin: 0 auto !important;
|
| 404 |
}
|
| 405 |
#main-title h1 { font-size: 2.3em !important; }
|
| 406 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 407 |
'''
|
| 408 |
|
| 409 |
# Gradio interface
|
|
|
|
| 533 |
)
|
| 534 |
|
| 535 |
if __name__ == "__main__":
|
| 536 |
+
demo.queue(max_size=30).launch(css=css, theme=gr.themes.Soft(
|
| 537 |
+
primary_hue="blue",
|
| 538 |
+
secondary_hue="indigo",
|
| 539 |
+
neutral_hue="slate",
|
| 540 |
+
), mcp_server=True, ssr_mode=False, show_error=True)
|