Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files- __pycache__/app.cpython-311.pyc +0 -0
- app.py +17 -25
__pycache__/app.cpython-311.pyc
CHANGED
|
Binary files a/__pycache__/app.cpython-311.pyc and b/__pycache__/app.cpython-311.pyc differ
|
|
|
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import inspect
|
| 2 |
import time
|
| 3 |
-
from typing import Iterable
|
| 4 |
|
| 5 |
from gradio_client.documentation import document_fn
|
| 6 |
|
|
@@ -50,7 +50,6 @@ def get_doc_theme_var_groups():
|
|
| 50 |
return groups, flat_variables
|
| 51 |
|
| 52 |
|
| 53 |
-
|
| 54 |
variable_groups, flat_variables = get_doc_theme_var_groups()
|
| 55 |
|
| 56 |
css = """
|
|
@@ -504,9 +503,14 @@ with gr.Blocks( # noqa: SIM117
|
|
| 504 |
+ mono_is_google
|
| 505 |
+ theme_var_input
|
| 506 |
)
|
| 507 |
-
|
| 508 |
-
|
| 509 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 510 |
if custom_theme:
|
| 511 |
theme = custom_theme
|
| 512 |
else:
|
|
@@ -521,7 +525,7 @@ with gr.Blocks( # noqa: SIM117
|
|
| 521 |
spacing_size = parameters["spacing_size"].default
|
| 522 |
radius_size = parameters["radius_size"].default
|
| 523 |
|
| 524 |
-
|
| 525 |
|
| 526 |
font = theme._font[:4]
|
| 527 |
font_mono = theme._font_mono[:4]
|
|
@@ -557,9 +561,10 @@ with gr.Blocks( # noqa: SIM117
|
|
| 557 |
)
|
| 558 |
|
| 559 |
def load_custom_theme(custom_theme_name):
|
| 560 |
-
|
| 561 |
-
|
| 562 |
-
|
|
|
|
| 563 |
return load_theme(theme.name, theme)
|
| 564 |
|
| 565 |
|
|
@@ -644,21 +649,7 @@ with gr.Blocks( # noqa: SIM117
|
|
| 644 |
if getattr(source_obj, attr) != final_attr_values[final_theme_attr]:
|
| 645 |
diff = True
|
| 646 |
if diff:
|
| 647 |
-
|
| 648 |
-
# We need to update the theme keys to match the color and size attribute names
|
| 649 |
-
for key, val in final_attr_values.items():
|
| 650 |
-
if key.startswith(("primary_", "secondary_", "neutral_")):
|
| 651 |
-
color_key = "c" + key.split("_")[-1]
|
| 652 |
-
new_final_attr_values[color_key] = val
|
| 653 |
-
elif key.startswith(("text_", "spacing_", "radius_")):
|
| 654 |
-
size_key = key.split("_")[-1]
|
| 655 |
-
new_final_attr_values[size_key] = val
|
| 656 |
-
else:
|
| 657 |
-
new_final_attr_values[key] = val
|
| 658 |
-
specific_core_diffs[value_name] = (
|
| 659 |
-
source_class,
|
| 660 |
-
new_final_attr_values,
|
| 661 |
-
)
|
| 662 |
|
| 663 |
font_diffs = {}
|
| 664 |
|
|
@@ -927,7 +918,8 @@ with gr.Blocks(theme=theme) as demo:
|
|
| 927 |
)
|
| 928 |
|
| 929 |
attach_rerender(
|
| 930 |
-
load_custom_theme_btn.click(load_custom_theme, custom_theme_name,
|
|
|
|
| 931 |
)
|
| 932 |
|
| 933 |
for theme_box in (
|
|
|
|
| 1 |
import inspect
|
| 2 |
import time
|
| 3 |
+
from typing import Iterable, Optional
|
| 4 |
|
| 5 |
from gradio_client.documentation import document_fn
|
| 6 |
|
|
|
|
| 50 |
return groups, flat_variables
|
| 51 |
|
| 52 |
|
|
|
|
| 53 |
variable_groups, flat_variables = get_doc_theme_var_groups()
|
| 54 |
|
| 55 |
css = """
|
|
|
|
| 503 |
+ mono_is_google
|
| 504 |
+ theme_var_input
|
| 505 |
)
|
| 506 |
+
def load_theme(theme_name: Optional[str], custom_theme: Optional[gr.themes.ThemeClass] = None):
|
| 507 |
+
'''
|
| 508 |
+
Load a theme based on the theme name or theme object.
|
| 509 |
+
|
| 510 |
+
Parameters:
|
| 511 |
+
theme_name (str): The name of the theme to load.
|
| 512 |
+
custom_theme (gr.themes.Base, optional): Custom theme object to load. Defaults to None if loading a default theme.
|
| 513 |
+
'''
|
| 514 |
if custom_theme:
|
| 515 |
theme = custom_theme
|
| 516 |
else:
|
|
|
|
| 525 |
spacing_size = parameters["spacing_size"].default
|
| 526 |
radius_size = parameters["radius_size"].default
|
| 527 |
|
| 528 |
+
|
| 529 |
|
| 530 |
font = theme._font[:4]
|
| 531 |
font_mono = theme._font_mono[:4]
|
|
|
|
| 561 |
)
|
| 562 |
|
| 563 |
def load_custom_theme(custom_theme_name):
|
| 564 |
+
try:
|
| 565 |
+
theme = gr.Theme.from_hub(custom_theme_name)
|
| 566 |
+
except Exception as e:
|
| 567 |
+
raise gr.Error(f"Error loading custom theme:{e}")
|
| 568 |
return load_theme(theme.name, theme)
|
| 569 |
|
| 570 |
|
|
|
|
| 649 |
if getattr(source_obj, attr) != final_attr_values[final_theme_attr]:
|
| 650 |
diff = True
|
| 651 |
if diff:
|
| 652 |
+
specific_core_diffs[value_name] = (source_class, final_attr_values)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 653 |
|
| 654 |
font_diffs = {}
|
| 655 |
|
|
|
|
| 918 |
)
|
| 919 |
|
| 920 |
attach_rerender(
|
| 921 |
+
load_custom_theme_btn.click(load_custom_theme, custom_theme_name,
|
| 922 |
+
theme_inputs, show_api=False).then
|
| 923 |
)
|
| 924 |
|
| 925 |
for theme_box in (
|