Mudditha commited on
Commit
365a4d0
·
verified ·
1 Parent(s): ae7e299

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +124 -95
app.py CHANGED
@@ -34,6 +34,7 @@ don't include '.com' in outputs and give different names.
34
  {}"""
35
 
36
 
 
37
  def print_output(input):
38
  inputs = tokenizer(
39
  [
@@ -46,102 +47,130 @@ def print_output(input):
46
  # outputs = model.generate(**inputs, max_new_tokens = 64, use_cache = True)
47
  # tokenizer.batch_decode(outputs)
48
 
49
- outputs = model.generate(**inputs, max_new_tokens = 200, use_cache = True, temperature=0.5)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
- n1 = tokenizer.batch_decode(outputs)[0].index('### Response:')
52
- output_ = tokenizer.batch_decode(outputs)[0][n1+13:].replace('.com','')
53
- n2 = output_.index('\n\n')
54
 
55
- dom_names = []
56
 
57
- for name in output_[:n2].split('\n'):
58
- if name != '':
59
- dom_names.append(name.split('.')[1])
60
 
61
- s = '\n'.join(dom_names)
62
-
63
- return tokenizer.batch_decode(s)
64
-
65
-
66
- # # Streamlit app UI
67
- # st.title("Echo Input Example")
68
-
69
- # # Text box for user input
70
- # user_input = st.text_input("Type something here:")
71
-
72
- # # Button to submit input
73
- # if st.button("Submit"):
74
- # # Reprint the user input
75
- # st.write(f"You typed: {print_output(user_input)}")
76
-
77
-
78
- def main():
79
-
80
- css_dark_mode = """
81
- <style>
82
- body {
83
- background-color: #121212;
84
- color: #f8f9fa;
85
- font-family: Arial, sans-serif;
86
- }
87
- .header {
88
- background: linear-gradient(90deg, #005c97, #363795);
89
- padding: 15px;
90
- margin-bottom: 15px;
91
- border-radius: 10px;
92
- box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2);
93
- text-align: center;
94
- }
95
- .header h1 {
96
- color: #ffffff;
97
- font-size: 36px;
98
- }
99
- .header h2 {
100
- color: #b0b0b0;
101
- font-size: 22px;
102
- font-family: Georgia, serif;
103
- }
104
- .stButton > button {
105
- background-color: #20c997;
106
- color: #ffffff;
107
- border: none;
108
- border-radius: 8px;
109
- padding: 10px 20px;
110
- font-size: 16px;
111
- cursor: pointer;
112
- transition: background-color 0.3s;
113
- }
114
- .stButton > button:hover {
115
- background-color: #17a589;
116
- }
117
- .success-box {
118
- background-color: #A1D6CB;
119
- padding: 10px;
120
- margin: 10px 0;
121
- border-radius: 8px;
122
- box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2);
123
- }
124
- </style>
125
- """
126
- # Inject the custom CSS
127
- st.markdown(css_dark_mode, unsafe_allow_html=True)
128
-
129
- # Header Section
130
- html_temp = """
131
- <div class="header">
132
- <h1>Dominious</h1>
133
- <h2>AI Based Domain Name Suggestion System</h2>
134
- </div>
135
- """
136
- st.markdown(html_temp, unsafe_allow_html=True)
137
- # st.title("Domain Name Suggestion System")
138
-
139
- # Get user input
140
- user_input = st.text_input("Describe your business here...")
141
-
142
- # Generate the response
143
- if st.button("Generate"):
144
- with st.spinner("Generating Domain Names..."):
145
- result = print_output(user_input)
146
- if __name__ == "__main__":
147
- main()
 
34
  {}"""
35
 
36
 
37
+
38
  def print_output(input):
39
  inputs = tokenizer(
40
  [
 
47
  # outputs = model.generate(**inputs, max_new_tokens = 64, use_cache = True)
48
  # tokenizer.batch_decode(outputs)
49
 
50
+ outputs = model.generate(**inputs, max_new_tokens = 100, use_cache = True)
51
+ return tokenizer.batch_decode(outputs)
52
+
53
+
54
+ # Streamlit app UI
55
+ st.title("Echo Input Example")
56
+
57
+ # Text box for user input
58
+ user_input = st.text_input("Type something here:")
59
+
60
+ # Button to submit input
61
+ if st.button("Submit"):
62
+ # Reprint the user input
63
+ st.write(f"You typed: {print_output(user_input)}")
64
+
65
+
66
+ # def print_output(input):
67
+ # inputs = tokenizer(
68
+ # [
69
+ # inf_prompt_1.format(
70
+ # input, # instruction
71
+ # "", # output - leave this blank for generation!
72
+ # ),
73
+ # ], return_tensors = "pt").to("cuda")
74
+
75
+ # # outputs = model.generate(**inputs, max_new_tokens = 64, use_cache = True)
76
+ # # tokenizer.batch_decode(outputs)
77
+
78
+ # outputs = model.generate(**inputs, max_new_tokens = 200, use_cache = True, temperature=0.5)
79
 
80
+ # n1 = tokenizer.batch_decode(outputs)[0].index('### Response:')
81
+ # output_ = tokenizer.batch_decode(outputs)[0][n1+13:].replace('.com','')
82
+ # n2 = output_.index('\n\n')
83
 
84
+ # dom_names = []
85
 
86
+ # for name in output_[:n2].split('\n'):
87
+ # if name != '':
88
+ # dom_names.append(name.split('.')[1])
89
 
90
+ # s = '\n'.join(dom_names)
91
+
92
+ # return tokenizer.batch_decode(s)
93
+
94
+
95
+ # # # Streamlit app UI
96
+ # # st.title("Echo Input Example")
97
+
98
+ # # # Text box for user input
99
+ # # user_input = st.text_input("Type something here:")
100
+
101
+ # # # Button to submit input
102
+ # # if st.button("Submit"):
103
+ # # # Reprint the user input
104
+ # # st.write(f"You typed: {print_output(user_input)}")
105
+
106
+
107
+ # def main():
108
+
109
+ # css_dark_mode = """
110
+ # <style>
111
+ # body {
112
+ # background-color: #121212;
113
+ # color: #f8f9fa;
114
+ # font-family: Arial, sans-serif;
115
+ # }
116
+ # .header {
117
+ # background: linear-gradient(90deg, #005c97, #363795);
118
+ # padding: 15px;
119
+ # margin-bottom: 15px;
120
+ # border-radius: 10px;
121
+ # box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2);
122
+ # text-align: center;
123
+ # }
124
+ # .header h1 {
125
+ # color: #ffffff;
126
+ # font-size: 36px;
127
+ # }
128
+ # .header h2 {
129
+ # color: #b0b0b0;
130
+ # font-size: 22px;
131
+ # font-family: Georgia, serif;
132
+ # }
133
+ # .stButton > button {
134
+ # background-color: #20c997;
135
+ # color: #ffffff;
136
+ # border: none;
137
+ # border-radius: 8px;
138
+ # padding: 10px 20px;
139
+ # font-size: 16px;
140
+ # cursor: pointer;
141
+ # transition: background-color 0.3s;
142
+ # }
143
+ # .stButton > button:hover {
144
+ # background-color: #17a589;
145
+ # }
146
+ # .success-box {
147
+ # background-color: #A1D6CB;
148
+ # padding: 10px;
149
+ # margin: 10px 0;
150
+ # border-radius: 8px;
151
+ # box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2);
152
+ # }
153
+ # </style>
154
+ # """
155
+ # # Inject the custom CSS
156
+ # st.markdown(css_dark_mode, unsafe_allow_html=True)
157
+
158
+ # # Header Section
159
+ # html_temp = """
160
+ # <div class="header">
161
+ # <h1>Dominious</h1>
162
+ # <h2>AI Based Domain Name Suggestion System</h2>
163
+ # </div>
164
+ # """
165
+ # st.markdown(html_temp, unsafe_allow_html=True)
166
+ # # st.title("Domain Name Suggestion System")
167
+
168
+ # # Get user input
169
+ # user_input = st.text_input("Describe your business here...")
170
+
171
+ # # Generate the response
172
+ # if st.button("Generate"):
173
+ # with st.spinner("Generating Domain Names..."):
174
+ # result = print_output(user_input)
175
+ # if __name__ == "__main__":
176
+ # main()