Spaces:
Runtime error
Runtime error
dafajudin
commited on
Commit
·
fb3d5fb
1
Parent(s):
27acef2
update code
Browse files- app.py +16 -13
- index.html +1 -1
- style.css +0 -79
app.py
CHANGED
|
@@ -81,24 +81,28 @@ def format_answer(image, question, history):
|
|
| 81 |
return f"Error: {str(e)}", history
|
| 82 |
|
| 83 |
def clear_history():
|
| 84 |
-
return "", []
|
| 85 |
|
| 86 |
def undo_last(history):
|
| 87 |
if history:
|
| 88 |
history.pop()
|
| 89 |
-
|
|
|
|
|
|
|
|
|
|
| 90 |
|
| 91 |
-
def retry_last(
|
| 92 |
if history:
|
| 93 |
last_image, last_entry = history[-1]
|
|
|
|
| 94 |
return format_answer(last_image, question, history[:-1])
|
| 95 |
-
return "No previous analysis to retry.", history
|
| 96 |
|
| 97 |
def switch_theme(mode):
|
| 98 |
if mode == "Light Mode":
|
| 99 |
return gr.themes.Default()
|
| 100 |
else:
|
| 101 |
-
return gr.themes.Soft(primary_hue=gr.themes.colors.
|
| 102 |
|
| 103 |
def save_feedback(feedback):
|
| 104 |
return "Thank you for your feedback!"
|
|
@@ -113,8 +117,8 @@ def display_history(history):
|
|
| 113 |
with gr.Blocks(
|
| 114 |
theme=gr.themes.Soft(
|
| 115 |
font=[gr.themes.GoogleFont("Inconsolata"), "Arial", "sans-serif"],
|
| 116 |
-
primary_hue=gr.themes.colors.
|
| 117 |
-
secondary_hue=gr.themes.colors.
|
| 118 |
)
|
| 119 |
) as VisualQAApp:
|
| 120 |
gr.HTML(html_content) # Display the HTML content
|
|
@@ -122,10 +126,9 @@ with gr.Blocks(
|
|
| 122 |
with gr.Row():
|
| 123 |
with gr.Column():
|
| 124 |
image_input = gr.Image(label="Upload image", type="pil")
|
|
|
|
| 125 |
question_input = gr.Textbox(show_label=False, placeholder="Enter your question here...")
|
| 126 |
submit_button = gr.Button("Submit", variant="primary")
|
| 127 |
-
|
| 128 |
-
with gr.Column():
|
| 129 |
answer_output = gr.Textbox(label="Result Prediction")
|
| 130 |
|
| 131 |
history_state = gr.State([]) # Initialize the history state
|
|
@@ -144,20 +147,20 @@ with gr.Blocks(
|
|
| 144 |
|
| 145 |
retry_button.click(
|
| 146 |
retry_last,
|
| 147 |
-
inputs=[
|
| 148 |
-
outputs=[answer_output, history_state]
|
| 149 |
)
|
| 150 |
|
| 151 |
undo_button.click(
|
| 152 |
undo_last,
|
| 153 |
inputs=[history_state],
|
| 154 |
-
outputs=[answer_output, history_state]
|
| 155 |
)
|
| 156 |
|
| 157 |
clear_button.click(
|
| 158 |
clear_history,
|
| 159 |
inputs=[],
|
| 160 |
-
outputs=[answer_output, history_state]
|
| 161 |
)
|
| 162 |
|
| 163 |
with gr.Row():
|
|
|
|
| 81 |
return f"Error: {str(e)}", history
|
| 82 |
|
| 83 |
def clear_history():
|
| 84 |
+
return None, "", []
|
| 85 |
|
| 86 |
def undo_last(history):
|
| 87 |
if history:
|
| 88 |
history.pop()
|
| 89 |
+
if history:
|
| 90 |
+
last_image, last_entry = history[-1]
|
| 91 |
+
return last_image, last_entry, history
|
| 92 |
+
return None, "", history
|
| 93 |
|
| 94 |
+
def retry_last(history):
|
| 95 |
if history:
|
| 96 |
last_image, last_entry = history[-1]
|
| 97 |
+
question = last_entry.split(" | ")[0].replace("Question: ", "")
|
| 98 |
return format_answer(last_image, question, history[:-1])
|
| 99 |
+
return None, "No previous analysis to retry.", history
|
| 100 |
|
| 101 |
def switch_theme(mode):
|
| 102 |
if mode == "Light Mode":
|
| 103 |
return gr.themes.Default()
|
| 104 |
else:
|
| 105 |
+
return gr.themes.Soft(primary_hue=gr.themes.colors.green, secondary_hue=gr.themes.colors.green)
|
| 106 |
|
| 107 |
def save_feedback(feedback):
|
| 108 |
return "Thank you for your feedback!"
|
|
|
|
| 117 |
with gr.Blocks(
|
| 118 |
theme=gr.themes.Soft(
|
| 119 |
font=[gr.themes.GoogleFont("Inconsolata"), "Arial", "sans-serif"],
|
| 120 |
+
primary_hue=gr.themes.colors.green,
|
| 121 |
+
secondary_hue=gr.themes.colors.green,
|
| 122 |
)
|
| 123 |
) as VisualQAApp:
|
| 124 |
gr.HTML(html_content) # Display the HTML content
|
|
|
|
| 126 |
with gr.Row():
|
| 127 |
with gr.Column():
|
| 128 |
image_input = gr.Image(label="Upload image", type="pil")
|
| 129 |
+
with gr.Column():
|
| 130 |
question_input = gr.Textbox(show_label=False, placeholder="Enter your question here...")
|
| 131 |
submit_button = gr.Button("Submit", variant="primary")
|
|
|
|
|
|
|
| 132 |
answer_output = gr.Textbox(label="Result Prediction")
|
| 133 |
|
| 134 |
history_state = gr.State([]) # Initialize the history state
|
|
|
|
| 147 |
|
| 148 |
retry_button.click(
|
| 149 |
retry_last,
|
| 150 |
+
inputs=[history_state],
|
| 151 |
+
outputs=[answer_output, image_input, history_state]
|
| 152 |
)
|
| 153 |
|
| 154 |
undo_button.click(
|
| 155 |
undo_last,
|
| 156 |
inputs=[history_state],
|
| 157 |
+
outputs=[image_input, answer_output, history_state]
|
| 158 |
)
|
| 159 |
|
| 160 |
clear_button.click(
|
| 161 |
clear_history,
|
| 162 |
inputs=[],
|
| 163 |
+
outputs=[image_input, answer_output, history_state]
|
| 164 |
)
|
| 165 |
|
| 166 |
with gr.Row():
|
index.html
CHANGED
|
@@ -109,7 +109,7 @@
|
|
| 109 |
<div>
|
| 110 |
<p class="overview-content">
|
| 111 |
The model is trained with Colorectal Nuclear Segmentation and Phenotypes (CoNSeP) dataset
|
| 112 |
-
<a href="https://
|
| 113 |
</p>
|
| 114 |
<ul>
|
| 115 |
<li>Target: Nuclei</li>
|
|
|
|
| 109 |
<div>
|
| 110 |
<p class="overview-content">
|
| 111 |
The model is trained with Colorectal Nuclear Segmentation and Phenotypes (CoNSeP) dataset
|
| 112 |
+
<a href="https://huggingface.co/datasets/mdwiratathya/SLAKE-vqa-english" target="_blank">https://huggingface.co/datasets/mdwiratathya/SLAKE-vqa-english</a>. Images were extracted from 16 colorectal adenocarcinoma (CRA) WSIs.
|
| 113 |
</p>
|
| 114 |
<ul>
|
| 115 |
<li>Target: Nuclei</li>
|
style.css
DELETED
|
@@ -1,79 +0,0 @@
|
|
| 1 |
-
* {
|
| 2 |
-
box-sizing: border-box;
|
| 3 |
-
}
|
| 4 |
-
|
| 5 |
-
body {
|
| 6 |
-
font-family: 'Source Sans Pro', sans-serif;
|
| 7 |
-
font-size: 16px;
|
| 8 |
-
}
|
| 9 |
-
|
| 10 |
-
.container {
|
| 11 |
-
width: 100%;
|
| 12 |
-
margin: 0 auto;
|
| 13 |
-
}
|
| 14 |
-
|
| 15 |
-
.title {
|
| 16 |
-
font-size: 24px !important;
|
| 17 |
-
font-weight: 600 !important;
|
| 18 |
-
letter-spacing: 0em;
|
| 19 |
-
text-align: center;
|
| 20 |
-
color: #374159 !important;
|
| 21 |
-
}
|
| 22 |
-
|
| 23 |
-
.subtitle {
|
| 24 |
-
font-size: 24px !important;
|
| 25 |
-
font-style: italic;
|
| 26 |
-
font-weight: 400 !important;
|
| 27 |
-
letter-spacing: 0em;
|
| 28 |
-
text-align: center;
|
| 29 |
-
color: #1d652a !important;
|
| 30 |
-
padding-bottom: 0.5em;
|
| 31 |
-
}
|
| 32 |
-
|
| 33 |
-
.overview-heading {
|
| 34 |
-
font-size: 24px !important;
|
| 35 |
-
font-weight: 600 !important;
|
| 36 |
-
letter-spacing: 0em;
|
| 37 |
-
text-align: left;
|
| 38 |
-
}
|
| 39 |
-
|
| 40 |
-
.overview-content {
|
| 41 |
-
font-size: 14px !important;
|
| 42 |
-
font-weight: 400 !important;
|
| 43 |
-
line-height: 33px !important;
|
| 44 |
-
letter-spacing: 0em;
|
| 45 |
-
text-align: left;
|
| 46 |
-
}
|
| 47 |
-
|
| 48 |
-
.content-image {
|
| 49 |
-
width: 100% !important;
|
| 50 |
-
height: auto !important;
|
| 51 |
-
}
|
| 52 |
-
|
| 53 |
-
.vl {
|
| 54 |
-
border-left: 5px solid #1d652a;
|
| 55 |
-
padding-left: 20px;
|
| 56 |
-
color: #1d652a !important;
|
| 57 |
-
}
|
| 58 |
-
|
| 59 |
-
.grid-container {
|
| 60 |
-
display: grid;
|
| 61 |
-
grid-template-columns: 1fr 2fr;
|
| 62 |
-
gap: 20px;
|
| 63 |
-
align-items: flex-start;
|
| 64 |
-
margin-bottom: 1em;
|
| 65 |
-
}
|
| 66 |
-
|
| 67 |
-
@media screen and (max-width: 768px) {
|
| 68 |
-
.container {
|
| 69 |
-
width: 90%;
|
| 70 |
-
}
|
| 71 |
-
|
| 72 |
-
.grid-container {
|
| 73 |
-
display: block;
|
| 74 |
-
}
|
| 75 |
-
|
| 76 |
-
.overview-heading {
|
| 77 |
-
font-size: 18px !important;
|
| 78 |
-
}
|
| 79 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|