Spaces:
Runtime error
Runtime error
update
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ from scorer import DSGPromptProcessor
|
|
4 |
import matplotlib.pyplot as plt
|
5 |
import networkx as nx
|
6 |
from PIL import Image
|
7 |
-
|
8 |
|
9 |
def draw_colored_graph(dependencies, questions, answers):
|
10 |
# Create a directed graph
|
@@ -52,7 +52,7 @@ def process_image(image, prompt):
|
|
52 |
)
|
53 |
reward = processor.get_reward(questions, dependencies, [image])
|
54 |
reward = reward[0]
|
55 |
-
answers = {i: v > 0.5 for i, v in enumerate(reward)}
|
56 |
graph_img = draw_colored_graph(dependencies, questions, answers)
|
57 |
return reward, f"""
|
58 |
Question: {questions}.
|
@@ -63,7 +63,8 @@ Reward per question: {reward}"""
|
|
63 |
description = """
|
64 |
<p align="center">T2I Adherence Scorer based on Davidsonian Scene Graph</p>
|
65 |
<p><center>
|
66 |
-
<a >Original
|
|
|
67 |
<a href="https://huggingface.co/toilaluan/Florence-2-base-Yes-No-VQA" target="_blank">[Binary VQA Model - Query Answering]</a>
|
68 |
<a href="https://huggingface.co/mistralai/Mixtral-8x7B-Instruct-v0.1" target="_blank">[Mixtral 7x8 - Query Generating]</a>
|
69 |
</center></p>
|
@@ -72,8 +73,8 @@ description = """
|
|
72 |
# Define the Gradio interface
|
73 |
interface = gr.Interface(
|
74 |
fn=process_image,
|
75 |
-
inputs=[gr.Image(type="pil"), gr.Textbox(label="Enter your prompt")],
|
76 |
-
outputs=[gr.Image(type="pil"), gr.Textbox(label="
|
77 |
theme=gr.themes.Soft(),
|
78 |
title="",
|
79 |
description=description
|
|
|
4 |
import matplotlib.pyplot as plt
|
5 |
import networkx as nx
|
6 |
from PIL import Image
|
7 |
+
import io
|
8 |
|
9 |
def draw_colored_graph(dependencies, questions, answers):
|
10 |
# Create a directed graph
|
|
|
52 |
)
|
53 |
reward = processor.get_reward(questions, dependencies, [image])
|
54 |
reward = reward[0]
|
55 |
+
answers = {str(i): v > 0.5 for i, v in enumerate(reward)}
|
56 |
graph_img = draw_colored_graph(dependencies, questions, answers)
|
57 |
return reward, f"""
|
58 |
Question: {questions}.
|
|
|
63 |
description = """
|
64 |
<p align="center">T2I Adherence Scorer based on Davidsonian Scene Graph</p>
|
65 |
<p><center>
|
66 |
+
<a href="https://arxiv.org/abs/2310.18235A" target="_blank">[Original Paper]</a>
|
67 |
+
<a href="https://github.com/toilaluan" target="_blank">[My Github]</a>
|
68 |
<a href="https://huggingface.co/toilaluan/Florence-2-base-Yes-No-VQA" target="_blank">[Binary VQA Model - Query Answering]</a>
|
69 |
<a href="https://huggingface.co/mistralai/Mixtral-8x7B-Instruct-v0.1" target="_blank">[Mixtral 7x8 - Query Generating]</a>
|
70 |
</center></p>
|
|
|
73 |
# Define the Gradio interface
|
74 |
interface = gr.Interface(
|
75 |
fn=process_image,
|
76 |
+
inputs=[gr.Image(type="pil", label="Input Image"), gr.Textbox(label="Enter your prompt")],
|
77 |
+
outputs=[gr.Image(type="pil", label="Graph Score Image"), gr.Textbox(label="Analyzed Result")],
|
78 |
theme=gr.themes.Soft(),
|
79 |
title="",
|
80 |
description=description
|