Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,10 +5,18 @@ import numpy as np
|
|
5 |
from torchvision import transforms
|
6 |
|
7 |
def predict(text):
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
# Creamos la interfaz y la lanzamos.
|
14 |
gr.Interface(fn=predict, inputs="text", outputs="text").launch();
|
|
|
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();
|