win2win commited on
Commit
db3d54d
·
verified ·
1 Parent(s): 2e15bb7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -14
app.py CHANGED
@@ -7,24 +7,17 @@ def install(package):
7
  install("transformers")
8
  install("torch")
9
 
10
- from transformers import pipeline
11
  import gradio as gr
12
 
13
- model = pipeline("text-classification", model="win2win/3-epochs-classifier-ver2")
14
-
15
- def predict(text):
16
- return model(text)
17
-
18
- gr.Interface(fn=predict, inputs="text", outputs="json").launch()
19
-
20
- import gradio as gr
21
  from transformers import pipeline
22
 
 
23
 
24
-
25
  model = pipeline("text-classification", model="win2win/3-epochs-classifier-ver2")
26
 
27
- def predict(text):
28
- return model(text)
29
-
30
- gr.Interface(fn=predict, inputs="text", outputs="json").launch()
 
7
  install("transformers")
8
  install("torch")
9
 
 
10
  import gradio as gr
11
 
12
+ from fastapi import FastAPI
 
 
 
 
 
 
 
13
  from transformers import pipeline
14
 
15
+ app = FastAPI()
16
 
17
+ # Load your Hugging Face model
18
  model = pipeline("text-classification", model="win2win/3-epochs-classifier-ver2")
19
 
20
+ # Define a POST endpoint at `/predict`
21
+ @app.post("/predict")
22
+ async def predict(text: str):
23
+ return model(text)