YDluffy commited on
Commit
2db7de7
·
verified ·
1 Parent(s): c8ee001

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -14
app.py CHANGED
@@ -1,20 +1,30 @@
1
  import gradio as gr
2
  import joblib
 
 
3
 
4
- # 加载训练好的模型
5
- model = joblib.load("lottery_predictor_model.pkl")
 
6
 
7
- # 定义预测函数
8
- def predict(lottery_period, date):
9
- # 将期号和日期转化为模型需要的特征
10
- features = [[lottery_period, date]] # 转换为二维数组
11
- prediction = model.predict(features) # 使用模型进行预测
12
- return f"Predicted numbers: {prediction}"
13
 
14
- # 创建 Gradio 接口
15
- interface = gr.Interface(fn=predict,
16
- inputs=[gr.Textbox(label="Lottery Period"), gr.Textbox(label="Date")],
17
- outputs="text")
 
 
 
 
 
 
 
 
 
18
 
19
- # 启动界面
20
- interface.launch()
 
1
  import gradio as gr
2
  import joblib
3
+ from huggingface_hub import hf_hub_download
4
+ import numpy as np
5
 
6
+ # 从 Hugging Face 下载模型
7
+ model_path = hf_hub_download(repo_id="YDluffy/lottery_predictor_model", filename="lottery_predictor_model.pkl")
8
+ model = joblib.load(model_path)
9
 
10
+ # 预测函数
11
+ def predict_lottery(year, period, num1, num2, num3, num4, num5, num6, special):
12
+ features = np.array([[year, period, num1, num2, num3, num4, num5, num6, special]])
13
+ prediction = model.predict(features)
14
+ return prediction
 
15
 
16
+ # Gradio Web 界面
17
+ iface = gr.Interface(
18
+ fn=predict_lottery,
19
+ inputs=[
20
+ gr.Number(label="年份"), gr.Number(label="期数"),
21
+ gr.Number(label="号码1"), gr.Number(label="号码2"), gr.Number(label="号码3"),
22
+ gr.Number(label="号码4"), gr.Number(label="号码5"), gr.Number(label="号码6"),
23
+ gr.Number(label="特别号码")
24
+ ],
25
+ outputs="text",
26
+ title="六合彩预测模型",
27
+ description="输入期号和历史开奖号码,预测下一期开奖"
28
+ )
29
 
30
+ iface.launch()