chgrdj commited on
Commit
480c8da
·
verified ·
1 Parent(s): ae18a31

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -9
app.py CHANGED
@@ -12,6 +12,7 @@ def load_model():
12
  tokenizer = AutoTokenizer.from_pretrained(model_id)
13
  model = AutoModelForSeq2SeqLM.from_pretrained(model_id)
14
  model = PeftModel.from_pretrained(model, adapter_path)
 
15
  model.eval()
16
 
17
  return model, tokenizer
@@ -21,21 +22,13 @@ model, tokenizer = load_model()
21
  st.title("FLAN-T5 Typosquatting Detection")
22
  st.write("Enter a potential typosquatted domain and a target domain to check if one is a variant of the other.")
23
 
24
- # Non-editable prompt part
25
  prompt_prefix = "Is the first domain a typosquat of the second:"
26
 
27
- # Display the non-editable prompt with input fields for the rest
28
- st.markdown("### Prompt")
29
- st.text_area("Prompt", prompt_prefix, height=68, disabled=True)
30
-
31
- # User inputs for dynamic part of the prompt
32
  potential_typosquat = st.text_input("Potential Typosquatted Domain", value="lonlonsoft.com")
33
  target_domain = st.text_input("Legitimate Domain", value="stiltsoft.net")
34
 
35
- # Generate prompt by combining fixed and dynamic parts
36
  full_prompt = f"{prompt_prefix} {potential_typosquat} {target_domain}"
37
 
38
- # Perform inference when button is clicked
39
  if st.button("Check Typosquatting"):
40
  if potential_typosquat and target_domain:
41
  # Encode and generate response
@@ -46,7 +39,7 @@ if st.button("Check Typosquatting"):
46
  prediction = tokenizer.decode(outputs[0], skip_special_tokens=True)
47
 
48
  # Display the result
49
- st.write("**Prediction:**")
50
  st.write(prediction)
51
  else:
52
  st.warning("Please enter both domains to perform the check.")
 
12
  tokenizer = AutoTokenizer.from_pretrained(model_id)
13
  model = AutoModelForSeq2SeqLM.from_pretrained(model_id)
14
  model = PeftModel.from_pretrained(model, adapter_path)
15
+ model = model.merge_and_unload()
16
  model.eval()
17
 
18
  return model, tokenizer
 
22
  st.title("FLAN-T5 Typosquatting Detection")
23
  st.write("Enter a potential typosquatted domain and a target domain to check if one is a variant of the other.")
24
 
 
25
  prompt_prefix = "Is the first domain a typosquat of the second:"
26
 
 
 
 
 
 
27
  potential_typosquat = st.text_input("Potential Typosquatted Domain", value="lonlonsoft.com")
28
  target_domain = st.text_input("Legitimate Domain", value="stiltsoft.net")
29
 
 
30
  full_prompt = f"{prompt_prefix} {potential_typosquat} {target_domain}"
31
 
 
32
  if st.button("Check Typosquatting"):
33
  if potential_typosquat and target_domain:
34
  # Encode and generate response
 
39
  prediction = tokenizer.decode(outputs[0], skip_special_tokens=True)
40
 
41
  # Display the result
42
+ st.write("**Prediction: **")
43
  st.write(prediction)
44
  else:
45
  st.warning("Please enter both domains to perform the check.")