selamw commited on
Commit
1e01463
·
verified ·
1 Parent(s): b8a9160

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -11
app.py CHANGED
@@ -25,21 +25,20 @@ def convert_to_markdown(input_text):
25
  str: The formatted Markdown text.
26
  """
27
 
28
- # bold_words = ['Look:', 'Cool Fact!:', 'Habitat:', 'Food:', 'Birdie Behaviors:']
29
 
30
- # # Split into title and content based on the first ":", handling extra whitespace
31
- # title, content = map(str.strip, input_text.split(":", 1))
32
- # # Bold the keywords
33
- # for word in bold_words:
34
- # content = content.replace(word, f'\n**{word}**\n')
35
- # content = content.replace(f'** ', f' ')
36
 
37
- # # Construct the Markdown output with headings
38
- # formatted_output = f"**{title}{content}"
39
- input_text = """**ABBOTT'S BABBLER (Malacocincla abbotti)** \n\n **Look:** \n Robin-sized detective! This bird has a sandy-brown body with rusty flanks, a short tail, and a heavy hooked bill. Check for a pale gray eyebrow in Southeast Asia. \n\n **Cool Fact!:** \n Works in pairs, hopping on the forest floor like little detectives searching for clues (their prey!). \n\n **Habitat:** \n Prefers the shady undergrowth of permanent forests, especially near streams and tangled vegetation. \n\n **Food:** \n Not picky eaters! They enjoy a varied menu of insects, worms, and even seeds. \n\n **Birdie Behaviors:** \n Secretive by nature, but listen for their surprising calls – a mix of harsh churrs and melodic whistles."""
40
 
41
 
42
- return input_text
43
 
44
  @spaces.GPU
45
  def infer_fin_pali(image, question):
 
25
  str: The formatted Markdown text.
26
  """
27
 
28
+ bold_words = ['Look:', 'Cool Fact!:', 'Habitat:', 'Food:', 'Birdie Behaviors:']
29
 
30
+ # Split into title and content based on the first ":", handling extra whitespace
31
+ title, content = map(str.strip, input_text.split(":", 1))
32
+ # Bold the keywords
33
+ for word in bold_words:
34
+ content = content.replace(word, f'\n**{word}**\n')
35
+ content = content.replace(f'** ', f' ')
36
 
37
+ # Construct the Markdown output with headings
38
+ formatted_output = f"**{title}{content}"
 
39
 
40
 
41
+ return formatted_output.strip()
42
 
43
  @spaces.GPU
44
  def infer_fin_pali(image, question):