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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -41,7 +41,7 @@ def ocr_and_extract(image, text_query):
41
  )
42
 
43
  # Perform the search query on the indexed image
44
- results = rag_model.search(text_query, k=1) # Removed index_name argument
45
 
46
  # Prepare the input for Qwen2-VL
47
  image_data = Image.open(temp_image_path)
@@ -74,10 +74,13 @@ def ocr_and_extract(image, text_query):
74
  generated_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False
75
  )
76
 
 
 
 
77
  # Clean up the temporary file
78
  os.remove(temp_image_path)
79
 
80
- return output_text[0]
81
 
82
  except Exception as e:
83
  error_message = str(e)
 
41
  )
42
 
43
  # Perform the search query on the indexed image
44
+ results = rag_model.search(text_query, k=1)
45
 
46
  # Prepare the input for Qwen2-VL
47
  image_data = Image.open(temp_image_path)
 
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)