vagrillo commited on
Commit
edd1986
·
verified ·
1 Parent(s): b9a8d78

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -119,8 +119,8 @@ def resize_image_max_dimension(image, max_size=4096):
119
  width, height = image.size
120
 
121
  # Check if resizing is needed
122
- if max(width, height) <= max_size:
123
- return image
124
 
125
  # Calculate new dimensions maintaining aspect ratio
126
  ratio = max_size / max(width, height)
@@ -213,7 +213,7 @@ def load_examples_from_directory(directory="examples"):
213
  # Crea gli esempi per ogni file JPG
214
  for jpg_file in jpg_files:
215
  filepath = os.path.join(directory, jpg_file)
216
- examples.append([filepath, "stickers. labels.", 0.24, 0.23])
217
 
218
  return examples
219
 
@@ -224,7 +224,7 @@ examples = load_examples_from_directory()
224
  if not examples:
225
  print("[INFO] Usando esempio di fallback")
226
  examples = [
227
- ["examples/stickers(1).jpg", "stickers. labels.", 0.24, 0.23],
228
  ]
229
 
230
 
@@ -238,16 +238,16 @@ def cleanup_temp_files(crop_paths):
238
  pass
239
 
240
  # Create Gradio demo
241
- with gr.Blocks(title="Stikkiers", css=".gradio-container {max-width: 100% !important}") as demo:
242
- gr.Markdown("# Sticker Finder")
243
- gr.Markdown("Upload an image and adjust thresholds to see detections.")
244
 
245
  with gr.Row():
246
  with gr.Column():
247
  image_input = gr.Image(type="pil", label="Input Image")
248
  text_query = gr.Textbox(
249
- value="stickers. labels. postcards.",
250
- label="Text Query (lowercase, end each with '.', for example 'a bird. a tree.')"
251
  )
252
  box_threshold = gr.Slider(0.0, 1.0, 0.14, step=0.05, label="Box Threshold")
253
  text_threshold = gr.Slider(0.0, 1.0, 0.13, step=0.05, label="Text Threshold")
 
119
  width, height = image.size
120
 
121
  # Check if resizing is needed
122
+ # if max(width, height) <= max_size:
123
+ # return image
124
 
125
  # Calculate new dimensions maintaining aspect ratio
126
  ratio = max_size / max(width, height)
 
213
  # Crea gli esempi per ogni file JPG
214
  for jpg_file in jpg_files:
215
  filepath = os.path.join(directory, jpg_file)
216
+ examples.append([filepath, "heads.", 0.24, 0.23])
217
 
218
  return examples
219
 
 
224
  if not examples:
225
  print("[INFO] Usando esempio di fallback")
226
  examples = [
227
+ ["examples/stickers(1).jpg", "heads.", 0.24, 0.23],
228
  ]
229
 
230
 
 
238
  pass
239
 
240
  # Create Gradio demo
241
+ with gr.Blocks(title="VTLinuxDayDemo25", css=".gradio-container {max-width: 100% !important}") as demo:
242
+ gr.Markdown("# Student Finder")
243
+ gr.Markdown("Upload una foto di classe e regola le soglie.")
244
 
245
  with gr.Row():
246
  with gr.Column():
247
  image_input = gr.Image(type="pil", label="Input Image")
248
  text_query = gr.Textbox(
249
+ value="heads.",
250
+ label="Text Query (lowercase, end each with '.', for example 'heads. faces. hands.')"
251
  )
252
  box_threshold = gr.Slider(0.0, 1.0, 0.14, step=0.05, label="Box Threshold")
253
  text_threshold = gr.Slider(0.0, 1.0, 0.13, step=0.05, label="Text Threshold")