kgemera commited on
Commit
c6b27bf
·
verified ·
1 Parent(s): 8209ae5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -17,8 +17,9 @@ model_path = hf_hub_download(
17
  model = joblib.load(model_path)
18
 
19
  # Single prediction
20
- def predict_single(text):
21
- return model.predict([text])[0]
 
22
 
23
  single_interface = gr.Interface(
24
  fn=predict_single,
@@ -27,8 +28,9 @@ single_interface = gr.Interface(
27
  )
28
 
29
  # Batch prediction
30
- def predict_batch(texts):
31
- return [model.predict([t])[0] for t in texts]
 
32
 
33
  batch_interface = gr.Interface(
34
  fn=predict_batch,
 
17
  model = joblib.load(model_path)
18
 
19
  # Single prediction
20
+ def predict_single(title, abstract):
21
+ df = pd.DataFrame([{"title": title, "abstract": abstract}])
22
+ return model.predict(df)[0]
23
 
24
  single_interface = gr.Interface(
25
  fn=predict_single,
 
28
  )
29
 
30
  # Batch prediction
31
+ def predict_batch(df):
32
+ # df ya vendrá como dataframe desde gr.Dataframe
33
+ return model.predict(df).tolist()
34
 
35
  batch_interface = gr.Interface(
36
  fn=predict_batch,