JarrettYe commited on
Commit
52ef280
1 Parent(s): 3ee8078

Add application file

Browse files
Files changed (3) hide show
  1. .gitignore +4 -0
  2. app.py +27 -0
  3. requirements.txt +1 -0
.gitignore ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ .idea/
2
+ __pycache__
3
+ projects
4
+ .DS_Store
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fsrs_optimizer import Optimizer
3
+
4
+
5
+ def interface_func(weights: str, ratings: str, request_retention: float) -> str:
6
+ optimizer = Optimizer()
7
+ optimizer.w = list(map(lambda x: float(x.strip()), weights.split(',')))
8
+ test_sequence = optimizer.preview_sequence(
9
+ ratings.replace(' ', ''), request_retention)
10
+ default_preview = optimizer.preview(request_retention)
11
+ return test_sequence, default_preview
12
+
13
+
14
+ iface = gr.Interface(
15
+ fn=interface_func,
16
+ inputs=[
17
+ gr.inputs.Textbox(label="weights", lines=1,
18
+ default="0.4, 0.6, 2.4, 5.8, 4.93, 0.94, 0.86, 0.01, 1.49, 0.14, 0.94, 2.18, 0.05, 0.34, 1.26, 0.29, 2.61"),
19
+ gr.inputs.Textbox(label="ratings", lines=1, default="3,3,3,3,3,3,3"),
20
+ gr.inputs.Slider(label="Your Request Retention",
21
+ minimum=0.6, maximum=0.97, step=0.01, default=0.9)
22
+ ],
23
+ outputs=[gr.outputs.Textbox(label="test sequences"),
24
+ gr.outputs.Textbox(label="default preview")]
25
+ )
26
+
27
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ FSRS-Optimizer==4.12.0