LAJILAODEEAIQ commited on
Commit
44b321e
·
verified ·
1 Parent(s): 4650402

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +203 -28
app.py CHANGED
@@ -1,52 +1,227 @@
1
  import gradio as gr
2
 
 
 
 
 
 
 
3
 
 
4
  model1 = gr.load("models/Jonny001/NSFW_master")
5
  model2 = gr.load("models/Jonny001/Alita-v1")
6
  model3 = gr.load("models/Jonny001/WBMH-v1.1")
7
- model4 = gr.load("models/Keltezaa/flux_pussy_NSFW")
8
  model5 = gr.load("models/prashanth970/flux-lora-uncensored")
9
 
 
 
 
 
 
10
  def generate_images(text, selected_model):
11
- if selected_model == "Model 1 (NSFW Master)":
12
  model = model1
13
- elif selected_model == "Model 2 (Alita)":
14
  model = model2
15
- elif selected_model == "Model 3 (WBMH-v1.1)":
16
  model = model3
17
- elif selected_model == "Model 4 (Flux NSFW)":
18
- model = model4
19
- elif selected_model == "Model 5 (Lora Uncensored)":
20
  model = model5
21
  else:
22
- return "Invalid model selection."
23
 
24
  results = []
25
  for i in range(3):
26
- modified_text = f"{text} variation {i+1}"
27
  result = model(modified_text)
28
  results.append(result)
29
 
30
  return results
31
 
32
- interface = gr.Interface(
33
- fn=generate_images,
34
- inputs=[
35
- gr.Textbox(label="Type here your imagination:", placeholder="Type your prompt..."),
36
- gr.Radio(
37
- ["Model 1 (NSFW Master)", "Model 2 (Alita)", "Model 3 (WBMH-v1.1)", "Model 4 (Flux NSFW)", "Model 5 (Lora Uncensored)"],
38
- label="Select Model (Try All Models & Get Different Results)",
39
- value="Model 1 (NSFW Master)",
40
- ),
41
- ],
42
- outputs=[
43
- gr.Image(label="Generated Image 1"),
44
- gr.Image(label="Generated Image 2"),
45
- gr.Image(label="Generated Image 3"),
46
- ],
47
- theme="Yntec/HaleyCH_Theme_Orange",
48
- description="⚠ Sorry for the inconvenience. The space are currently running on the CPU, which might affect performance. We appreciate your understanding.",
49
- cache_examples=False,
50
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
 
52
  interface.launch()
 
1
  import gradio as gr
2
 
3
+ # Hardcoded credentials
4
+ VALID_CREDENTIALS = {
5
+ "admin": "officechat888",
6
+ "vip": "vip888",
7
+ "user": "user888"
8
+ }
9
 
10
+ # Models loading code remains the same
11
  model1 = gr.load("models/Jonny001/NSFW_master")
12
  model2 = gr.load("models/Jonny001/Alita-v1")
13
  model3 = gr.load("models/Jonny001/WBMH-v1.1")
 
14
  model5 = gr.load("models/prashanth970/flux-lora-uncensored")
15
 
16
+ def check_login(username, password):
17
+ if username in VALID_CREDENTIALS and VALID_CREDENTIALS[username] == password:
18
+ return True
19
+ return False
20
+
21
  def generate_images(text, selected_model):
22
+ if selected_model == "模型1 (NSFW Master)":
23
  model = model1
24
+ elif selected_model == "模型2 (Alita)":
25
  model = model2
26
+ elif selected_model == "模型3 (WBMH-v1.1)":
27
  model = model3
28
+ elif selected_model == "模型5 (Lora Uncensored)":
 
 
29
  model = model5
30
  else:
31
+ return "无效的模型选择。"
32
 
33
  results = []
34
  for i in range(3):
35
+ modified_text = f"{text} 变体 {i+1}"
36
  result = model(modified_text)
37
  results.append(result)
38
 
39
  return results
40
 
41
+ custom_css = """
42
+ /* Login page styles */
43
+ .login-container {
44
+ max-width: 400px !important;
45
+ margin: 100px auto !important;
46
+ padding: 30px !important;
47
+ background: #ffffff !important;
48
+ border-radius: 15px !important;
49
+ box-shadow: 0 4px 20px rgba(0,0,0,0.1) !important;
50
+ }
51
+
52
+ .login-title {
53
+ text-align: center !important;
54
+ font-size: 24px !important;
55
+ color: #333 !important;
56
+ margin-bottom: 30px !important;
57
+ }
58
+
59
+ .login-button {
60
+ background: #4a90e2 !important;
61
+ width: 100% !important;
62
+ margin-top: 20px !important;
63
+ }
64
+
65
+ /* Main interface styles */
66
+ .gradio-container {
67
+ max-width: 1200px !important;
68
+ margin: 0 auto !important;
69
+ padding: 20px !important;
70
+ }
71
+
72
+ .control-panel {
73
+ background: #ffffff !important;
74
+ padding: 30px;
75
+ border-radius: 15px;
76
+ box-shadow: 0 2px 10px rgba(0,0,0,0.05);
77
+ margin-bottom: 30px;
78
+ border: 1px solid #e1e4e8 !important;
79
+ }
80
+
81
+ .title {
82
+ font-size: 18px !important;
83
+ margin-bottom: 25px !important;
84
+ text-align: center !important;
85
+ font-weight: bold !important;
86
+ color: #24292e !important;
87
+ background: #ffffff !important;
88
+ padding: 15px !important;
89
+ border-radius: 10px !important;
90
+ border: 1px solid #e1e4e8 !important;
91
+ }
92
+
93
+ .input-area {
94
+ display: flex;
95
+ gap: 20px;
96
+ align-items: flex-start;
97
+ }
98
+
99
+ .gradio-button {
100
+ background: #4a90e2 !important;
101
+ color: white !important;
102
+ padding: 12px 30px !important;
103
+ border-radius: 8px !important;
104
+ border: none !important;
105
+ cursor: pointer !important;
106
+ transition: all 0.3s !important;
107
+ font-size: 16px !important;
108
+ }
109
+
110
+ .results-panel {
111
+ display: flex;
112
+ flex-direction: column;
113
+ gap: 30px;
114
+ }
115
+
116
+ .gradio-image {
117
+ background: #ffffff !important;
118
+ padding: 15px !important;
119
+ border-radius: 15px !important;
120
+ box-shadow: 0 3px 15px rgba(0,0,0,0.1) !important;
121
+ min-height: 400px !important;
122
+ width: 100% !important;
123
+ border: 1px solid #e1e4e8 !important;
124
+ }
125
+
126
+ .gradio-image img {
127
+ width: 100% !important;
128
+ height: auto !important;
129
+ min-height: 400px !important;
130
+ object-fit: contain !important;
131
+ }
132
+
133
+ /* Dark mode styles */
134
+ @media (prefers-color-scheme: dark) {
135
+ body {
136
+ background: #0d1117 !important;
137
+ }
138
+
139
+ .login-container, .control-panel, .gradio-image {
140
+ background: #161b22 !important;
141
+ border: 1px solid #30363d !important;
142
+ }
143
+
144
+ .login-title, .title {
145
+ color: #c9d1d9 !important;
146
+ background: #161b22 !important;
147
+ border: 1px solid #30363d !important;
148
+ }
149
+
150
+ label, input, textarea {
151
+ color: #c9d1d9 !important;
152
+ }
153
+
154
+ input, textarea {
155
+ background: #0d1117 !important;
156
+ border: 1px solid #30363d !important;
157
+ }
158
+ }
159
+ """
160
+
161
+ with gr.Blocks(css=custom_css) as interface:
162
+ # Login state
163
+ logged_in = gr.State(False)
164
+
165
+ # Login page
166
+ with gr.Column(visible=True) as login_page:
167
+ with gr.Column(elem_classes=["login-container"]):
168
+ gr.Markdown("### Office Chat VIP登录", elem_classes=["login-title"])
169
+ username = gr.Textbox(label="用户名", placeholder="请输入用户名...")
170
+ password = gr.Textbox(label="密码", placeholder="请输入密码...", type="password")
171
+ login_button = gr.Button("登录", elem_classes=["login-button"])
172
+ login_status = gr.Markdown("")
173
+
174
+ # Main interface
175
+ with gr.Column(visible=False) as main_interface:
176
+ with gr.Column(elem_classes=["control-panel"]):
177
+ gr.Markdown(
178
+ "### 本程序专为Office chat 超级VIP使用用户免费使用。因为免费,可能会比较慢,感谢您的理解。感谢您选择Office chat。",
179
+ elem_classes=["title"]
180
+ )
181
+ with gr.Row(elem_classes=["input-area"]):
182
+ text_input = gr.Textbox(
183
+ label="在这里输入你的想象(英文):",
184
+ placeholder="输入你的提示...",
185
+ scale=1
186
+ )
187
+ model_selection = gr.Radio(
188
+ ["模型1 (NSFW Master)", "模型2 (Alita)", "模型3 (WBMH-v1.1)",
189
+ "模型5 (Lora Uncensored)"],
190
+ label="选择模型(尝试所有模型并获得不同结果)",
191
+ value="模型1 (NSFW Master)",
192
+ scale=2
193
+ )
194
+ generate_button = gr.Button("生成图片")
195
+
196
+ with gr.Column(elem_classes=["results-panel"]):
197
+ image1 = gr.Image(label="生成的图片1")
198
+ image2 = gr.Image(label="生成的图片2")
199
+ image3 = gr.Image(label="生成的图片3")
200
+
201
+ def login(username, password):
202
+ if check_login(username, password):
203
+ return {
204
+ login_page: gr.update(visible=False),
205
+ main_interface: gr.update(visible=True),
206
+ login_status: ""
207
+ }
208
+ else:
209
+ return {
210
+ login_page: gr.update(visible=True),
211
+ main_interface: gr.update(visible=False),
212
+ login_status: "用户名或密码错误!"
213
+ }
214
+
215
+ login_button.click(
216
+ login,
217
+ inputs=[username, password],
218
+ outputs=[login_page, main_interface, login_status]
219
+ )
220
+
221
+ generate_button.click(
222
+ fn=generate_images,
223
+ inputs=[text_input, model_selection],
224
+ outputs=[image1, image2, image3]
225
+ )
226
 
227
  interface.launch()