ttoosi commited on
Commit
2022ae6
·
1 Parent(s): 67f0c8b

Fix Gradio invalid path for built-in stimuli

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -608,9 +608,10 @@ def apply_example(example):
608
  mcx = example.get("mask_center_x", 0.0)
609
  mcy = example.get("mask_center_y", 0.0)
610
  mrad = example.get("mask_radius", 0.3)
611
- mask_img = draw_mask_overlay(example["image"], mcx, mcy, mrad)
 
612
  return [
613
- example["image"],
614
  rd.get("model", "resnet50_robust"),
615
  example["method"],
616
  rd["epsilon"],
@@ -662,7 +663,11 @@ with gr.Blocks(title="Human Hallucination Prediction", css="""
662
  with gr.Column(scale=1):
663
  # Inputs (track path so save filenames use stimulus name when from example)
664
  default_image_path = os.path.join("stimuli", "urbanoffice1.jpg")
665
- image_input = gr.Image(label="Input Image (click to set mask center)", type="pil", value=default_image_path)
 
 
 
 
666
  current_image_path_state = gr.State(value=default_image_path)
667
  mask_preview = gr.Image(
668
  label="Mask center preview (click to set center — circle shows mask)",
 
608
  mcx = example.get("mask_center_x", 0.0)
609
  mcy = example.get("mask_center_y", 0.0)
610
  mrad = example.get("mask_radius", 0.3)
611
+ example_image_pil = _image_to_pil(example["image"])
612
+ mask_img = draw_mask_overlay(example_image_pil, mcx, mcy, mrad)
613
  return [
614
+ example_image_pil,
615
  rd.get("model", "resnet50_robust"),
616
  example["method"],
617
  rd["epsilon"],
 
663
  with gr.Column(scale=1):
664
  # Inputs (track path so save filenames use stimulus name when from example)
665
  default_image_path = os.path.join("stimuli", "urbanoffice1.jpg")
666
+ image_input = gr.Image(
667
+ label="Input Image (click to set mask center)",
668
+ type="pil",
669
+ value=_image_to_pil(default_image_path),
670
+ )
671
  current_image_path_state = gr.State(value=default_image_path)
672
  mask_preview = gr.Image(
673
  label="Mask center preview (click to set center — circle shows mask)",