akhaliq HF Staff commited on
Commit
b7457e0
·
verified ·
1 Parent(s): 7f6d4c2

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. app.py +155 -112
  2. requirements.txt +10 -6
app.py CHANGED
@@ -13,9 +13,6 @@ pipe.to("cuda")
13
  @spaces.GPU(duration=120)
14
  def generate_image(
15
  prompt: str,
16
- negative_prompt: str,
17
- num_inference_steps: int,
18
- true_cfg_scale: float,
19
  progress=gr.Progress(track_tqdm=True)
20
  ):
21
  if not prompt.strip():
@@ -23,142 +20,176 @@ def generate_image(
23
 
24
  image = pipe(
25
  prompt=prompt,
26
- negative_prompt=negative_prompt if negative_prompt.strip() else "",
27
- num_inference_steps=int(num_inference_steps),
28
- true_cfg_scale=true_cfg_scale
29
  ).images[0]
30
 
31
  return image
32
 
33
- # Clean Apple-inspired CSS
34
  apple_css = """
35
- @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&display=swap');
36
 
37
  * {
38
- font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif !important;
39
  }
40
 
 
41
  .gradio-container {
42
- max-width: 900px !important;
43
  margin: 0 auto !important;
44
- background: #fbfbfd !important;
45
  }
46
 
 
47
  .main-header {
48
  text-align: center;
49
- padding: 48px 24px 32px;
50
  }
51
 
52
  .main-header h1 {
53
- font-size: 44px;
54
  font-weight: 600;
55
- color: #1d1d1f;
56
  margin: 0 0 8px 0;
57
- letter-spacing: -0.03em;
 
 
 
58
  }
59
 
60
  .main-header p {
61
  font-size: 17px;
62
- color: #86868b;
63
- margin: 0;
64
  font-weight: 400;
 
 
65
  }
66
 
67
- .main-header a {
68
- color: #0071e3;
69
- text-decoration: none;
 
 
 
70
  }
71
 
72
- .main-header a:hover {
73
- text-decoration: underline;
 
 
 
 
 
 
 
 
74
  }
75
 
76
- .card {
77
- background: #ffffff;
78
- border-radius: 16px;
79
- padding: 28px;
80
- box-shadow: 0 2px 12px rgba(0,0,0,0.04);
81
- border: 1px solid #e5e5e7;
82
  }
83
 
84
- textarea, input[type="text"] {
85
- background: #f5f5f7 !important;
 
86
  border: none !important;
87
- border-radius: 10px !important;
88
- padding: 14px 16px !important;
89
- font-size: 15px !important;
90
- color: #1d1d1f !important;
91
- transition: all 0.2s ease !important;
 
92
  }
93
 
94
- textarea:focus, input[type="text"]:focus {
95
- background: #ffffff !important;
96
- box-shadow: 0 0 0 3px rgba(0,113,227,0.2) !important;
97
  outline: none !important;
98
  }
99
 
100
- textarea::placeholder, input::placeholder {
101
- color: #86868b !important;
 
 
 
 
102
  }
103
 
 
 
 
 
 
104
  label span {
105
- font-size: 13px !important;
106
  font-weight: 500 !important;
107
- color: #1d1d1f !important;
108
  }
109
 
 
110
  button.primary {
111
- background: #0071e3 !important;
112
  color: white !important;
113
  border: none !important;
114
  border-radius: 980px !important;
115
- padding: 12px 28px !important;
116
- font-size: 15px !important;
117
  font-weight: 500 !important;
 
118
  cursor: pointer !important;
119
- transition: all 0.2s ease !important;
 
 
120
  }
121
 
122
  button.primary:hover {
123
- background: #0077ed !important;
124
- transform: scale(1.02);
125
  }
126
 
127
  button.primary:active {
128
- transform: scale(0.98);
129
  }
130
 
131
- .settings-section {
132
- background: #f5f5f7;
133
- border-radius: 12px;
134
- padding: 20px;
135
- margin-top: 16px;
 
136
  }
137
 
138
- input[type="range"] {
139
- accent-color: #0071e3 !important;
140
  }
141
 
142
- .output-image {
143
- border-radius: 12px;
144
- overflow: hidden;
145
- background: #f5f5f7;
146
- min-height: 400px;
147
  }
148
 
149
- .footer-text {
 
150
  text-align: center;
151
- padding: 24px;
152
  font-size: 13px;
153
- color: #86868b;
154
  }
155
 
156
- .footer-text a {
157
- color: #0071e3;
158
  text-decoration: none;
 
 
159
  }
160
 
161
- /* Hide unnecessary elements */
 
 
 
 
162
  .block.padded:not(.gradio-group) {
163
  padding: 0 !important;
164
  background: transparent !important;
@@ -166,21 +197,57 @@ input[type="range"] {
166
  box-shadow: none !important;
167
  }
168
 
169
- .gradio-accordion {
170
- border: none !important;
171
- background: transparent !important;
 
172
  }
173
 
174
- .gradio-accordion > .label-wrap {
175
- background: #f5f5f7 !important;
176
- border-radius: 10px !important;
177
- padding: 12px 16px !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
  }
179
  """
180
 
181
  with gr.Blocks(title="OVIS Image Generator") as demo:
182
 
183
- # Clean header
184
  gr.HTML("""
185
  <div class="main-header">
186
  <h1>OVIS Image</h1>
@@ -188,57 +255,33 @@ with gr.Blocks(title="OVIS Image Generator") as demo:
188
  </div>
189
  """)
190
 
191
- with gr.Column(elem_classes="card"):
 
192
  prompt = gr.Textbox(
193
- label="What do you want to create?",
194
- placeholder="A serene mountain landscape at sunset...",
195
  lines=3,
196
- show_label=True
 
197
  )
198
 
199
- with gr.Accordion("Advanced Settings", open=False):
200
- negative_prompt = gr.Textbox(
201
- label="Negative prompt",
202
- placeholder="Things to avoid...",
203
- lines=2
204
- )
205
-
206
- with gr.Row():
207
- num_steps = gr.Slider(
208
- label="Steps",
209
- minimum=10,
210
- maximum=100,
211
- value=50,
212
- step=5
213
- )
214
-
215
- cfg_scale = gr.Slider(
216
- label="CFG Scale",
217
- minimum=1.0,
218
- maximum=15.0,
219
- value=5.0,
220
- step=0.5
221
- )
222
-
223
  generate_btn = gr.Button(
224
  "Generate",
225
  variant="primary",
226
  size="lg"
227
  )
228
 
229
- gr.HTML("<div style='height: 16px'></div>")
230
-
231
- with gr.Column(elem_classes="card"):
232
  output_image = gr.Image(
233
- label="",
234
  type="pil",
235
- show_label=False,
236
- elem_classes="output-image"
237
  )
238
 
239
  # Footer
240
  gr.HTML("""
241
- <div class="footer-text">
242
  <a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank">Built with anycoder</a>
243
  </div>
244
  """)
@@ -246,14 +289,14 @@ with gr.Blocks(title="OVIS Image Generator") as demo:
246
  # Events
247
  generate_btn.click(
248
  fn=generate_image,
249
- inputs=[prompt, negative_prompt, num_steps, cfg_scale],
250
  outputs=output_image,
251
  api_visibility="public"
252
  )
253
 
254
  prompt.submit(
255
  fn=generate_image,
256
- inputs=[prompt, negative_prompt, num_steps, cfg_scale],
257
  outputs=output_image,
258
  api_visibility="public"
259
  )
 
13
  @spaces.GPU(duration=120)
14
  def generate_image(
15
  prompt: str,
 
 
 
16
  progress=gr.Progress(track_tqdm=True)
17
  ):
18
  if not prompt.strip():
 
20
 
21
  image = pipe(
22
  prompt=prompt,
23
+ negative_prompt="",
24
+ num_inference_steps=50,
25
+ true_cfg_scale=5.0
26
  ).images[0]
27
 
28
  return image
29
 
30
+ # Apple-inspired CSS that works for both light and dark mode
31
  apple_css = """
32
+ @import url('https://fonts.googleapis.com/css2?family=SF+Pro+Display:wght@300;400;500;600;700&family=SF+Pro+Text:wght@300;400;500;600&display=swap');
33
 
34
  * {
35
+ font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', sans-serif !important;
36
  }
37
 
38
+ /* Light mode styles */
39
  .gradio-container {
40
+ max-width: 700px !important;
41
  margin: 0 auto !important;
42
+ padding: 0 16px !important;
43
  }
44
 
45
+ /* Main header */
46
  .main-header {
47
  text-align: center;
48
+ padding: 40px 20px 32px;
49
  }
50
 
51
  .main-header h1 {
52
+ font-size: 40px;
53
  font-weight: 600;
54
+ letter-spacing: -0.025em;
55
  margin: 0 0 8px 0;
56
+ background: linear-gradient(135deg, #1d1d1f 0%, #424245 100%);
57
+ -webkit-background-clip: text;
58
+ -webkit-text-fill-color: transparent;
59
+ background-clip: text;
60
  }
61
 
62
  .main-header p {
63
  font-size: 17px;
 
 
64
  font-weight: 400;
65
+ margin: 0;
66
+ opacity: 0.7;
67
  }
68
 
69
+ /* Dark mode header */
70
+ .dark .main-header h1 {
71
+ background: linear-gradient(135deg, #f5f5f7 0%, #a1a1a6 100%);
72
+ -webkit-background-clip: text;
73
+ -webkit-text-fill-color: transparent;
74
+ background-clip: text;
75
  }
76
 
77
+ /* Card styling */
78
+ .card-container {
79
+ border-radius: 20px;
80
+ padding: 24px;
81
+ margin-bottom: 16px;
82
+ background: rgba(255, 255, 255, 0.8);
83
+ backdrop-filter: blur(20px);
84
+ -webkit-backdrop-filter: blur(20px);
85
+ border: 1px solid rgba(0, 0, 0, 0.08);
86
+ box-shadow: 0 4px 24px rgba(0, 0, 0, 0.04);
87
  }
88
 
89
+ .dark .card-container {
90
+ background: rgba(30, 30, 32, 0.8);
91
+ border: 1px solid rgba(255, 255, 255, 0.08);
92
+ box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
 
 
93
  }
94
 
95
+ /* Textbox styling */
96
+ textarea {
97
+ background: rgba(142, 142, 147, 0.12) !important;
98
  border: none !important;
99
+ border-radius: 12px !important;
100
+ padding: 16px !important;
101
+ font-size: 16px !important;
102
+ line-height: 1.5 !important;
103
+ transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
104
+ resize: none !important;
105
  }
106
 
107
+ textarea:focus {
108
+ background: rgba(142, 142, 147, 0.18) !important;
109
+ box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.15) !important;
110
  outline: none !important;
111
  }
112
 
113
+ textarea::placeholder {
114
+ opacity: 0.5 !important;
115
+ }
116
+
117
+ .dark textarea {
118
+ background: rgba(142, 142, 147, 0.16) !important;
119
  }
120
 
121
+ .dark textarea:focus {
122
+ background: rgba(142, 142, 147, 0.24) !important;
123
+ }
124
+
125
+ /* Label styling */
126
  label span {
127
+ font-size: 14px !important;
128
  font-weight: 500 !important;
129
+ letter-spacing: -0.01em !important;
130
  }
131
 
132
+ /* Button styling */
133
  button.primary {
134
+ background: linear-gradient(180deg, #0a84ff 0%, #0077ed 100%) !important;
135
  color: white !important;
136
  border: none !important;
137
  border-radius: 980px !important;
138
+ padding: 14px 32px !important;
139
+ font-size: 17px !important;
140
  font-weight: 500 !important;
141
+ letter-spacing: -0.01em !important;
142
  cursor: pointer !important;
143
+ transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
144
+ box-shadow: 0 2px 8px rgba(10, 132, 255, 0.3) !important;
145
+ min-height: 50px !important;
146
  }
147
 
148
  button.primary:hover {
149
+ transform: scale(1.02) !important;
150
+ box-shadow: 0 4px 16px rgba(10, 132, 255, 0.4) !important;
151
  }
152
 
153
  button.primary:active {
154
+ transform: scale(0.98) !important;
155
  }
156
 
157
+ /* Output image styling */
158
+ .output-container {
159
+ border-radius: 20px;
160
+ overflow: hidden;
161
+ background: rgba(142, 142, 147, 0.08);
162
+ min-height: 300px;
163
  }
164
 
165
+ .dark .output-container {
166
+ background: rgba(142, 142, 147, 0.12);
167
  }
168
 
169
+ /* Image container */
170
+ .output-container img {
171
+ border-radius: 16px;
 
 
172
  }
173
 
174
+ /* Footer styling */
175
+ .footer-link {
176
  text-align: center;
177
+ padding: 24px 0;
178
  font-size: 13px;
 
179
  }
180
 
181
+ .footer-link a {
182
+ color: #0a84ff;
183
  text-decoration: none;
184
+ font-weight: 500;
185
+ transition: opacity 0.2s;
186
  }
187
 
188
+ .footer-link a:hover {
189
+ opacity: 0.7;
190
+ }
191
+
192
+ /* Remove default Gradio styling */
193
  .block.padded:not(.gradio-group) {
194
  padding: 0 !important;
195
  background: transparent !important;
 
197
  box-shadow: none !important;
198
  }
199
 
200
+ /* Progress bar styling */
201
+ .progress-bar {
202
+ background: linear-gradient(90deg, #0a84ff, #5ac8fa) !important;
203
+ border-radius: 4px !important;
204
  }
205
 
206
+ /* Mobile responsive */
207
+ @media (max-width: 640px) {
208
+ .gradio-container {
209
+ padding: 0 12px !important;
210
+ }
211
+
212
+ .main-header {
213
+ padding: 32px 16px 24px;
214
+ }
215
+
216
+ .main-header h1 {
217
+ font-size: 32px;
218
+ }
219
+
220
+ .main-header p {
221
+ font-size: 15px;
222
+ }
223
+
224
+ .card-container {
225
+ padding: 20px;
226
+ border-radius: 16px;
227
+ }
228
+
229
+ button.primary {
230
+ width: 100% !important;
231
+ padding: 16px 24px !important;
232
+ }
233
+
234
+ textarea {
235
+ font-size: 16px !important;
236
+ }
237
+ }
238
+
239
+ /* Smooth transitions for dark mode */
240
+ .gradio-container,
241
+ .card-container,
242
+ textarea,
243
+ button {
244
+ transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease !important;
245
  }
246
  """
247
 
248
  with gr.Blocks(title="OVIS Image Generator") as demo:
249
 
250
+ # Header
251
  gr.HTML("""
252
  <div class="main-header">
253
  <h1>OVIS Image</h1>
 
255
  </div>
256
  """)
257
 
258
+ # Input card
259
+ with gr.Column(elem_classes="card-container"):
260
  prompt = gr.Textbox(
261
+ label="Describe your image",
262
+ placeholder="A serene mountain landscape at golden hour with snow-capped peaks...",
263
  lines=3,
264
+ show_label=True,
265
+ max_lines=5
266
  )
267
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
268
  generate_btn = gr.Button(
269
  "Generate",
270
  variant="primary",
271
  size="lg"
272
  )
273
 
274
+ # Output card
275
+ with gr.Column(elem_classes="card-container output-container"):
 
276
  output_image = gr.Image(
277
+ label="Generated Image",
278
  type="pil",
279
+ show_label=False
 
280
  )
281
 
282
  # Footer
283
  gr.HTML("""
284
+ <div class="footer-link">
285
  <a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank">Built with anycoder</a>
286
  </div>
287
  """)
 
289
  # Events
290
  generate_btn.click(
291
  fn=generate_image,
292
+ inputs=[prompt],
293
  outputs=output_image,
294
  api_visibility="public"
295
  )
296
 
297
  prompt.submit(
298
  fn=generate_image,
299
+ inputs=[prompt],
300
  outputs=output_image,
301
  api_visibility="public"
302
  )
requirements.txt CHANGED
@@ -1,13 +1,17 @@
1
  spaces
2
- git+https://github.com/DoctorKey/diffusers.git@ovis-image
 
 
3
  git+https://github.com/huggingface/transformers
4
  sentencepiece
5
  accelerate
6
- torch
7
- torchvision
8
- torchaudio
9
  tokenizers
10
  datasets
11
- gradio
12
  requests
13
- Pillow
 
 
 
 
 
 
 
1
  spaces
2
+ gradio
3
+ git+https://github.com/huggingface/diffusers
4
+ torch
5
  git+https://github.com/huggingface/transformers
6
  sentencepiece
7
  accelerate
 
 
 
8
  tokenizers
9
  datasets
 
10
  requests
11
+ Pillow
12
+ torchvision
13
+ torchaudio
14
+ numpy
15
+ scipy
16
+ opencv-python
17
+ matplotlib