gauri-sharan commited on
Commit
200c7bb
·
verified ·
1 Parent(s): 47c68aa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -74,13 +74,13 @@ def ocr_and_extract(image, text_query):
74
  generated_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False
75
  )
76
 
77
- # Filter out system and user prompts
78
- filtered_output = [line for line in output_text[0].split("\n") if not any(kw in line.lower() for kw in ["system", "user"])]
79
 
80
  # Clean up the temporary file
81
  os.remove(temp_image_path)
82
 
83
- return "\n".join(filtered_output)
84
 
85
  except Exception as e:
86
  error_message = str(e)
 
74
  generated_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False
75
  )
76
 
77
+ # Filter out "You are a helpful assistant" and "assistant" labels
78
+ filtered_output = [line for line in output_text[0].split("\n") if not any(kw in line.lower() for kw in ["you are a helpful assistant", "assistant", "user", "system"])]
79
 
80
  # Clean up the temporary file
81
  os.remove(temp_image_path)
82
 
83
+ return "\n".join(filtered_output).strip()
84
 
85
  except Exception as e:
86
  error_message = str(e)