umang018 commited on
Commit
ba95aa8
·
verified ·
1 Parent(s): 175710c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -25,7 +25,8 @@ emotion_labels = ["admiration", "amusement", "anger", "annoyance", "approval",
25
  def classify_emotions_in_batches(texts, batch_size=64):
26
  results = []
27
  start_time = time.time()
28
- for i in range(0, 1280, batch_size):
 
29
  batch = texts[i:i+batch_size]
30
  inputs = tokenizer(batch, return_tensors="pt", truncation=True, padding=True).to(device)
31
  with torch.no_grad():
@@ -36,7 +37,7 @@ def classify_emotions_in_batches(texts, batch_size=64):
36
 
37
  # Log progress
38
  batch_time = time.time() - start_time
39
- st.write(f"Processed batch {i//batch_size + 1} of {len(texts)//batch_size + 1} in {batch_time:.2f} seconds")
40
  start_time = time.time()
41
  return results
42
 
 
25
  def classify_emotions_in_batches(texts, batch_size=64):
26
  results = []
27
  start_time = time.time()
28
+ num_batches = min(20, (len(texts) + batch_size - 1) // batch_size) # Calculate the number of batches to run (up to 20)
29
+ for i in range(0, num_batches * batch_size, batch_size):
30
  batch = texts[i:i+batch_size]
31
  inputs = tokenizer(batch, return_tensors="pt", truncation=True, padding=True).to(device)
32
  with torch.no_grad():
 
37
 
38
  # Log progress
39
  batch_time = time.time() - start_time
40
+ st.write(f"Processed batch {i//batch_size + 1} of {num_batches} in {batch_time:.2f} seconds")
41
  start_time = time.time()
42
  return results
43