Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,7 @@ from transformers import BitsAndBytesConfig, PaliGemmaForConditionalGeneration,
|
|
| 4 |
import spaces
|
| 5 |
import torch
|
| 6 |
import os
|
| 7 |
-
|
| 8 |
|
| 9 |
access_token = os.getenv('HF_token')
|
| 10 |
|
|
@@ -15,22 +15,22 @@ bnb_config = BitsAndBytesConfig(load_in_8bit=True)
|
|
| 15 |
|
| 16 |
|
| 17 |
def convert_to_markdown(input_text):
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
|
| 35 |
@spaces.GPU
|
| 36 |
def infer_fin_pali(image, question):
|
|
|
|
| 4 |
import spaces
|
| 5 |
import torch
|
| 6 |
import os
|
| 7 |
+
|
| 8 |
|
| 9 |
access_token = os.getenv('HF_token')
|
| 10 |
|
|
|
|
| 15 |
|
| 16 |
|
| 17 |
def convert_to_markdown(input_text):
|
| 18 |
+
# Split the input text into sections based on the '**' delimiter
|
| 19 |
+
sections = input_text.split("**")
|
| 20 |
+
|
| 21 |
+
# Initialize the formatted output with the bird name
|
| 22 |
+
formatted_output = f"**{sections[0].strip()}**\n"
|
| 23 |
+
|
| 24 |
+
# Process each section to format it
|
| 25 |
+
for i in range(1, len(sections), 2):
|
| 26 |
+
if i + 1 < len(sections):
|
| 27 |
+
# Use '##' for subheadings and clean up the text
|
| 28 |
+
header = sections[i].strip() + "** "
|
| 29 |
+
content = sections[i + 1].strip()
|
| 30 |
+
formatted_output += f"\n**{header}{content}\n"
|
| 31 |
+
|
| 32 |
+
# Return the formatted output
|
| 33 |
+
return formatted_output.strip()
|
| 34 |
|
| 35 |
@spaces.GPU
|
| 36 |
def infer_fin_pali(image, question):
|