LPN64 commited on
Commit
0a1005c
·
verified ·
1 Parent(s): 737fa5c

Don't treat a string starting by http as an image link if there is a space in it

Browse files

Just because there is a http at start doesn't mean it's an url, added space check to extract chunks just starting by http (happened with a research paper)

Files changed (1) hide show
  1. custom_st.py +1 -1
custom_st.py CHANGED
@@ -70,7 +70,7 @@ class Transformer(nn.Module):
70
  elif text.startswith("Passage: "):
71
  clean_text = text[len("Passage: ") :]
72
 
73
- if clean_text.startswith("http"):
74
  response = requests.get(clean_text)
75
  texts[i] = Image.open(BytesIO(response.content)).convert("RGB")
76
  image_indices.append(i)
 
70
  elif text.startswith("Passage: "):
71
  clean_text = text[len("Passage: ") :]
72
 
73
+ if clean_text.startswith("http") and " " not in clean_text:
74
  response = requests.get(clean_text)
75
  texts[i] = Image.open(BytesIO(response.content)).convert("RGB")
76
  image_indices.append(i)