Singularity666 commited on
Commit
4fbc488
·
1 Parent(s): b84092b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -0
app.py CHANGED
@@ -57,6 +57,11 @@ model = CLIPModel().to(device)
57
  model.load_state_dict(torch.load("weights.pt", map_location=torch.device('cpu')))
58
  text_embeddings = torch.load('saved_text_embeddings.pt', map_location=device)
59
 
 
 
 
 
 
60
  def show_predicted_caption(image, top_k=1):
61
  matches = predict_caption(
62
  image, model, text_embeddings, testing_df["caption"]
 
57
  model.load_state_dict(torch.load("weights.pt", map_location=torch.device('cpu')))
58
  text_embeddings = torch.load('saved_text_embeddings.pt', map_location=device)
59
 
60
+ def download_link(content, filename, link_text):
61
+ b64 = base64.b64encode(content).decode()
62
+ href = f'<a href="data:application/octet-stream;base64,{b64}" download="{filename}">{link_text}</a>'
63
+ return href
64
+
65
  def show_predicted_caption(image, top_k=1):
66
  matches = predict_caption(
67
  image, model, text_embeddings, testing_df["caption"]