Jasper Gilley commited on
Commit
b07085b
1 Parent(s): 3166be1
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import autokeras as ak
3
+ import numpy as np
4
+ from tensorflow.keras.models import load_model
5
+
6
+ loaded_model = load_model("text_model", custom_objects=ak.CUSTOM_OBJECTS)
7
+
8
+ def tweet_tester(tweet1, tweet2):
9
+ pred1 = loaded_model.predict(np.array([[tweet1]]))[0][0]
10
+ pred2 = loaded_model.predict(np.array([[tweet2]]))[0][0]
11
+ print(pred1, pred2)
12
+ diff_pct = (pred1 - pred2) / pred1 * 100
13
+ # truncate diff_pct to 2 decimal places
14
+ diff_pct = round(diff_pct, 3)
15
+ return diff_pct
16
+
17
+ interface = gr.Interface(
18
+ title="Tweet A/B Test",
19
+ description="Enter the text of two tweets you'd like to A/B test. The output number represents the percent difference in expected likes between the two tweets. If the number is positive, the second tweet is more likely to get more likes than the first tweet. If the number is negative, the first tweet is more likely to get more likes than the second tweet.",
20
+ fn=tweet_tester,
21
+ inputs=["text", "text"],
22
+ outputs=["number"]
23
+ )
24
+ interface.launch()