Chris Addis commited on
Commit ·
c477cef
1
Parent(s): f3f3f51
Matcha 2
Browse files
app.py
CHANGED
|
@@ -72,7 +72,6 @@ def get_base_filename(filepath):
|
|
| 72 |
|
| 73 |
# Define the Gradio interface
|
| 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 {
|
|
@@ -84,14 +83,16 @@ def create_demo():
|
|
| 84 |
overflow: hidden; /* Hide any potential overflow from container */
|
| 85 |
}
|
| 86 |
|
| 87 |
-
/*
|
| 88 |
-
#current-image-display img
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
|
|
|
|
|
|
| 95 |
}
|
| 96 |
"""
|
| 97 |
# --- Pass css to gr.Blocks ---
|
|
@@ -150,13 +151,11 @@ def create_demo():
|
|
| 150 |
|
| 151 |
# Right column: Display area
|
| 152 |
with gr.Column(scale=2):
|
| 153 |
-
# --- Use elem_id for CSS targeting, remove unsupported object_fit ---
|
| 154 |
current_image = gr.Image(
|
| 155 |
label="Current Image",
|
| 156 |
height=600,
|
| 157 |
type="filepath",
|
| 158 |
-
|
| 159 |
-
elem_id="current-image-display", # ADDED - for CSS targeting
|
| 160 |
show_fullscreen_button=True,
|
| 161 |
show_download_button=False,
|
| 162 |
show_share_button=False,
|
|
@@ -212,10 +211,6 @@ def create_demo():
|
|
| 212 |
prompt0 = prompt_new()
|
| 213 |
model_name = model_choice
|
| 214 |
client_to_use = OR # Default client
|
| 215 |
-
# Add logic here if you need to switch between OR and gemini clients based on model_name
|
| 216 |
-
# Example:
|
| 217 |
-
# if model_name.startswith("google/gemini") and gemini:
|
| 218 |
-
# client_to_use = gemini
|
| 219 |
|
| 220 |
result = client_to_use.generate_caption(
|
| 221 |
img, model=model_name, max_image_size=512,
|
|
|
|
| 72 |
|
| 73 |
# Define the Gradio interface
|
| 74 |
def create_demo():
|
|
|
|
| 75 |
custom_css = """
|
| 76 |
/* Container for the image component (#current-image-display is the elem_id of gr.Image) */
|
| 77 |
#current-image-display {
|
|
|
|
| 83 |
overflow: hidden; /* Hide any potential overflow from container */
|
| 84 |
}
|
| 85 |
|
| 86 |
+
/* Target all possible image elements within the container */
|
| 87 |
+
#current-image-display img,
|
| 88 |
+
#current-image-display .gradio-image img,
|
| 89 |
+
#current-image-display div img,
|
| 90 |
+
#current-image-display * img {
|
| 91 |
+
object-fit: contain !important;
|
| 92 |
+
max-width: 100% !important;
|
| 93 |
+
max-height: 100% !important;
|
| 94 |
+
width: auto !important;
|
| 95 |
+
height: auto !important;
|
| 96 |
}
|
| 97 |
"""
|
| 98 |
# --- Pass css to gr.Blocks ---
|
|
|
|
| 151 |
|
| 152 |
# Right column: Display area
|
| 153 |
with gr.Column(scale=2):
|
|
|
|
| 154 |
current_image = gr.Image(
|
| 155 |
label="Current Image",
|
| 156 |
height=600,
|
| 157 |
type="filepath",
|
| 158 |
+
elem_id="current-image-display",
|
|
|
|
| 159 |
show_fullscreen_button=True,
|
| 160 |
show_download_button=False,
|
| 161 |
show_share_button=False,
|
|
|
|
| 211 |
prompt0 = prompt_new()
|
| 212 |
model_name = model_choice
|
| 213 |
client_to_use = OR # Default client
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
|
| 215 |
result = client_to_use.generate_caption(
|
| 216 |
img, model=model_name, max_image_size=512,
|