Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,22 +1,18 @@
|
|
| 1 |
from transformers import pipeline
|
| 2 |
import gradio as gr
|
| 3 |
-
import os
|
| 4 |
|
| 5 |
-
# Load model
|
| 6 |
-
model = pipeline(
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
device="cpu" # Free Spaces only have CPU
|
| 10 |
-
)
|
| 11 |
|
| 12 |
def predict(text):
|
| 13 |
return model(text)
|
| 14 |
|
| 15 |
-
#
|
| 16 |
gr.Interface(
|
| 17 |
fn=predict,
|
| 18 |
inputs="text",
|
| 19 |
outputs="json",
|
| 20 |
-
title="Text Classifier"
|
| 21 |
-
|
| 22 |
-
).launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
| 1 |
from transformers import pipeline
|
| 2 |
import gradio as gr
|
|
|
|
| 3 |
|
| 4 |
+
# Load model with CPU (required for free Spaces)
|
| 5 |
+
model = pipeline("text-classification",
|
| 6 |
+
model="win2win/3-epochs-classifier-ver2",
|
| 7 |
+
device="cpu")
|
|
|
|
|
|
|
| 8 |
|
| 9 |
def predict(text):
|
| 10 |
return model(text)
|
| 11 |
|
| 12 |
+
# Create Gradio interface
|
| 13 |
gr.Interface(
|
| 14 |
fn=predict,
|
| 15 |
inputs="text",
|
| 16 |
outputs="json",
|
| 17 |
+
title="Text Classifier"
|
| 18 |
+
).launch()
|
|
|