kithangw commited on
Commit
4c9cbd6
1 Parent(s): 0ebd7c5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -45,16 +45,18 @@ def main():
45
  try:
46
  # Process the image with the OCR pipeline
47
  ocr_result = image_pipeline(image)[0]['generated_text'].replace(" ", "").lower()
48
- verified_url = st.text_input("Recognized URL", ocr_result)
 
49
  except Exception as e:
50
  st.error(f"An error occurred during image processing: {e}")
51
 
52
  if st.button('Detect Phishing'):
53
- if 'verified_url' in st.session_state:
 
54
  result = check_phishing(phishing_model, phishing_tokenizer, st.session_state['verified_url'])
55
  st.write(result)
56
  else:
57
- st.write("Please upload an image to detect the URL and check for phishing.")
58
 
59
  # Run the main function
60
  if __name__ == "__main__":
 
45
  try:
46
  # Process the image with the OCR pipeline
47
  ocr_result = image_pipeline(image)[0]['generated_text'].replace(" ", "").lower()
48
+ # Store the verified URL in session state for access later
49
+ st.session_state['verified_url'] = st.text_input("Recognized URL", ocr_result)
50
  except Exception as e:
51
  st.error(f"An error occurred during image processing: {e}")
52
 
53
  if st.button('Detect Phishing'):
54
+ # Check for 'verified_url' in session state instead of local variable
55
+ if 'verified_url' in st.session_state and st.session_state['verified_url']:
56
  result = check_phishing(phishing_model, phishing_tokenizer, st.session_state['verified_url'])
57
  st.write(result)
58
  else:
59
+ st.error("Please upload an image to detect the URL and check for phishing.")
60
 
61
  # Run the main function
62
  if __name__ == "__main__":