jeffeux commited on
Commit
8e44aac
1 Parent(s): 30f0864
Files changed (1) hide show
  1. main.py +25 -23
main.py CHANGED
@@ -43,29 +43,31 @@ def model_init():
43
  logging.info(C("[INFO] "f"Model init success!"))
44
  return tokenizer, model
45
 
46
- tokenizer, model = model_init()
47
- st.balloons()
48
 
49
- try:
50
- # ===================== INPUT ====================== #
51
- # prompt = "\u554F\uFF1A\u53F0\u7063\u6700\u9AD8\u7684\u5EFA\u7BC9\u7269\u662F\uFF1F\u7B54\uFF1A" #@param {type:"string"}
52
- prompt = st.text_input("Prompt: ")
53
- st.balloons()
54
 
55
 
56
- # =================== INFERENCE ==================== #
57
- if prompt:
58
- st.balloons()
59
- with torch.no_grad():
60
- [texts_out] = model.generate(
61
- **tokenizer(
62
- prompt, return_tensors="pt"
63
- ).to(device))
64
- st.balloons()
65
- output_text = tokenizer.decode(texts_out)
66
- st.balloons()
67
- st.markdown(output_text)
68
- st.balloons()
69
- except Exception as err:
70
- st.write(str(err))
71
- st.snow()
 
 
 
43
  logging.info(C("[INFO] "f"Model init success!"))
44
  return tokenizer, model
45
 
46
+ # tokenizer, model = model_init()
47
+ # st.balloons()
48
 
49
+ # try:
50
+ # # ===================== INPUT ====================== #
51
+ # # prompt = "\u554F\uFF1A\u53F0\u7063\u6700\u9AD8\u7684\u5EFA\u7BC9\u7269\u662F\uFF1F\u7B54\uFF1A" #@param {type:"string"}
52
+ # prompt = st.text_input("Prompt: ")
53
+ # st.balloons()
54
 
55
 
56
+ # # =================== INFERENCE ==================== #
57
+ # if prompt:
58
+ # st.balloons()
59
+ # with torch.no_grad():
60
+ # [texts_out] = model.generate(
61
+ # **tokenizer(
62
+ # prompt, return_tensors="pt"
63
+ # ).to(device))
64
+ # st.balloons()
65
+ # output_text = tokenizer.decode(texts_out)
66
+ # st.balloons()
67
+ # st.markdown(output_text)
68
+ # st.balloons()
69
+ # except Exception as err:
70
+ # st.write(str(err))
71
+ # st.snow()
72
+
73
+ st.snow()