File size: 14,043 Bytes
c904a84
d07afa3
71cfd62
c904a84
 
42d184c
 
bb264ad
42d184c
c6f1bc4
42d184c
 
 
 
d3ca046
9995431
42d184c
f361d06
 
 
 
 
 
 
 
7231961
f361d06
7231961
f361d06
 
 
42d184c
 
 
c904a84
d07afa3
 
 
 
 
 
 
 
 
 
d9f4047
 
d07afa3
 
 
 
 
 
 
 
 
 
2f998c6
d9f4047
 
 
 
 
 
 
 
 
d07afa3
 
 
d9f4047
d07afa3
 
 
 
 
 
d9f4047
 
d07afa3
 
 
 
 
 
 
 
 
 
 
 
2f998c6
d07afa3
 
2f998c6
 
d07afa3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d9f4047
d07afa3
 
 
 
 
 
 
 
d9f4047
d07afa3
 
d9f4047
 
 
 
d07afa3
d9f4047
 
 
 
 
d07afa3
d9f4047
d07afa3
d9f4047
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d07afa3
c904a84
42d184c
4d219f0
 
57b618a
 
 
 
4d219f0
 
 
 
 
 
 
 
 
 
 
57b618a
 
 
 
 
4d219f0
d07afa3
42d184c
b8a5462
 
 
d07afa3
b8a5462
 
c281eb1
42d184c
 
 
b8a5462
42d184c
072047c
 
 
 
bb362e5
b8a5462
42d184c
c3c4e2d
42d184c
b8a5462
c3c4e2d
 
 
 
 
072047c
fbaa964
 
1edfc99
b8a5462
 
6cb2be7
022eecc
0ab22f2
022eecc
1edfc99
4d219f0
1edfc99
c3c4e2d
d07afa3
c3c4e2d
4d219f0
 
c3c4e2d
 
 
 
d07afa3
b8a5462
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
import gradio as gr
import random
import os
from llama_cpp import Llama

# Liste des modèles disponibles
model_versions = {
    "WizzGPTv3": "model/WizzGPTv3-q8_0.gguf",
    "WizzGPTv6": "model/WizzGPTv6-q8_0.gguf",
    "WizzGPTv7": "model/WizzGPTv7-q8_0.gguf"
}

# Modèle initial (v7 par défaut)
llm = None
current_model = "WizzGPTv7"
model_name = model_versions[current_model]

# Fonction de chargement du modèle
def load_model(model_name):
    global llm, current_model
    model_path = model_versions[model_name]
    if not os.path.exists(model_path):
        raise FileNotFoundError(f"Model file not found at {model_path}")
    llm = Llama(
        model_path=model_path,
        n_ctx=1024,
        n_threads=2,
        n_batch=256,
        verbose=False
    )
    current_model = model_name

# Charger modèle initial
load_model(current_model)

# Liste complète des débuts de prompt
prompt_list = [
    "A beautiful sunset over",
    "A macro shot of",
    "Award winning photography of",
    "Wide shot of",
    "The intricate details of",
    "The portrait of a",
    "A resin figurine of",
    "Painting of",
    "A delicate",
    "A rustic",
    "A stunningly beautiful",
    "Masterpiece, best quality",
    "Hyperrealistic shot of a",
    "Professional fashion shot of",
    "Photo of a classy",
    "Photo of a glamour",
    "(Horror) shot of",
    "Cinematic film still of",
    "A (monochrome:2) photography of",
    "A ",
    "Masterpiece, best quality, ultra-detailed,",
    "A hyper-realistic, cinematic shot of",
    "An incredibly detailed, high-resolution portrait of",
    "A breathtaking, photorealistic capture of",
    "A vivid, intricately detailed scene of",
    "A surreal, ultra-detailed rendering of",
    "An exquisitely detailed, cinematic masterpiece of",
    "A mesmerizing, hyper-detailed view of",
    "A stunning, ultra-realistic depiction of",
    "A visually arresting, high-definition snapshot of",
    "The ",
    "The (hologram) of",
    "A surrealist art of",
    "The (photography of a __animal__:2), (full-body),",
    "The (photo of a (__animal__:__animal__:__weight__) hybrid), full-body,",
    "A photo of an Eldritch abomination,",
    "A (3D geometrically printed figurine) of",
    "An overwhelmingly beautiful",
    "An (eerie scene) featuring",
    "A serene landscape showcasing",
    "A photography of a magnificent",
    "A bokeh effect background with",
    "The bustling streets of",
    "A whimsical depiction of",
    "A dramatic aerial view of",
    "An enchanting tableau presenting",
    "The ancient ruins of",
    "A night sky filled with",
    "A macro close-up portrait of",
    "An (abstract composition) with",
    "A snowy scene with",
    "The golden hour lighting up",
    "A mystical forest where",
    "A futuristic cityscape with",
    "An ethereal",
    "A whimsical",
    "Photo of an amazingly beautiful creature with",
    "Photo of an iridescent",
    "Focus on",
    "A meticulously crafted",
    "A dramatic chiaroscuro lighting of",
    "An artistic interpretation of",
    "A vivid depiction of",
    "A serene moment captured in",
    "A richly textured",
    "An evocative scene portraying",
    "An epic panorama of",
    "An iconic representation of",
    "A minimalist composition featuring",
    "An avant-garde portrayal of",
    "An immersive diorama of",
    "A time-lapse sequence showing",
    "A haunting silhouette against",
    "An ancient mythological scene in",
    "A contemporary reimagining of",
    "A hyper-detailed rendering of",
    "A nostalgic memory preserved in",
    "A powerful juxtaposition of",
    "A seamless blend of",
    "A surreal",
    "An evocative interplay of light and shadow",
    "A preserved fragment of",
    "An intricate lacework of",
    "An offbeat take on",
    "A reflective surface capturing",
    "A slow-motion capture of",
    "A stunning vista showcasing",
    "A timeless black-and-white portrait of",
    "A twisted version of",
    "A dynamic motion blur effect in",
    "A geometric pattern inspired by",
    "A moody fog enveloping",
    "A textured overlay on",
    "A vibrant explosion of color",
    "A carefully orchestrated symmetry in",
    "A kaleidoscopic arrangement of",
    "A subtle gradation of color in",
    "The raw grandeur of",
    "A whirlwind of movement in",
    "A conceptual representation of",
    "An experimental take on",
    "A harmonious blend of",
    "A poetic rendering of",
    "An organic flow of",
    "An understated elegance in",
    "An unassuming grace in",
    "A dynamic shift in",
    "A gentle harmony of",
    "A graceful curve in",
    "A heightened sense of",
    "A radiant glow surrounding",
    "A resonant soundscape in visual form",
    "A strong focal point in",
    "An angular perspective on",
    "A fleeting moment of",
    "A playful interaction between",
    "A stark minimalist design featuring",
    "A whimsical journey through",
    "An organic structure evolving from",
    "A visual metaphor for",
    "A window into another world through a Stable-Diffusion of",
    "A delicate balance between",
    "A seamless transition from",
    "A tranquil scene",
    "The vibrant colors of",
    "A peaceful countryside morning in",
    "An underwater world revealing",
    "The photography of",
    "A (2000s vintage RAW photo) of",
    "Photoshoot of",
    "A breathtaking",
    "An extremely detailed",
    "An establishing shot of",
    "A concept art of",
    "A breathtaking portrait of a majestic",
    "A charcoal sketch of",
    "A dramatic scene of",
    "A painting in the style of",
    "An isolated",
    "An (upper angle shot) of",
    "An (aerial perspective photo) of a",
    "A high contrast side light scene",
    "A dark And mysterious ",
    "A clay sculpture of",
    "A digital illustration featuring",
    "A graffiti art piece depicting",
    "A historical reenactment of",
    "A leading lines shot of",
    "A low angle view of",
    "A misty dawn over",
    "A mixed media collage showcasing",
    "A panoramic view of",
    "A pastel portrait of",
    "A pencil drawing of",
    "A tight shot of",
    "A watercolor painting of",
    "A National Geographic wildlife photographer capturing",
    "A worm's eye view of",
    "An ink drawing depicting",
    "Masterpiece,",
    "A mesmerizing glimpse of",
    "A captivating display of",
    "A dynamic interplay of",
    "A sublime vision of",
    "A breathtaking portrayal of",
    "A poetic interpretation of",
    "A striking composition of",
    "A vivid tapestry of",
    "An enigmatic depiction of",
    "A remarkable fusion of",
    "A stunning perspective of",
    "A harmonious blend of",
    "A radical reinterpretation of",
    "A delicate sketch of",
    "A vibrant composition of",
    "A richly textured portrayal of",
    "A pioneering outlook of",
    "A refined portrait of",
    "A sharp focus on",
    "A monumental depiction of",
    "A fluid rendering of",
    "A kinetic expression of",
    "A graceful outline of",
    "A provocative framework of",
    "A subtle balance of",
    "A minimalist construction of",
    "A dramatic evolution of",
    "A whimsical abstraction of",
    "A poignant reflection of",
    "A pioneering illustration of",
    "A sophisticated visualization of",
    "An exuberant composition of",
    "A bold expression of",
    "A lavish interpretation of",
    "A masterful arrangement of",
    "A futuristic vision of",
    "A radiant convergence of",
    "A surrealist portrayal of",
    "A fragmented mosaic of",
    "A cryptic collage of",
    "A crystalline perspective on",
    "A dreamlike rendition of",
    "A kinetic study of",
    "A spontaneous capture of",
    "A reflective moment of",
    "An intense interplay of",
    "A layered narrative of",
    "A refined synthesis of",
    "A chiaroscuro play of",
    "A poetic exploration of",
    "A reimagined concept of",
    "A vigorous depiction of",
    "A textured cascade of",
    "A visionary abstraction of",
    "A monumental snapshot of",
    "A scintillating vignette of",
    "A graceful melding of",
    "A spectral composition of",
    "A radiant interplay of",
    "A striking juxtaposition of",
    "A refined montage of",
    "A nuanced portrayal of",
    "A visionary construct of",
    "An evocative snapshot of",
    "A bold fusion of",
    "A delicate overlay of",
    "A complex layering of",
    "A vivid gradient of",
    "A kinetic cascade of",
    "A luminous texture of",
    "A bold silhouette of",
    "A high-resolution photographic capture of",
    "A sharply focused photographic study of",
    "A meticulously framed photographic moment of",
    "An ultra-detailed photographic exploration of",
    "A dynamic high-contrast photographic depiction of",
    "A bold, hyper-realistic photographic rendering of",
    "An intimate photographic snapshot of",
    "A vividly composed photographic portrayal of",
    "A crisp, professional photographic impression of",
    "A timeless black-and-white photographic record of",
    "A vividly detailed photographic vignette of",
    "A dynamic, low-key photographic interpretation of",
    "A refined photographic montage of",
    "A compelling photographic narrative of",
    "A striking high-key photographic expression of",
    "A meticulously captured photographic scene of",
    "A visionary photographic perspective on",
    "An innovative photographic framing of",
    "A sophisticated photographic series of",
    "A powerful photographic study of",
    "A radiant photographic tableau of",
    "A minimalist photographic composition of",
    "An edgy photographic take on",
    "A vibrant photographic freeze-frame of",
    "A kinetic photographic capture of",
    "A meticulously arranged photographic display of",
    "A dramatic photographic snapshot of",
    "A crisp, color-rich photographic impression of",
    "A bold photographic experiment capturing",
    "An avant-garde photographic reinterpretation of",
    "A sharply rendered photographic moment of",
    "A compelling photographic sequence of",
    "A profound photographic observation of",
    "A refined photographic layering of",
    "A spontaneous photographic capture of",
    "A surreal photographic juxtaposition of",
    "A masterfully composed photographic glimpse of",
    "A radiant photographic slice of",
    "A detailed photographic capture of",
    "A visually arresting photographic study of"
]

# Fonction de génération
def generate_completions(prompt, n_responses, max_tokens, temperature, top_p, top_k, repeat_penalty):
    results = []
    print("\n" + "="*50)
    print(f"[PROMPT] {prompt}")
    print(f"[PARAMS] Completions: {n_responses}, max_tokens: {max_tokens}, temp: {temperature}, top_p: {top_p}, top_k: {top_k}, penalty: {repeat_penalty}")
    
    for _ in range(n_responses):
        output = llm(
            prompt,
            max_tokens=max_tokens,
            temperature=temperature,
            top_p=top_p,
            top_k=top_k,
            repeat_penalty=repeat_penalty,
            echo=False
        )
        text = output["choices"][0]["text"].strip()
        full = f"{prompt} {text}"
        results.append(full)
        print(f"[RESPONSE] {full}")

    print("="*50 + "\n")
    return "\n\n".join(results)

# Fonctions UI
def set_random_prompt(n):
    selected = random.choice(prompt_list)
    return selected, f"🎲 Random Prompt{'s' if n > 1 else ''}", f"🚀 Generate Prompt{'s' if n > 1 else ''}"

def set_prompt_from_dropdown(choice, n):
    return choice, f"🎲 Random Prompt{'s' if n > 1 else ''}", f"🚀 Generate Prompt{'s' if n > 1 else ''}"

def on_model_change(model_name):
    load_model(model_name)
    return f"Model loaded: {model_name}"

# Interface Gradio
with gr.Blocks(css="""
    .gr-button { font-size: 16px; }
    #random-btn { height: 100%; margin: auto 0; }
""") as demo:
    gr.Markdown("## ✨ WizzGPT — Forget logic. Embrace surprise. This model creates visual wonder, not narrative clarity.")

    with gr.Row():
        model_selector = gr.Dropdown(choices=list(model_versions.keys()), value="WizzGPTv7", label="🧠 Select Model")
        model_status = gr.Textbox(value=f"Model loaded: {current_model}", label="Status", interactive=False)

    with gr.Group():
        with gr.Row():
            prompt_input = gr.Textbox(label="📝 Prompt", lines=3, placeholder="Type or pick a prompt...")
        with gr.Row():
            prompt_dropdown = gr.Dropdown(choices=prompt_list, label="📌 Prompt Examples", scale=2)
            random_button = gr.Button("🎲 Random Prompt", scale=1, elem_id="random-btn")

    with gr.Row():
        n_responses = gr.Slider(1, 7, value=1, step=1, label="Number of Completions")

    with gr.Accordion("⚙️ Advanced Settings", open=False):
        max_tokens = gr.Slider(10, 200, value=75, step=5, label="Max Tokens")
        temperature = gr.Slider(0.1, 2.0, value=1.10, step=0.05, label="Temperature")
        top_p = gr.Slider(0.0, 1.0, value=0.90, step=0.05, label="Top-p")
        top_k = gr.Slider(0, 128, value=40, step=1, label="Top-k")
        repeat_penalty = gr.Slider(0.5, 2.0, value=1.4, step=0.05, label="Repeat Penalty")

    generate_button = gr.Button("🚀 Generate Prompt(s)")
    output = gr.Textbox(label="📄 Completions", lines=12)

    # Interactions
    prompt_dropdown.change(set_prompt_from_dropdown, [prompt_dropdown, n_responses], [prompt_input, random_button, generate_button])
    random_button.click(set_random_prompt, inputs=n_responses, outputs=[prompt_input, random_button, generate_button])
    n_responses.change(lambda n: (f"🎲 Random Prompt{'s' if n > 1 else ''}", f"🚀 Generate Prompt{'s' if n > 1 else ''}"), inputs=n_responses, outputs=[random_button, generate_button])
    generate_button.click(fn=generate_completions, inputs=[prompt_input, n_responses, max_tokens, temperature, top_p, top_k, repeat_penalty], outputs=output)

    model_selector.change(on_model_change, inputs=model_selector, outputs=model_status)

demo.launch()