yingzhac commited on
Commit
7b692ae
·
1 Parent(s): 97b66ab

强化文字对比度修复 - 使用更强力的CSS选择器

Browse files
Files changed (1) hide show
  1. app.py +59 -24
app.py CHANGED
@@ -161,10 +161,20 @@ def get_ocr_info(input_image):
161
 
162
  # Define CSS for styling
163
  css = """
 
 
 
 
 
 
 
 
 
 
164
  #col-container {
165
  margin: 0 auto;
166
  max-width: 1000px;
167
- color: #333;
168
  }
169
 
170
  #input-section {
@@ -172,19 +182,16 @@ css = """
172
  padding: 20px;
173
  border-radius: 15px;
174
  margin-bottom: 20px;
175
- color: white;
176
  }
177
 
178
  #output-section {
179
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
180
  padding: 20px;
181
  border-radius: 15px;
182
- color: white;
183
  }
184
 
185
  .gradio-container {
186
  background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
187
- color: #333;
188
  }
189
 
190
  #title {
@@ -199,7 +206,7 @@ css = """
199
 
200
  #description {
201
  text-align: center;
202
- color: #444;
203
  font-size: 1.1em;
204
  margin-bottom: 30px;
205
  line-height: 1.6;
@@ -207,7 +214,7 @@ css = """
207
 
208
  .process-button {
209
  background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
210
- color: white;
211
  border: none;
212
  padding: 15px 30px;
213
  font-size: 16px;
@@ -221,48 +228,75 @@ css = """
221
  box-shadow: 0 5px 15px rgba(0,0,0,0.2);
222
  }
223
 
224
- /* Additional text contrast improvements */
225
- .gradio-container label {
226
- color: #333 !important;
227
- font-weight: 500;
228
  }
229
 
230
- .gradio-container .gr-form {
231
- color: #333 !important;
232
  }
233
 
234
- .gradio-container .gr-text-input {
 
 
 
 
235
  color: #333 !important;
236
  }
237
 
238
- .gradio-container .gr-button {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
239
  color: #333 !important;
 
240
  }
241
 
242
  #input-section label,
243
- #input-section .gr-form,
244
- #input-section .gr-text-input,
245
- #input-section .gr-button {
 
246
  color: white !important;
247
  }
248
 
249
  #output-section label,
250
- #output-section .gr-form,
251
- #output-section .gr-text-input,
252
- #output-section .gr-button {
 
253
  color: white !important;
254
  }
255
 
256
- /* Make sure markdown text is readable */
257
- .gradio-container .gr-markdown {
 
 
258
  color: #333 !important;
259
  }
260
 
261
- #input-section .gr-markdown {
 
 
262
  color: white !important;
263
  }
264
 
265
- #output-section .gr-markdown {
 
 
266
  color: white !important;
267
  }
268
  """
@@ -422,4 +456,5 @@ with gr.Blocks(css=css, title="智能文字缩放工具") as demo:
422
  )
423
 
424
  if __name__ == "__main__":
 
425
  demo.launch(share=True, server_name="0.0.0.0", server_port=7860)
 
161
 
162
  # Define CSS for styling
163
  css = """
164
+ /* Global text color fixes - high priority */
165
+ body, .gradio-container, .gradio-container * {
166
+ color: #333 !important;
167
+ }
168
+
169
+ /* Force all text elements to have good contrast */
170
+ p, div, span, label, input, textarea, button, h1, h2, h3, h4, h5, h6 {
171
+ color: #333 !important;
172
+ }
173
+
174
  #col-container {
175
  margin: 0 auto;
176
  max-width: 1000px;
177
+ color: #333 !important;
178
  }
179
 
180
  #input-section {
 
182
  padding: 20px;
183
  border-radius: 15px;
184
  margin-bottom: 20px;
 
185
  }
186
 
187
  #output-section {
188
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
189
  padding: 20px;
190
  border-radius: 15px;
 
191
  }
192
 
193
  .gradio-container {
194
  background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
 
195
  }
196
 
197
  #title {
 
206
 
207
  #description {
208
  text-align: center;
209
+ color: #222 !important;
210
  font-size: 1.1em;
211
  margin-bottom: 30px;
212
  line-height: 1.6;
 
214
 
215
  .process-button {
216
  background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
217
+ color: white !important;
218
  border: none;
219
  padding: 15px 30px;
220
  font-size: 16px;
 
228
  box-shadow: 0 5px 15px rgba(0,0,0,0.2);
229
  }
230
 
231
+ /* White text for dark gradient sections */
232
+ #input-section, #input-section * {
233
+ color: white !important;
 
234
  }
235
 
236
+ #output-section, #output-section * {
237
+ color: white !important;
238
  }
239
 
240
+ /* Override Gradio's default text colors */
241
+ .gradio-container .gr-markdown p,
242
+ .gradio-container .gr-markdown div,
243
+ .gradio-container .gr-markdown span,
244
+ .gradio-container .gr-markdown li {
245
  color: #333 !important;
246
  }
247
 
248
+ #input-section .gr-markdown p,
249
+ #input-section .gr-markdown div,
250
+ #input-section .gr-markdown span,
251
+ #input-section .gr-markdown li {
252
+ color: white !important;
253
+ }
254
+
255
+ #output-section .gr-markdown p,
256
+ #output-section .gr-markdown div,
257
+ #output-section .gr-markdown span,
258
+ #output-section .gr-markdown li {
259
+ color: white !important;
260
+ }
261
+
262
+ /* Force all labels and form elements to have proper contrast */
263
+ label, .gr-form label, .gr-textbox label, .gr-button, .gr-checkbox label {
264
  color: #333 !important;
265
+ font-weight: 500;
266
  }
267
 
268
  #input-section label,
269
+ #input-section .gr-form label,
270
+ #input-section .gr-textbox label,
271
+ #input-section .gr-button,
272
+ #input-section .gr-checkbox label {
273
  color: white !important;
274
  }
275
 
276
  #output-section label,
277
+ #output-section .gr-form label,
278
+ #output-section .gr-textbox label,
279
+ #output-section .gr-button,
280
+ #output-section .gr-checkbox label {
281
  color: white !important;
282
  }
283
 
284
+ /* Additional fallback for any missed text elements */
285
+ .gradio-container [class*="text"],
286
+ .gradio-container [class*="label"],
287
+ .gradio-container [class*="markdown"] {
288
  color: #333 !important;
289
  }
290
 
291
+ #input-section [class*="text"],
292
+ #input-section [class*="label"],
293
+ #input-section [class*="markdown"] {
294
  color: white !important;
295
  }
296
 
297
+ #output-section [class*="text"],
298
+ #output-section [class*="label"],
299
+ #output-section [class*="markdown"] {
300
  color: white !important;
301
  }
302
  """
 
456
  )
457
 
458
  if __name__ == "__main__":
459
+ # Fixed text contrast issues - force redeploy
460
  demo.launch(share=True, server_name="0.0.0.0", server_port=7860)