toilaluan commited on
Commit
f52b9ad
1 Parent(s): d1bc12b
Files changed (2) hide show
  1. app.py +6 -3
  2. scorer.py +1 -1
app.py CHANGED
@@ -51,10 +51,13 @@ def process_image(image, prompt):
51
  questions, _ = processor.generate_questions(
52
  prompt, tuples.tuples, dependencies
53
  )
54
- reward = processor.get_reward(questions, dependencies, [image])
55
  reward = reward[0]
 
56
  answers = {str(i): v > 0.5 for i, v in enumerate(reward)}
57
- graph_img = draw_colored_graph(dependencies, questions, answers)
 
 
58
  return graph_img, f"""
59
  Question: {questions}.
60
  Reward per question: {reward}"""
@@ -84,7 +87,7 @@ interface = gr.Interface(
84
  theme=gr.themes.Soft(),
85
  description=description,
86
  examples = [
87
- ["examples/input_image.png", "a cat with red eyes in the jungle"],
88
  ],
89
  css=css,
90
  title="T2I Adherence Scorer based on Davidsonian Scene Graph",
 
51
  questions, _ = processor.generate_questions(
52
  prompt, tuples.tuples, dependencies
53
  )
54
+ reward, sorted_questions = processor.get_reward(questions, dependencies, [image])
55
  reward = reward[0]
56
+ print(reward)
57
  answers = {str(i): v > 0.5 for i, v in enumerate(reward)}
58
+ sorted_questions = {str(i): v for i, v in enumerate(sorted_questions)}
59
+ print(answers, sorted_questions)
60
+ graph_img = draw_colored_graph(dependencies, sorted_questions, answers)
61
  return graph_img, f"""
62
  Question: {questions}.
63
  Reward per question: {reward}"""
 
87
  theme=gr.themes.Soft(),
88
  description=description,
89
  examples = [
90
+ ["examples/input_image.png", "A cat with red eyes in the jungle. All tree in the jungle has blue color."],
91
  ],
92
  css=css,
93
  title="T2I Adherence Scorer based on Davidsonian Scene Graph",
scorer.py CHANGED
@@ -381,7 +381,7 @@ Each tuple contains the following information:
381
  )
382
  pbar.update(1)
383
 
384
- return scores
385
 
386
 
387
  if __name__ == "__main__":
 
381
  )
382
  pbar.update(1)
383
 
384
+ return scores, sorted_questions
385
 
386
 
387
  if __name__ == "__main__":