Wizz13150 commited on
Commit
d07afa3
·
1 Parent(s): 496d3bc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +320 -10
app.py CHANGED
@@ -1,7 +1,8 @@
1
  import gradio as gr
 
2
  from llama_cpp import Llama
3
 
4
- # Charger le modèle GGUF (Q8_0)
5
  llm = Llama(
6
  model_path="model/WizzGPTv7-q8_0.gguf",
7
  n_threads=1,
@@ -10,14 +11,323 @@ llm = Llama(
10
  use_mlock=True
11
  )
12
 
13
- def generate(prompt):
14
- output = llm(prompt, max_tokens=200, stop=["</s>"], echo=False)
15
- return output["choices"][0]["text"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
- # UI Gradio
18
- iface = gr.Interface(fn=generate,
19
- inputs=gr.Textbox(lines=5, label="Prompt"),
20
- outputs=gr.Textbox(label="Answer"),
21
- title="WizzGPTv7 - CPU Demo")
 
 
 
22
 
23
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ import random
3
  from llama_cpp import Llama
4
 
5
+ # Charger le modèle
6
  llm = Llama(
7
  model_path="model/WizzGPTv7-q8_0.gguf",
8
  n_threads=1,
 
11
  use_mlock=True
12
  )
13
 
14
+ # Liste complète des débuts de prompt
15
+ prompt_list = [
16
+ "A beautiful sunset over",
17
+ "A macro shot of",
18
+ "Award winning photography of",
19
+ "Wide shot of",
20
+ "The intricate details of",
21
+ "The portrait of a",
22
+ "A resin figurine of",
23
+ "Painting of",
24
+ "A delicate ",
25
+ "A rustic ",
26
+ "A stunningly beautiful",
27
+ "Masterpiece, best quality",
28
+ "Hyperrealistic shot of a",
29
+ "Professional fashion shot of",
30
+ "Photo of a classy",
31
+ "Photo of a glamour",
32
+ "(Horror) shot of",
33
+ "Cinematic film still of",
34
+ "A (monochrome:2) photography of",
35
+ "A ",
36
+ "Masterpiece, best quality, ultra-detailed, ",
37
+ "A hyper-realistic, cinematic shot of ",
38
+ "An incredibly detailed, high-resolution portrait of ",
39
+ "A breathtaking, photorealistic capture of ",
40
+ "A vivid, intricately detailed scene of ",
41
+ "A surreal, ultra-detailed rendering of ",
42
+ "An exquisitely detailed, cinematic masterpiece of ",
43
+ "A mesmerizing, hyper-detailed view of ",
44
+ "A stunning, ultra-realistic depiction of ",
45
+ "A visually arresting, high-definition snapshot of ",
46
+ "The ",
47
+ "The (hologram) of",
48
+ "A surrealist art of",
49
+ "The (photography of a __animal__:2), (full-body), ",
50
+ "The (photo of a (__animal__:__animal__:__weight__) hybrid), full-body,",
51
+ "A photo of an Eldritch abomination,",
52
+ "A (3D geometrically printed figurine) of",
53
+ "An overwhelmingly beautiful",
54
+ "An (eerie scene) featuring",
55
+ "A serene landscape showcasing",
56
+ "A photography of a magnificent ",
57
+ "A bokeh effect background with ",
58
+ "The bustling streets of",
59
+ "A whimsical depiction of",
60
+ "A dramatic aerial view of",
61
+ "An enchanting tableau presenting",
62
+ "The ancient ruins of",
63
+ "A night sky filled with",
64
+ "A macro close-up portrait of",
65
+ "An (abstract composition) with",
66
+ "A snowy scene with",
67
+ "The golden hour lighting up",
68
+ "A mystical forest where",
69
+ "A futuristic cityscape with",
70
+ "An ethereal ",
71
+ "A whimsical",
72
+ "Photo of an amazingly beautiful creature with",
73
+ "Photo of an iridescent ",
74
+ "Focus on ",
75
+ "A meticulously crafted",
76
+ "A dramatic chiaroscuro lighting of",
77
+ "An artistic interpretation of",
78
+ "A vivid depiction of",
79
+ "A serene moment captured in",
80
+ "A richly textured",
81
+ "An evocative scene portraying",
82
+ "An epic panorama of",
83
+ "An iconic representation of",
84
+ "A minimalist composition featuring",
85
+ "An avant-garde portrayal of",
86
+ "An immersive diorama of",
87
+ "A time-lapse sequence showing",
88
+ "A haunting silhouette against",
89
+ "An ancient mythological scene in",
90
+ "A contemporary reimagining of",
91
+ "A hyper-detailed rendering of",
92
+ "A nostalgic memory preserved in",
93
+ "A powerful juxtaposition of",
94
+ "A seamless blend of",
95
+ "A surreal",
96
+ "An evocative interplay of light and shadow",
97
+ "A preserved fragment of",
98
+ "An intricate lacework of",
99
+ "An offbeat take on",
100
+ "A reflective surface capturing",
101
+ "A slow-motion capture of",
102
+ "A stunning vista showcasing",
103
+ "A timeless black-and-white portrait of",
104
+ "A twisted version of",
105
+ "A dynamic motion blur effect in",
106
+ "A geometric pattern inspired by",
107
+ "A moody fog enveloping",
108
+ "A textured overlay on",
109
+ "A vibrant explosion of color",
110
+ "A carefully orchestrated symmetry in",
111
+ "A kaleidoscopic arrangement of",
112
+ "A subtle gradation of color in",
113
+ "The raw grandeur of",
114
+ "A whirlwind of movement in",
115
+ "A conceptual representation of",
116
+ "An experimental take on",
117
+ "A harmonious blend of",
118
+ "A poetic rendering of",
119
+ "An organic flow of",
120
+ "An understated elegance in",
121
+ "An unassuming grace in",
122
+ "A dynamic shift in",
123
+ "A gentle harmony of",
124
+ "A graceful curve in",
125
+ "A heightened sense of",
126
+ "A radiant glow surrounding",
127
+ "A resonant soundscape in visual form",
128
+ "A strong focal point in",
129
+ "An angular perspective on",
130
+ "A fleeting moment of",
131
+ "A playful interaction between",
132
+ "A stark minimalist design featuring",
133
+ "A whimsical journey through",
134
+ "An organic structure evolving from",
135
+ "A visual metaphor for",
136
+ "A window into another world through a Stable-Diffusion of",
137
+ "A delicate balance between",
138
+ "A seamless transition from",
139
+ "A tranquil scene",
140
+ "The vibrant colors of",
141
+ "A peaceful countryside morning in",
142
+ "An underwater world revealing",
143
+ "The photography of",
144
+ "A (2000s vintage RAW photo) of",
145
+ "Photoshoot of",
146
+ "A breathtaking",
147
+ "An extremely detailed",
148
+ "An establishing shot of",
149
+ "A concept art of",
150
+ "A breathtaking portrait of a majestic ",
151
+ "A charcoal sketch of",
152
+ "A dramatic scene of",
153
+ "A painting in the style of",
154
+ "An isolated",
155
+ "An (upper angle shot) of",
156
+ "An (aerial perspective photo) of a",
157
+ "A high contrast side light scene",
158
+ "A dark And mysterious ",
159
+ "A clay sculpture of ",
160
+ "A digital illustration featuring",
161
+ "A graffiti art piece depicting",
162
+ "A historical reenactment of ",
163
+ "A leading lines shot of ",
164
+ "A low angle view of ",
165
+ "A misty dawn over ",
166
+ "A mixed media collage showcasing",
167
+ "A panoramic view of ",
168
+ "A pastel portrait of ",
169
+ "A pencil drawing of ",
170
+ "A tight shot of ",
171
+ "A watercolor painting of ",
172
+ "A National Geographic wildlife photographer capturing",
173
+ "A worm's eye view of ",
174
+ "An ink drawing depicting",
175
+ "Masterpiece, ",
176
+ "A mesmerizing glimpse of ",
177
+ "A captivating display of ",
178
+ "A dynamic interplay of ",
179
+ "A sublime vision of ",
180
+ "A breathtaking portrayal of ",
181
+ "A poetic interpretation of ",
182
+ "A striking composition of ",
183
+ "A vivid tapestry of ",
184
+ "An enigmatic depiction of ",
185
+ "A remarkable fusion of ",
186
+ "A stunning perspective of ",
187
+ "A harmonious blend of ",
188
+ "A radical reinterpretation of ",
189
+ "A delicate sketch of ",
190
+ "A vibrant composition of ",
191
+ "A richly textured portrayal of ",
192
+ "A pioneering outlook of ",
193
+ "A refined portrait of ",
194
+ "A sharp focus on ",
195
+ "A monumental depiction of ",
196
+ "A fluid rendering of ",
197
+ "A kinetic expression of ",
198
+ "A graceful outline of ",
199
+ "A provocative framework of ",
200
+ "A subtle balance of ",
201
+ "A minimalist construction of ",
202
+ "A dramatic evolution of ",
203
+ "A whimsical abstraction of ",
204
+ "A poignant reflection of ",
205
+ "A pioneering illustration of ",
206
+ "A sophisticated visualization of ",
207
+ "An exuberant composition of ",
208
+ "A bold expression of ",
209
+ "A lavish interpretation of ",
210
+ "A masterful arrangement of ",
211
+ "A futuristic vision of ",
212
+ "A radiant convergence of ",
213
+ "A surrealist portrayal of ",
214
+ "A fragmented mosaic of ",
215
+ "A cryptic collage of ",
216
+ "A crystalline perspective on ",
217
+ "A dreamlike rendition of ",
218
+ "A kinetic study of ",
219
+ "A spontaneous capture of ",
220
+ "A reflective moment of ",
221
+ "An intense interplay of ",
222
+ "A layered narrative of ",
223
+ "A refined synthesis of ",
224
+ "A chiaroscuro play of ",
225
+ "A poetic exploration of ",
226
+ "A reimagined concept of ",
227
+ "A vigorous depiction of ",
228
+ "A textured cascade of ",
229
+ "A visionary abstraction of ",
230
+ "A monumental snapshot of ",
231
+ "A scintillating vignette of ",
232
+ "A graceful melding of ",
233
+ "A spectral composition of ",
234
+ "A radiant interplay of ",
235
+ "A striking juxtaposition of ",
236
+ "A refined montage of ",
237
+ "A nuanced portrayal of ",
238
+ "A visionary construct of ",
239
+ "An evocative snapshot of ",
240
+ "A bold fusion of ",
241
+ "A delicate overlay of ",
242
+ "A complex layering of ",
243
+ "A vivid gradient of ",
244
+ "A kinetic cascade of ",
245
+ "A luminous texture of ",
246
+ "A bold silhouette of ",
247
+ "A high-resolution photographic capture of ",
248
+ "A sharply focused photographic study of ",
249
+ "A meticulously framed photographic moment of ",
250
+ "An ultra-detailed photographic exploration of ",
251
+ "A dynamic high-contrast photographic depiction of ",
252
+ "A bold, hyper-realistic photographic rendering of ",
253
+ "An intimate photographic snapshot of ",
254
+ "A vividly composed photographic portrayal of ",
255
+ "A crisp, professional photographic impression of ",
256
+ "A timeless black-and-white photographic record of ",
257
+ "A vividly detailed photographic vignette of ",
258
+ "A dynamic, low-key photographic interpretation of ",
259
+ "A refined photographic montage of ",
260
+ "A compelling photographic narrative of ",
261
+ "A striking high-key photographic expression of ",
262
+ "A meticulously captured photographic scene of ",
263
+ "A visionary photographic perspective on ",
264
+ "An innovative photographic framing of ",
265
+ "A sophisticated photographic series of ",
266
+ "A powerful photographic study of ",
267
+ "A radiant photographic tableau of ",
268
+ "A minimalist photographic composition of ",
269
+ "An edgy photographic take on ",
270
+ "A vibrant photographic freeze-frame of ",
271
+ "A kinetic photographic capture of ",
272
+ "A meticulously arranged photographic display of ",
273
+ "A dramatic photographic snapshot of ",
274
+ "A crisp, color-rich photographic impression of ",
275
+ "A bold photographic experiment capturing ",
276
+ "An avant-garde photographic reinterpretation of ",
277
+ "A sharply rendered photographic moment of ",
278
+ "A compelling photographic sequence of ",
279
+ "A profound photographic observation of ",
280
+ "A refined photographic layering of ",
281
+ "A spontaneous photographic capture of ",
282
+ "A surreal photographic juxtaposition of ",
283
+ "A masterfully composed photographic glimpse of ",
284
+ "A radiant photographic slice of ",
285
+ "A detailed photographic capture of ",
286
+ "A visually arresting photographic study of "
287
+ ]
288
 
289
+ # Top 5 exemples à afficher dans le menu déroulant
290
+ prompt_examples = [
291
+ "Award winning photography of",
292
+ "A breathtaking portrait of a majestic",
293
+ "A surreal, ultra-detailed rendering of",
294
+ "The golden hour lighting up",
295
+ "A concept art of"
296
+ ]
297
 
298
+ # Génération
299
+ def generate(prompt, n):
300
+ return "\n\n---\n\n".join(
301
+ prompt + llm(prompt, max_tokens=200, stop=["</s>"], echo=False)["choices"][0]["text"]
302
+ for _ in range(n)
303
+ )
304
+
305
+ # Random prompt
306
+ def use_random_prompt(n):
307
+ prompt = random.choice(prompt_list)
308
+ return prompt, generate(prompt, n)
309
+
310
+ # Sélection d’un exemple
311
+ def use_example_prompt(example, n):
312
+ return example, generate(example, n)
313
+
314
+ # Interface Gradio
315
+ with gr.Blocks(title="WizzGPTv7 - CPU Demo") as demo:
316
+ gr.Markdown("## WizzGPTv7 - Text Completion (GGUF - CPU)")
317
+
318
+ with gr.Row():
319
+ prompt_box = gr.Textbox(lines=5, label="Prompt")
320
+ random_button = gr.Button("🎲 Random Prompt")
321
+
322
+ with gr.Row():
323
+ example_dropdown = gr.Dropdown(choices=prompt_examples, label="📌 Prompt Examples")
324
+ num_slider = gr.Slider(minimum=1, maximum=7, step=1, value=1, label="Number of Responses")
325
+
326
+ output_box = gr.Textbox(label="Completions", lines=15)
327
+ submit_button = gr.Button("Submit")
328
+
329
+ submit_button.click(generate, inputs=[prompt_box, num_slider], outputs=output_box)
330
+ random_button.click(use_random_prompt, inputs=[num_slider], outputs=[prompt_box, output_box])
331
+ example_dropdown.change(use_example_prompt, inputs=[example_dropdown, num_slider], outputs=[prompt_box, output_box])
332
+
333
+ demo.launch()