win2win commited on
Commit
9395b4a
·
verified ·
1 Parent(s): b7d4dcb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -11
app.py CHANGED
@@ -1,22 +1,18 @@
1
  from transformers import pipeline
2
  import gradio as gr
3
- import os
4
 
5
- # Load model (force CPU if no GPU)
6
- model = pipeline(
7
- "text-classification",
8
- model="win2win/3-epochs-classifier-ver2",
9
- device="cpu" # Free Spaces only have CPU
10
- )
11
 
12
  def predict(text):
13
  return model(text)
14
 
15
- # Launch Gradio with explicit API enabled
16
  gr.Interface(
17
  fn=predict,
18
  inputs="text",
19
  outputs="json",
20
- title="Text Classifier",
21
- allow_flagging="never"
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()