Tonic commited on
Commit
e0ce0b3
β€’
1 Parent(s): 3ba36fc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -8
app.py CHANGED
@@ -1,4 +1,3 @@
1
- import spaces
2
  import torch
3
  import torch.nn.functional as F
4
  from torch import Tensor
@@ -82,8 +81,6 @@ def embedding_worker():
82
 
83
  threading.Thread(target=embedding_worker, daemon=True).start()
84
 
85
-
86
- @spaces.GPU
87
  def compute_embeddings(selected_task, input_text):
88
  try:
89
  task_description = tasks[selected_task]
@@ -104,7 +101,6 @@ def compute_embeddings(selected_task, input_text):
104
  clear_cuda_cache()
105
  return embeddings_list
106
 
107
- @spaces.GPU
108
  def decode_embedding(embedding_str):
109
  try:
110
  embedding = [float(num) for num in embedding_str.split(',')]
@@ -114,7 +110,6 @@ def decode_embedding(embedding_str):
114
  except Exception as e:
115
  return f"Error in decoding: {str(e)}"
116
 
117
- @spaces.GPU
118
  def compute_similarity(selected_task, sentence1, sentence2, extra_sentence1, extra_sentence2):
119
  try:
120
  task_description = tasks[selected_task]
@@ -145,7 +140,6 @@ def compute_similarity(selected_task, sentence1, sentence2, extra_sentence1, ext
145
  clear_cuda_cache()
146
  return similarity_scores
147
 
148
- @spaces.GPU
149
  def compute_cosine_similarity(emb1, emb2):
150
  tensor1 = torch.tensor(emb1).to(device).half()
151
  tensor2 = torch.tensor(emb2).to(device).half()
@@ -155,7 +149,6 @@ def compute_cosine_similarity(emb1, emb2):
155
  return similarity
156
 
157
 
158
- @spaces.GPU
159
  def compute_embeddings_batch(input_texts):
160
  max_length = 2042
161
  processed_texts = [f'Instruct: {task_description}\nQuery: {text}' for text in input_texts]
@@ -311,4 +304,4 @@ def app_interface():
311
  return demo
312
 
313
  app_interface().queue()
314
- app_interface().launch()
 
 
1
  import torch
2
  import torch.nn.functional as F
3
  from torch import Tensor
 
81
 
82
  threading.Thread(target=embedding_worker, daemon=True).start()
83
 
 
 
84
  def compute_embeddings(selected_task, input_text):
85
  try:
86
  task_description = tasks[selected_task]
 
101
  clear_cuda_cache()
102
  return embeddings_list
103
 
 
104
  def decode_embedding(embedding_str):
105
  try:
106
  embedding = [float(num) for num in embedding_str.split(',')]
 
110
  except Exception as e:
111
  return f"Error in decoding: {str(e)}"
112
 
 
113
  def compute_similarity(selected_task, sentence1, sentence2, extra_sentence1, extra_sentence2):
114
  try:
115
  task_description = tasks[selected_task]
 
140
  clear_cuda_cache()
141
  return similarity_scores
142
 
 
143
  def compute_cosine_similarity(emb1, emb2):
144
  tensor1 = torch.tensor(emb1).to(device).half()
145
  tensor2 = torch.tensor(emb2).to(device).half()
 
149
  return similarity
150
 
151
 
 
152
  def compute_embeddings_batch(input_texts):
153
  max_length = 2042
154
  processed_texts = [f'Instruct: {task_description}\nQuery: {text}' for text in input_texts]
 
304
  return demo
305
 
306
  app_interface().queue()
307
+ app_interface().launch(share=True)