DraconicDragon commited on
Commit
7d4c327
·
verified ·
1 Parent(s): f4a4f4b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -14
app.py CHANGED
@@ -2,7 +2,7 @@ import io
2
  import os
3
  import tempfile
4
  import uuid
5
- import base64 # <-- NEW IMPORT
6
  from typing import List, Tuple
7
  import requests
8
  from PIL import Image, UnidentifiedImageError
@@ -268,26 +268,30 @@ def run_classify(
268
  # Build the Gradio UI with CSS tweaks
269
  css = """
270
  /* clamp the left upload image preview to 40vh */
 
 
 
 
 
 
 
271
  #left_input_image img,
272
- #left_input_image canvas,
273
- .gradio-image img,
274
- .gradio-image canvas,
275
- .image-preview img,
276
- .image-preview canvas {
277
  max-height: 40vh !important;
 
278
  width: auto !important;
279
  object-fit: contain !important;
280
  display: block !important;
281
  margin: 0 auto !important;
282
  }
283
- /* reduce default strong outlines - table border is off-white at 60% opacity */
 
284
  #results_table_container table th {
285
  border-color: rgba(255,255,255,0.6) !important;
286
  }
287
  #results_table_container table td {
288
  border-color: rgba(255,255,255,0.06) !important;
289
  }
290
- /* make sure images in the table don't get outlines */
291
  #results_table_container img {
292
  outline: none !important;
293
  border: none !important;
@@ -297,17 +301,19 @@ css = """
297
  """
298
 
299
  with gr.Blocks(title="Aesthetic Shadow - Anime Image Quality Classifier (CPU)", css=css) as demo:
 
 
300
  with gr.Row():
301
- with gr.Column(scale=2):
302
  gr.Markdown("### Input")
303
  with gr.Tabs():
304
  with gr.TabItem("Single"):
305
  uploaded_image = gr.Image(label="Drop or click to upload", type="filepath", elem_id="left_input_image")
306
  url_input = gr.Textbox(label="Image URL (optional)", placeholder="https://...", lines=1)
307
- gr.Markdown("- The preview will appear immediately and is clamped to 40% of the browser height.")
308
- with gr.TabItem("Batch"):
309
- batch_files = gr.File(label="Upload multiple images (batch)", file_count="multiple", type="filepath")
310
- batch_urls_text = gr.Textbox(label="Batch URLs (one per line)", placeholder="https://...", lines=4)
311
 
312
  with gr.Column(scale=1):
313
  gr.Markdown("### Model & Run")
@@ -330,7 +336,6 @@ with gr.Blocks(title="Aesthetic Shadow - Anime Image Quality Classifier (CPU)",
330
  outputs=[result_table_html],
331
  )
332
 
333
- gr.Markdown("All Aesthetic Shadow models are by shadowlilac. V2 is using reuploads by other people.")
334
 
335
  if __name__ == "__main__":
336
  demo.launch()
 
2
  import os
3
  import tempfile
4
  import uuid
5
+ import base64
6
  from typing import List, Tuple
7
  import requests
8
  from PIL import Image, UnidentifiedImageError
 
268
  # Build the Gradio UI with CSS tweaks
269
  css = """
270
  /* clamp the left upload image preview to 40vh */
271
+ /* make left column scroll if content would grow too tall, and limit to viewport */
272
+ #left_column {
273
+ max-height: 90vh; /* entire column won't exceed viewport*/
274
+ overflow: auto;
275
+ }
276
+
277
+ /* clamp the upload preview to 40% of the viewport height */
278
  #left_input_image img,
279
+ #left_input_image canvas {
 
 
 
 
280
  max-height: 40vh !important;
281
+ height: auto !important;
282
  width: auto !important;
283
  object-fit: contain !important;
284
  display: block !important;
285
  margin: 0 auto !important;
286
  }
287
+
288
+ /* results table tweaks kept from before */
289
  #results_table_container table th {
290
  border-color: rgba(255,255,255,0.6) !important;
291
  }
292
  #results_table_container table td {
293
  border-color: rgba(255,255,255,0.06) !important;
294
  }
 
295
  #results_table_container img {
296
  outline: none !important;
297
  border: none !important;
 
301
  """
302
 
303
  with gr.Blocks(title="Aesthetic Shadow - Anime Image Quality Classifier (CPU)", css=css) as demo:
304
+ gr.Markdown("Aesthetic Shadow - Anime Image Quality Classifier (running on CPU | ETA for single image: ~50s (fp16 & fp32 are likely same speed on cpu))")
305
+ gr.Markdown("All Aesthetic Shadow models are by shadowlilac. V2 is using reuploads by other people.")
306
  with gr.Row():
307
+ with gr.Column(scale=2, elem_id="left_column"):
308
  gr.Markdown("### Input")
309
  with gr.Tabs():
310
  with gr.TabItem("Single"):
311
  uploaded_image = gr.Image(label="Drop or click to upload", type="filepath", elem_id="left_input_image")
312
  url_input = gr.Textbox(label="Image URL (optional)", placeholder="https://...", lines=1)
313
+ # commented in because it takes reaaaaally long and there is a bug i think where it will take images from both tabs instead of just the active one
314
+ #with gr.TabItem("Batch"):
315
+ # batch_files = gr.File(label="Upload multiple images (batch)", file_count="multiple", type="filepath")
316
+ # batch_urls_text = gr.Textbox(label="Batch URLs (one per line)", placeholder="https://...", lines=4)
317
 
318
  with gr.Column(scale=1):
319
  gr.Markdown("### Model & Run")
 
336
  outputs=[result_table_html],
337
  )
338
 
 
339
 
340
  if __name__ == "__main__":
341
  demo.launch()