Update app.py
Browse files
app.py
CHANGED
@@ -43,11 +43,11 @@ def get_css(bg_color, width, height):
|
|
43 |
.gradio-container {{
|
44 |
background-color: {bg_color} !important;
|
45 |
border: none !important;
|
46 |
-
width: {width} !important; /* Set the width */
|
47 |
-
height: {height} !important; /* Set the height */
|
48 |
max-width: 100%; /* Ensure it does not exceed the container's width */
|
49 |
max-height: 100%; /* Ensure it does not exceed the container's height */
|
50 |
-
overflow:
|
51 |
}}
|
52 |
footer {{display: none !important;}} /* Hide footer */
|
53 |
"""
|
@@ -55,24 +55,32 @@ def get_css(bg_color, width, height):
|
|
55 |
def update_status(img):
|
56 |
return inference(img), gr.update(value="Processing complete!")
|
57 |
|
58 |
-
def create_interface(
|
59 |
-
|
60 |
-
bg_color =
|
61 |
-
width =
|
62 |
-
height =
|
63 |
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
|
|
|
|
71 |
|
72 |
-
|
|
|
|
|
|
|
73 |
|
74 |
return demo
|
75 |
|
76 |
-
demo =
|
|
|
|
|
|
|
77 |
|
78 |
demo.launch()
|
|
|
43 |
.gradio-container {{
|
44 |
background-color: {bg_color} !important;
|
45 |
border: none !important;
|
46 |
+
width: {width}px !important; /* Set the width */
|
47 |
+
height: {height}px !important; /* Set the height */
|
48 |
max-width: 100%; /* Ensure it does not exceed the container's width */
|
49 |
max-height: 100%; /* Ensure it does not exceed the container's height */
|
50 |
+
overflow: hidden; /* Prevent internal scrolling */
|
51 |
}}
|
52 |
footer {{display: none !important;}} /* Hide footer */
|
53 |
"""
|
|
|
55 |
def update_status(img):
|
56 |
return inference(img), gr.update(value="Processing complete!")
|
57 |
|
58 |
+
def create_interface():
|
59 |
+
# Default values
|
60 |
+
bg_color = 'rgb(17, 24, 39)'
|
61 |
+
width = 'auto'
|
62 |
+
height = '100%'
|
63 |
|
64 |
+
# Function to update the interface based on the URL parameters
|
65 |
+
def update_interface(request: gr.Request):
|
66 |
+
nonlocal bg_color, width, height
|
67 |
+
query_params = parse_qs(urlparse(request.url).query)
|
68 |
+
bg_color = query_params.get('bg_color', [bg_color])[0]
|
69 |
+
width = int(query_params.get('width', [width])[0])
|
70 |
+
height = int(query_params.get('height', [height])[0])
|
71 |
+
css = get_css(bg_color, width, height)
|
72 |
+
return gr.Blocks(css=css)
|
73 |
|
74 |
+
with gr.Blocks() as demo:
|
75 |
+
gr.Markdown("Loading...") # Temporary placeholder
|
76 |
+
|
77 |
+
demo.load(update_interface)
|
78 |
|
79 |
return demo
|
80 |
|
81 |
+
demo = create_interface()
|
82 |
+
|
83 |
+
with gr.Blocks() as outer_demo:
|
84 |
+
outer_demo.mount(demo)
|
85 |
|
86 |
demo.launch()
|