Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,10 +7,7 @@ import os
|
|
| 7 |
|
| 8 |
|
| 9 |
access_token = os.getenv('HF_token')
|
| 10 |
-
|
| 11 |
model_id = "selamw/BirdWatcher"
|
| 12 |
-
# model_id = "selamw/bird-Identifier"
|
| 13 |
-
|
| 14 |
bnb_config = BitsAndBytesConfig(load_in_8bit=True)
|
| 15 |
|
| 16 |
|
|
@@ -29,14 +26,11 @@ def convert_to_markdown(input_text):
|
|
| 29 |
title, content = map(str.strip, input_text.split(":", 1))
|
| 30 |
# Bold the keywords
|
| 31 |
for word in bold_words:
|
| 32 |
-
# content = content.replace(word, f'\n\n**{word}\n')
|
| 33 |
content = content.replace(word, f'\n\n**{word}')
|
| 34 |
-
# content = content.replace(f': **', f':**')
|
| 35 |
|
| 36 |
# Construct the Markdown output with headings
|
| 37 |
formatted_output = f"**{title}**{content}"
|
| 38 |
|
| 39 |
-
|
| 40 |
return formatted_output.strip()
|
| 41 |
|
| 42 |
@spaces.GPU
|
|
@@ -53,7 +47,6 @@ def infer_fin_pali(image, question):
|
|
| 53 |
|
| 54 |
# Ensure proper Markdown formatting
|
| 55 |
formatted_output = convert_to_markdown(decoded_output)
|
| 56 |
-
# formatted_output = (decoded_output)
|
| 57 |
|
| 58 |
return formatted_output
|
| 59 |
|
|
@@ -87,12 +80,11 @@ with gr.Blocks(css=css) as demo:
|
|
| 87 |
input_img = gr.Image(label="Input Bird Image")
|
| 88 |
with gr.Column():
|
| 89 |
with gr.Row():
|
| 90 |
-
question = gr.Text(label="Default Prompt", value="Describe this bird species", elem_id="default-prompt")
|
| 91 |
with gr.Row():
|
| 92 |
submit_btn = gr.Button(value="Run")
|
| 93 |
with gr.Row():
|
| 94 |
output = gr.Markdown(label="Response") # Use Markdown component to display output
|
| 95 |
-
# output = gr.Text(label="Response") # Use Markdown component to display output
|
| 96 |
|
| 97 |
submit_btn.click(infer_fin_pali, [input_img, question], [output])
|
| 98 |
|
|
|
|
| 7 |
|
| 8 |
|
| 9 |
access_token = os.getenv('HF_token')
|
|
|
|
| 10 |
model_id = "selamw/BirdWatcher"
|
|
|
|
|
|
|
| 11 |
bnb_config = BitsAndBytesConfig(load_in_8bit=True)
|
| 12 |
|
| 13 |
|
|
|
|
| 26 |
title, content = map(str.strip, input_text.split(":", 1))
|
| 27 |
# Bold the keywords
|
| 28 |
for word in bold_words:
|
|
|
|
| 29 |
content = content.replace(word, f'\n\n**{word}')
|
|
|
|
| 30 |
|
| 31 |
# Construct the Markdown output with headings
|
| 32 |
formatted_output = f"**{title}**{content}"
|
| 33 |
|
|
|
|
| 34 |
return formatted_output.strip()
|
| 35 |
|
| 36 |
@spaces.GPU
|
|
|
|
| 47 |
|
| 48 |
# Ensure proper Markdown formatting
|
| 49 |
formatted_output = convert_to_markdown(decoded_output)
|
|
|
|
| 50 |
|
| 51 |
return formatted_output
|
| 52 |
|
|
|
|
| 80 |
input_img = gr.Image(label="Input Bird Image")
|
| 81 |
with gr.Column():
|
| 82 |
with gr.Row():
|
| 83 |
+
question = gr.Text(label="Default Prompt", value="Describe this bird species", elem_id="default-prompt", interactive: False)
|
| 84 |
with gr.Row():
|
| 85 |
submit_btn = gr.Button(value="Run")
|
| 86 |
with gr.Row():
|
| 87 |
output = gr.Markdown(label="Response") # Use Markdown component to display output
|
|
|
|
| 88 |
|
| 89 |
submit_btn.click(infer_fin_pali, [input_img, question], [output])
|
| 90 |
|