Chris Addis commited on
Commit ·
11b5f4d
1
Parent(s): a1d918e
Matcha 2
Browse files
app.py
CHANGED
|
@@ -74,18 +74,25 @@ def get_base_filename(filepath):
|
|
| 74 |
def create_demo():
|
| 75 |
# --- Reintroduce CSS ---
|
| 76 |
custom_css = """
|
| 77 |
-
/*
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
"""
|
| 90 |
# --- Pass css to gr.Blocks ---
|
| 91 |
with gr.Blocks(theme=gr.themes.Monochrome(), css=custom_css) as demo:
|
|
|
|
| 74 |
def create_demo():
|
| 75 |
# --- Reintroduce CSS ---
|
| 76 |
custom_css = """
|
| 77 |
+
/* Container for the image component (#current-image-display is the elem_id of gr.Image) */
|
| 78 |
+
#current-image-display {
|
| 79 |
+
height: 600px; /* Define container height */
|
| 80 |
+
width: 100%; /* Define container width (takes column width) */
|
| 81 |
+
display: flex; /* Use flexbox for alignment */
|
| 82 |
+
justify-content: center; /* Center content horizontally */
|
| 83 |
+
align-items: center; /* Center content vertically */
|
| 84 |
+
overflow: hidden; /* Hide any potential overflow from container */
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
/* The actual <img> element inside the container */
|
| 88 |
+
#current-image-display img {
|
| 89 |
+
object-fit: contain; /* Scale keeping aspect ratio, within bounds */
|
| 90 |
+
max-width: 100%; /* Prevent image exceeding container width */
|
| 91 |
+
max-height: 100%; /* Prevent image exceeding container height */
|
| 92 |
+
width: auto; /* Use natural width unless constrained by max-width */
|
| 93 |
+
height: auto; /* Use natural height unless constrained by max-height */
|
| 94 |
+
display: block; /* Ensure image behaves predictably in flex */
|
| 95 |
+
}
|
| 96 |
"""
|
| 97 |
# --- Pass css to gr.Blocks ---
|
| 98 |
with gr.Blocks(theme=gr.themes.Monochrome(), css=custom_css) as demo:
|