ivmarin commited on
Commit
6b74cdc
1 Parent(s): 86126f3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -12
app.py CHANGED
@@ -5,18 +5,10 @@ import numpy as np
5
  from torchvision import transforms
6
 
7
  def predict(text):
8
-
9
- device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
10
- model = torch.jit.load("model.pth")
11
- model = model.cpu()
12
- model.eval()
13
-
14
- model.to(device)
15
- with torch.no_grad():
16
- outputs = model(text)
17
- outputs = torch.argmax(outputs,1)
18
-
19
- return(outputs)
20
 
21
  # Creamos la interfaz y la lanzamos.
22
  gr.Interface(fn=predict, inputs="text", outputs="text").launch();
 
5
  from torchvision import transforms
6
 
7
  def predict(text):
8
+
9
+ learnClass = text_classifier_learner(dls, AWD_LSTM, drop_mult=0.5, metrics=accuracy,cbs=callbacks).to_fp16()
10
+ learnClass = learnClass.load_encoder('modelo')
11
+ return(learnClass.predict(text))
 
 
 
 
 
 
 
 
12
 
13
  # Creamos la interfaz y la lanzamos.
14
  gr.Interface(fn=predict, inputs="text", outputs="text").launch();