Spaces:
Runtime error
Runtime error
Commit ·
dd8538c
1
Parent(s): 7a88347
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,8 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
def greet(name):
|
| 4 |
if name == 'Just happened a terrible car crash':
|
|
@@ -10,8 +14,10 @@ def greet(name):
|
|
| 10 |
'input_ids': [1, 54453, 294, 1063, 1625, 266, 4838, 640, 4325, 2],
|
| 11 |
'token_type_ids': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
| 12 |
'attention_mask': [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]}
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
return
|
| 15 |
if name == 'Heard about #earthquake is different cities, stay safe everyone':
|
| 16 |
map = {'id': 2,
|
| 17 |
'keyword': '',
|
|
@@ -22,7 +28,9 @@ def greet(name):
|
|
| 22 |
'token_type_ids': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
| 23 |
'attention_mask': [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]}
|
| 24 |
|
| 25 |
-
|
|
|
|
|
|
|
| 26 |
if name == 'Theyd probably still show more life than Arsenal did yesterday, eh? EH?':
|
| 27 |
map = {'id': 21,
|
| 28 |
'keyword': '',
|
|
@@ -33,7 +41,9 @@ def greet(name):
|
|
| 33 |
'token_type_ids': [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
|
| 34 |
'attention_mask': [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]}
|
| 35 |
|
| 36 |
-
|
|
|
|
|
|
|
| 37 |
return
|
| 38 |
|
| 39 |
examples = [['Just happened a terrible car crash'],['Heard about #earthquake is different cities, stay safe everyone'], ['Theyd probably still show more life than Arsenal did yesterday, eh? EH?']]
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from fastai.vision.all import *
|
| 3 |
+
import skimage
|
| 4 |
+
|
| 5 |
+
learn = load_learner('export.pkl')
|
| 6 |
|
| 7 |
def greet(name):
|
| 8 |
if name == 'Just happened a terrible car crash':
|
|
|
|
| 14 |
'input_ids': [1, 54453, 294, 1063, 1625, 266, 4838, 640, 4325, 2],
|
| 15 |
'token_type_ids': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
| 16 |
'attention_mask': [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]}
|
| 17 |
+
|
| 18 |
+
pred,pred_idx,probs = learn.predict(map)
|
| 19 |
|
| 20 |
+
return probs
|
| 21 |
if name == 'Heard about #earthquake is different cities, stay safe everyone':
|
| 22 |
map = {'id': 2,
|
| 23 |
'keyword': '',
|
|
|
|
| 28 |
'token_type_ids': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
| 29 |
'attention_mask': [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]}
|
| 30 |
|
| 31 |
+
pred,pred_idx,probs = learn.predict(map)
|
| 32 |
+
|
| 33 |
+
return probs
|
| 34 |
if name == 'Theyd probably still show more life than Arsenal did yesterday, eh? EH?':
|
| 35 |
map = {'id': 21,
|
| 36 |
'keyword': '',
|
|
|
|
| 41 |
'token_type_ids': [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
|
| 42 |
'attention_mask': [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]}
|
| 43 |
|
| 44 |
+
pred,pred_idx,probs = learn.predict(map)
|
| 45 |
+
|
| 46 |
+
return probs
|
| 47 |
return
|
| 48 |
|
| 49 |
examples = [['Just happened a terrible car crash'],['Heard about #earthquake is different cities, stay safe everyone'], ['Theyd probably still show more life than Arsenal did yesterday, eh? EH?']]
|