Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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(
|
| 21 |
-
|
|
|
|
| 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(
|
| 31 |
-
|
|
|
|
| 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,
|