stzhao commited on
Commit
5e354c7
·
verified ·
1 Parent(s): 87d69ef

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -67,11 +67,11 @@ def render_annotations(annotations, image_dir):
67
  # Gradio interface function
68
  def gradio_interface():
69
  example_dir = "examples"
70
- random_index = random.choice([i for i in range(len(os.listdir(example_dir)))])
71
  selected_example_dir_path = os.path.join(example_dir, str(random_index))
72
  # annotations_file = random.choice([f for f in os.listdir(example_dir) if f.endswith('.json')])
73
- annotations_file = os.path.join(selected_example_dir_path, "reading_annotation.json")
74
- annotations = load_annotations(os.path.join(example_dir, annotations_file))
75
  annotated_images = render_annotations(annotations, example_dir)
76
  return [gr.Image(value=image[0], label=image[1]) for image in annotated_images]
77
 
 
67
  # Gradio interface function
68
  def gradio_interface():
69
  example_dir = "examples"
70
+ random_index = random.choice([i+1 for i in range(len(os.listdir(example_dir)))])
71
  selected_example_dir_path = os.path.join(example_dir, str(random_index))
72
  # annotations_file = random.choice([f for f in os.listdir(example_dir) if f.endswith('.json')])
73
+ annotations_file_path = os.path.join(selected_example_dir_path, "reading_annotation.json")
74
+ annotations = load_annotations(annotations_file_path)
75
  annotated_images = render_annotations(annotations, example_dir)
76
  return [gr.Image(value=image[0], label=image[1]) for image in annotated_images]
77