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
b62f01b
 
 
77cdce3
 
3bebd7a
59f4c33
 
 
 
 
b62f01b
d55aa26
9a6e98e
0e81abc
b62f01b
8637ff9
 
 
 
 
d55aa26
694da4b
3d8f3d4
 
 
694da4b
8637ff9
 
 
9bc6c6b
8637ff9
 
 
d4e1a5d
 
8637ff9
d55aa26
 
 
 
 
cf71924
d55aa26
 
8637ff9
cf71924
59f4c33
3d8f3d4
 
0e81abc
 
1a2ba23
8637ff9
e5111ed
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
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
import gradio as gr
import requests
import time
import json
import base64
import os
from io import BytesIO
import html
import re
from deep_translator import GoogleTranslator
from langdetect import detect



class Prodia:
    def __init__(self, api_key, base=None):
        self.base = base or "https://api.prodia.com/v1"
        self.headers = {
            "X-Prodia-Key": api_key
        }
    
    def generate(self, params):
        response = self._post(f"{self.base}/sd/generate", params)
        return response.json()
    
    def transform(self, params):
        response = self._post(f"{self.base}/sd/transform", params)
        return response.json()
    
    def controlnet(self, params):
        response = self._post(f"{self.base}/sd/controlnet", params)
        return response.json()
    
    def get_job(self, job_id):
        response = self._get(f"{self.base}/job/{job_id}")
        return response.json()

    def wait(self, job):
        job_result = job

        while job_result['status'] not in ['succeeded', 'failed']:
            time.sleep(0.25)
            job_result = self.get_job(job['job'])

        return job_result

    def list_models(self):
        response = self._get(f"{self.base}/sd/models")
        return response.json()

    def list_samplers(self):
        response = self._get(f"{self.base}/sd/samplers")
        return response.json()

    def _post(self, url, params):
        headers = {
            **self.headers,
            "Content-Type": "application/json"
        }
        response = requests.post(url, headers=headers, data=json.dumps(params))

        if response.status_code != 200:
            raise Exception(f"Bad Prodia Response: {response.status_code}")

        return response

    def _get(self, url):
        response = requests.get(url, headers=self.headers)

        if response.status_code != 200:
            raise Exception(f"Bad Prodia Response: {response.status_code}")

        return response


def image_to_base64(image):
    # Convert the image to bytes
    buffered = BytesIO()
    image.save(buffered, format="WEBP")  # You can change format to PNG if needed
    
    # Encode the bytes to base64
    img_str = base64.b64encode(buffered.getvalue())

    return img_str.decode('utf-8')  # Convert bytes to string


def remove_id_and_ext(text):
    text = re.sub(r'\[.*\]$', '', text)
    extension = text[-12:].strip()
    if extension == "safetensors":
        text = text[:-13]
    elif extension == "ckpt":
        text = text[:-4]
    return text


def get_data(text):
    results = {}
    patterns = {
        'prompt': r'(.*)',
        'negative_prompt': r'Negative prompt: (.*)',
        'steps': r'Steps: (\d+),',
        'seed': r'Seed: (\d+),',
        'sampler': r'Sampler:\s*([^\s,]+(?:\s+[^\s,]+)*)', 
        'model': r'Model:\s*([^\s,]+)',
        'cfg_scale': r'CFG scale:\s*([\d\.]+)',
        'size': r'Size:\s*([0-9]+x[0-9]+)'
        }
    for key in ['prompt', 'negative_prompt', 'steps', 'seed', 'sampler', 'model', 'cfg_scale', 'size']:
        match = re.search(patterns[key], text)
        if match:
            results[key] = match.group(1)
        else:
            results[key] = None
    if results['size'] is not None:
        w, h = results['size'].split("x")
        results['w'] = w
        results['h'] = h
    else:
        results['w'] = None
        results['h'] = None
    return results




prodia_client = Prodia(api_key=os.getenv("PRODIA_API_KEY"))
model_list = prodia_client.list_models()
model_names = {}

for model_name in model_list:
    name_without_ext = remove_id_and_ext(model_name)
    model_names[name_without_ext] = model_name


def txt2img(prompt, negative_prompt, model, steps, sampler, cfg_scale, width, height, seed):
    language = detect(prompt)
    
    if language == 'ru':
        prompt = GoogleTranslator(source='ru', target='en').translate(prompt)
        print(prompt)
    
    result = prodia_client.generate({
        "prompt": prompt,
        "negative_prompt": negative_prompt,
        "model": model,
        "steps": steps,
        "sampler": sampler,
        "cfg_scale": cfg_scale,
        "width": width,
        "height": height,
        "seed": seed
    })

    job = prodia_client.wait(result)

    return job["imageUrl"]


def img2img(input_image, denoising, prompt, negative_prompt, model, steps, sampler, cfg_scale, width, height, seed):
    result = prodia_client.transform({
        "imageData": image_to_base64(input_image),
        "denoising_strength": denoising,
        "prompt": prompt,
        "negative_prompt": negative_prompt,
        "model": model,
        "steps": steps,
        "sampler": sampler,
        "cfg_scale": cfg_scale,
        "width": width,
        "height": height,
        "seed": seed
    })

    job = prodia_client.wait(result)

    return job["imageUrl"]


css = """
footer {visibility: hidden !important;}
#container{

margin: 0 auto;

max-width: 40rem;

}

#intro{

max-width: 100%;

text-align: center;

margin: 0 auto;

}

div.svelte-vt1mxs {

display: flex;

position: relative;

flex-direction: column

}

div.svelte-vt1mxs>*,div.svelte-vt1mxs>.form > * {

width: var(--size-full)

}

.gap.svelte-vt1mxs {

gap: var(--layout-gap)

}

.hide.svelte-vt1mxs {

display: none

}

.compact.svelte-vt1mxs>*,.compact.svelte-vt1mxs .box {

border-radius: 0

}

.compact.svelte-vt1mxs,.panel.svelte-vt1mxs {

border: solid var(--panel-border-width) var(--panel-border-color);

border-radius: var(--container-radius);

background: var(--panel-background-fill);

padding: var(--spacing-lg)

}

div#component-24 {

display: none;

}

div#component-8 {background: #00000024;border: 0;color: #ffffff;backdrop-filter: blur(20px);-webkit-backdrop-filter: blur(20px);border-width: 0 !important;}

span.md.svelte-9tftx4 {

display: none;

}

.empty.svelte-lk9eg8.large.unpadded_box {

background: none !important;

}

div#component-26 {

display: none;

}

div#component-7 {

background: none;

}

.wrap.default.full.svelte-119qaqt.hide {

background: none !important;

}

.styler.svelte-iyf88w {

background: none !important;

}

div#component-3 {

background: none !important;

border: 0;

}

input.scroll-hide.svelte-1f354aw {

overflow: hidden !important;

}

div#component-5 {

border-radius: 40px 0px 0px 40px;

background: black !important;

opacity: 0.9;

}

#component-6 {

border-radius: 0px 40px 40px 0px;

background: linear-gradient(358deg, #ff4d0080, #fff0);

color: #ffffffe3;

border: 2px #ffffffc2 dashed;

border-left: 0;

font-size: 30px;

letter-spacing:-1px;

position: relative;

z-index: 1;

backdrop-filter: blur(18px);

-webkit-backdrop-filter: blur(18px);

}

div#component-0 {

max-width: 100% !important;

}

.grid-wrap.svelte-1b19cri.fixed-height {

max-height: 100% !important;

overflow: auto;

}

footer.svelte-1ax1toq {

display: none !important;

}

input.scroll-hide.svelte-1f354aw {

font-size: 26px;

padding: 25px;

}

div#component-4 {

margin-top: 230px;

margin-bottom: 30px;

}

gradio-app {

background-color: transparent !important;

background: url(https://vivawaves.com/wavesweaveslogo.svg) top center no-repeat !important;

margin-top: 260px;

}

label.svelte-1f354aw {

}

.styler.svelte-iyf88w {

}

body {

background: url(https://vivawaves.com/vivatodaybg2.jpg);

background-size: cover;

}

img.svelte-1b19cri {}

.preview.svelte-1b19cri {

background: #0000004d !important;

border-radius: 20px;

padding: 20px;

overflow: hidden;

}

button.svelte-1030q2h {

border-radius: 100%;

}

div.svelte-1030q2h svg {

}

svg path {

}

img.svelte-1b19cri {

border-radius: 10px;

}

.form.svelte-sfqy0y {

background: #fff0;

border-width: 0px;

opacity: 0.8;

}

.gradio-container-3-44-2,.gradio-container-3-44-2 *,.gradio-container-3-44-2 :before,.gradio-container-3-44-2 :after {

box-sizing: border-box;

border-width: 0;

border-style: solid;

}

div#component-13 {

display: none;

}

footer.svelte-mpyp5e {

display: none !important;

}

div#intro {

display: none;

}

div.svelte-15lo0d8 {

display: flex;

flex-wrap: wrap;

gap: 0;

width: var(--size-full);

flex-direction: initial;

justify-content: center;

align-items: baseline;

}

input.svelte-1f354aw.svelte-1f354aw, textarea.svelte-1f354aw.svelte-1f354aw {

display: block;

position: relative;

outline: none !important;

box-shadow: var(--input-shadow);

background: var(--input-background-fill);

padding: var(--input-padding);

width: 100%;

color: var(--body-text-color);

font-weight: var(--input-text-weight);

font-size: large;

line-height: initial;

border: none;

text-size-adjust: auto;

font-size: 23px !important;

}

div#component-24 {

display: none;

}

div#component-8 {background: #00000024;border: 0;color: #ffffff;backdrop-filter: blur(20px);-webkit-backdrop-filter: blur(20px);border-width: 0 !important;}

span.md.svelte-9tftx4 {

display: none;

}

.empty.svelte-lk9eg8.large.unpadded_box {

background: none !important;

}

div#component-26 {

display: none;

}

div#component-7 {

background: none;

}

.wrap.default.full.svelte-119qaqt.hide {

background: none !important;

}

.styler.svelte-iyf88w {

background: none !important;

}

div#component-3 {

background: none !important;

border: 0;

}

div#component-9 {
    border: 0 !important;
}


input.scroll-hide.svelte-1f354aw {

overflow: hidden !important;

}

div#component-5 {

border-radius: 40px;

background: transparent !important;

opacity: 1;

}

#component-6 {
    border-radius: 40px;
    background: #d7661500;
    border: none;
    border-left: 0;
    font-size: 30px;
    letter-spacing: -1px;
    position: relative;
    z-index: 1;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    display: block;
}

div#component-0 {

max-width: 100% !important;

}

.grid-wrap.svelte-1b19cri.fixed-height {

max-height: 100% !important;

overflow: auto;

}

footer.svelte-1ax1toq {

display: none !important;

}

input.scroll-hide.svelte-1f354aw {

font-size: 26px;

padding: 25px;

}

div#component-4 {

margin-top: 230px;

margin-bottom: 30px;

}

gradio-app {

background-color: transparent !important;

background: url(https://vivawaves.com/wavesweaveslogo.svg) top center no-repeat !important;

margin-top: 77px;

}

label.svelte-1f354aw {

}

.styler.svelte-iyf88w {

}

body {

background: url(https://vivawaves.com/vivatodaybg2.jpg);

background-size: cover;

}

img.svelte-1b19cri {}

.preview.svelte-1b19cri {

background: #0000004d !important;

border-radius: 20px;

padding: 20px;

overflow: hidden;

}

button.svelte-1030q2h {

border-radius: 100%;

}

div.svelte-1030q2h svg {

}

svg path {

}

img.svelte-1b19cri {

border-radius: 10px;

}

.form.svelte-sfqy0y {

background: #fff0;

border-width: 0px;

opacity: 0.8;

}

.gradio-container-3-44-2,.gradio-container-3-44-2 *,.gradio-container-3-44-2 :before,.gradio-container-3-44-2 :after {

box-sizing: border-box;

border-width: 0;

border-style: solid;

}

div#component-13 {

display: none;

}

footer.svelte-mpyp5e {

display: none !important;

}

div#intro {

display: none;

}

div.svelte-15lo0d8 {

display: flex;

flex-wrap: wrap;

gap: 0 !important;

width: var(--size-full);

flex-direction: initial;

justify-content: center;

align-items: baseline;

}

input.svelte-1f354aw.svelte-1f354aw, textarea.svelte-1f354aw.svelte-1f354aw {

display: block;

position: relative;

outline: none !important;

box-shadow: var(--input-shadow);

background: var(--input-background-fill);

padding: var(--input-padding);

width: 100%;

color: var(--body-text-color);

font-weight: var(--input-text-weight);

font-size: large;

line-height: initial;

border: none;

text-size-adjust: auto;

font-size: 23px !important;

border-radius: 30px;

background: white !important;

text-align: center;

}

div#component-8 {

margin-bottom: 70px;
margin-top: 210px;

}
    div#component-15 {display: none;}

div#component-18 {
    display: none;
}

div#component-1 {
    display: none;
}

button.selected.svelte-kqij2n {
    display: none;
}

button.svelte-kqij2n {
    display: none;
}

.tab-nav.scroll-hide.svelte-kqij2n {
    display: none;
}

.svelte-vt1mxs.gap {
    border-radius: 20px;
}

div#component-6 {padding: 26px;}

button#generate {
    background: #eb7623;
    border-radius: 40px;
    padding: 16px;
    color: #FFF;
    FONT-SIZE: large;
    border: 2px solid #ff7600;
    border-top: 0px solid;
    box-shadow: 0px 12px 10px -10px #ff7600;
}
"""
        
with gr.Blocks(css=css) as demo:
    with gr.Row():
        with gr.Accordion(label="Models", open=False):
            model = gr.Radio(interactive=False, value="epicrealism_naturalSinRC1VAE.safetensors [90a4c676]", show_label=False, choices=prodia_client.list_models())

    with gr.Tabs() as tabs:
        
        with gr.Tab("txt2img", id='t2i'):
                    
            with gr.Row():
                with gr.Column(scale=3):
                    with gr.Tab("Основные настройки"):
                        with gr.Column(scale=6, min_width=600):
                            prompt = gr.Textbox("", placeholder="Take a deep breath and take your time describing your weave... Be as vague or specific as you want. 💜✨ ", show_label=False, lines=3) 
                            negative_prompt = gr.Textbox(placeholder="Here you can describe anything that you would like NOT to see. ", show_label=False, lines=1, value="")
                                        
                        with gr.Row():
                            with gr.Column(scale=1):
                                steps = gr.Slider(label="Sampling Steps", minimum=1, maximum=50, value=40, step=1)
    
                        with gr.Row():
                            with gr.Column(scale=1):
                                width = gr.Slider(label="Ширина", minimum=15, maximum=1024, value=1024, step=8)
                                height = gr.Slider(label="Длина", minimum=15, maximum=1024, value=1024, step=8)
                            
                    with gr.Tab("Расширенные настройки"):
                        with gr.Row():
                            with gr.Column(scale=1):
                                sampler = gr.Dropdown(value="DPM++ 2M Karras", show_label=True, label="Sampling Method", choices=prodia_client.list_samplers())
                            
                        cfg_scale = gr.Slider(label="CFG Scale", minimum=1, maximum=20, value=7, step=1)
                        seed = gr.Slider(label="Seed", minimum=-1, maximum=10000000, value=-1)
                    text_button = gr.Button("Weave", variant='primary', elem_id="generate")
                    image_output = gr.Image()
    
            text_button.click(txt2img, inputs=[prompt, negative_prompt, model, steps, sampler, cfg_scale, width, height, seed], outputs=image_output)
        
        with gr.Tab("img2img", id='i2i'):
            with gr.Row():
                with gr.Column(scale=3):
                    with gr.Tab("Основные настройки"):
                        i2i_image_input = gr.Image(type="pil")
                        with gr.Column(scale=6, min_width=600):
                            i2i_prompt = gr.Textbox("", placeholder="Prompt", show_label=False, lines=3)
                            i2i_negative_prompt = gr.Textbox(placeholder="Negative Prompt", show_label=False, lines=3, value="[deformed | disfigured], poorly drawn, [bad : wrong] anatomy, [extra | missing | floating | disconnected] limb, (mutated hands and fingers), blurry")
                            
                        with gr.Row():
                                
                            with gr.Column(scale=1):
                                i2i_steps = gr.Slider(label="Sampling Steps", minimum=1, maximum=50, value=30, step=1)
    
                        with gr.Row():
                            with gr.Column(scale=1):
                                i2i_width = gr.Slider(label="Ширина", minimum=15, maximum=1024, value=512, step=8)
                                i2i_height = gr.Slider(label="Высота", minimum=15, maximum=1024, value=512, step=8)
                            
    
                    with gr.Tab("Расширенные настройки"):

                        with gr.Row():
                            with gr.Column(scale=1):
                                i2i_sampler = gr.Dropdown(value="DPM++ 2M Karras", show_label=True, label="Sampling Method", choices=prodia_client.list_samplers())
                                
                           
                        i2i_cfg_scale = gr.Slider(label="CFG Scale", minimum=1, maximum=20, value=7, step=1)
                        i2i_denoising = gr.Slider(label="Схожесть с оригиналом", minimum=0, maximum=1, value=0.7, step=0.1)
                        i2i_seed = gr.Slider(label="Seed", minimum=-1, maximum=10000000, value=-1)

                
                    i2i_text_button = gr.Button("Генерация", variant='primary', elem_id="generate")
                    i2i_image_output = gr.Image()

            i2i_text_button.click(img2img, inputs=[i2i_image_input, i2i_denoising, i2i_prompt, i2i_negative_prompt, model, i2i_steps, i2i_sampler, i2i_cfg_scale, i2i_width, i2i_height, i2i_seed], outputs=i2i_image_output)
demo.queue(concurrency_count=64, max_size=80, api_open=False).launch(max_threads=256)