ilan541 commited on
Commit
12d4f28
·
1 Parent(s): 50435fc

created app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import tensorflow as tf
2
+ from transformers import AutoTokenizer, TFAutoModelForSequenceClassification
3
+ import gradio as gr
4
+ import numpy as np
5
+ from scipy.special import softmax
6
+ from sklearn import metrics
7
+ import matplotlib.pyplot as plt
8
+ from scipy.interpolate import interp1d
9
+ import pandas as pd
10
+
11
+ tokenizer = AutoTokenizer.from_pretrained('roberta-base')
12
+
13
+ from transformers import AutoModel
14
+ model = AutoModel.from_pretrained("ilan541/OncUponTim")
15
+
16
+ def predict(your_text):
17
+ df = split_text(text)
18
+ inp = tokenizer(your_text, return_tensors='tf')
19
+ if np.argmax(softmax(model(inp).logits)) == 0:
20
+ return 'This content is not of high standard. It needs editing. '
21
+ else:
22
+ return 'Promising content! Our algorithm predicts it will be very popular.'
23
+
24
+
25
+ ##### add possibility to play with the threshold
26
+
27
+ iface = gr.Interface(fn=predict, inputs="text", outputs="text")
28
+ iface.launch()