Update app.py
Browse files
app.py
CHANGED
@@ -148,16 +148,53 @@ description = """Quick demonstration of the FAPM model for protein function pred
|
|
148 |
|
149 |
The model used in this app is available at [Hugging Face Model Hub](https://huggingface.co/wenkai/FAPM) and the source code can be found on [GitHub](https://github.com/xiangwenkai/FAPM/tree/main)."""
|
150 |
|
151 |
-
iface = gr.Interface(
|
152 |
-
fn=generate_caption,
|
153 |
-
inputs=[gr.Textbox(type="text", label="Upload sequence"), gr.Textbox(type="text", label="Prompt")],
|
154 |
-
outputs=gr.Textbox(label="Generated description"),
|
155 |
-
description=description
|
156 |
-
)
|
157 |
-
|
158 |
-
# Launch the interface
|
159 |
-
iface.launch()
|
160 |
-
|
161 |
-
|
162 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
|
|
|
148 |
|
149 |
The model used in this app is available at [Hugging Face Model Hub](https://huggingface.co/wenkai/FAPM) and the source code can be found on [GitHub](https://github.com/xiangwenkai/FAPM/tree/main)."""
|
150 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
|
152 |
+
# iface = gr.Interface(
|
153 |
+
# fn=generate_caption,
|
154 |
+
# inputs=[gr.Textbox(type="text", label="Upload sequence"), gr.Textbox(type="text", label="Prompt")],
|
155 |
+
# outputs=gr.Textbox(label="Generated description"),
|
156 |
+
# description=description
|
157 |
+
# )
|
158 |
+
# # Launch the interface
|
159 |
+
# iface.launch()
|
160 |
+
|
161 |
+
|
162 |
+
css = """
|
163 |
+
#output {
|
164 |
+
height: 500px;
|
165 |
+
overflow: auto;
|
166 |
+
border: 1px solid #ccc;
|
167 |
+
}
|
168 |
+
"""
|
169 |
+
|
170 |
+
with gr.Blocks(css=css) as demo:
|
171 |
+
gr.Markdown(description)
|
172 |
+
with gr.Tab(label="Protein caption"):
|
173 |
+
with gr.Row():
|
174 |
+
with gr.Column():
|
175 |
+
input_protein = gr.Textbox(type="text", label="Upload sequence")
|
176 |
+
# model_selector = gr.Dropdown(choices=list(models.keys()), label="Model", value='microsoft/Florence-2-large')
|
177 |
+
prompt = gr.Textbox(type="text", label="Prompt")
|
178 |
+
submit_btn = gr.Button(value="Submit")
|
179 |
+
with gr.Column():
|
180 |
+
output_text = gr.Textbox(label="Output Text")
|
181 |
+
# index 99, 127, 266, 738, 1060
|
182 |
+
gr.Examples(
|
183 |
+
examples=[
|
184 |
+
["MKTLLLTLVVVTIVCLDLGNSLKCYVSREGKTQTCPEGEKLCEKYAVSYFHDGRWRYRYECTSACHRGPYNVCCSTDLCNK", 'Micrurus'],
|
185 |
+
["MSSSAGSGHQPSQSRAIPTRTVAISDAAQLPHDYCTTPGGTLFSTTPGGTRIIYDRKFLLDRRNSPMAQTPPCHLPNIPGVTSPGTLIEDSKVEVNNLNNLNNHDRKHAVGDDAQFEMDI", 'Homo'],
|
186 |
+
["MKTLALFLVLVCVLGLVQSWEWPWNRKPTKFPIPSPNPRDKWCRLNLGPAWGGRC", 'Sophophora'],
|
187 |
+
["MAARGAMLRYLRVNVNPTIQNPRECVLPFSILLRRFSEEVRGSFLDKSEVTDRVLSVVKNFQKVDPSKVTPKANFQNDLGLDSLDSVEVVMALEEEFGFEIPDNEADKIQSIDLAVDFIASHPQAK", 'Arabidopsis'],
|
188 |
+
["MAAAGGARLLRAASAVLGGPAGRWLHHAGSRAGSSGLLRNRGPGGSAEASRSLSVSARARSSSEDKITVHFINRDGETLTTKGKVGDSLLDVVVENNLDIDGFGACEGTLACSTCHLIFEDHIYEKLDAITDEENDMLDLAYGLTDRSRLGCQICLTKSMDNMTVRVPETVADARQSIDVGKTS", 'Homo']
|
189 |
+
],
|
190 |
+
inputs=[input_protein, prompt],
|
191 |
+
outputs=[output_text],
|
192 |
+
fn=generate_caption,
|
193 |
+
cache_examples=True,
|
194 |
+
label='Try examples'
|
195 |
+
)
|
196 |
+
|
197 |
+
submit_btn.click(generate_caption, [input_protein, prompt], [output_text])
|
198 |
+
|
199 |
+
demo.launch(debug=True)
|
200 |
|