File size: 10,860 Bytes
5b6d22e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
075cbd5
5b6d22e
 
 
 
075cbd5
5b6d22e
 
 
 
 
075cbd5
5b6d22e
ce6f474
5b6d22e
 
 
 
 
 
01f4376
 
5b6d22e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
075cbd5
5b6d22e
 
 
 
 
 
 
 
 
075cbd5
 
 
5b6d22e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5f304a2
ce6f474
5b6d22e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
075cbd5
5b6d22e
075cbd5
5b6d22e
 
 
 
 
5f304a2
 
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
import os 
import cv2
import sys
import time 
import uuid as bandaid
import tarfile
import gradio as gr
from pathlib import Path
from PIL import Image


models = [
    "johnslegers/epic-diffusion-v1.1",
    "andite/anything-v4.0",    
    "runwayml/stable-diffusion-v1-5",
    "claudfuen/photorealistic-fuen-v1",
    "naclbit/trinart_stable_diffusion_v2",
    "nitrosocke/Arcane-Diffusion",
    "nitrosocke/archer-diffusion",
    "nitrosocke/elden-ring-diffusion",
    "nitrosocke/redshift-diffusion",
    "nitrosocke/spider-verse-diffusion", 
    "nitrosocke/mo-di-diffusion",
    "nitrosocke/classic-anim-diffusion",
    "dreamlike-art/dreamlike-diffusion-1.0",
    "dreamlike-art/dreamlike-photoreal-2.0",    
    "wavymulder/wavyfusion",
    "wavymulder/Analog-Diffusion",
    "prompthero/midjourney-v4-diffusion",
    "prompthero/openjourney",
    "dallinmackay/Van-Gogh-diffusion",
    "hakurei/waifu-diffusion",
    "DGSpitzer/Cyberpunk-Anime-Diffusion",
    "Fictiverse/Stable_Diffusion_BalloonArt_Model",
    "dallinmackay/Tron-Legacy-diffusion",
    "AstraliteHeart/pony-diffusion",
    "nousr/robo-diffusion",
    "CompVis/stable-diffusion-v1-4",
    
]
current_model = models[0]

text_gen1=gr.Interface.load("spaces/Omnibus/MagicPrompt-Stable-Diffusion_link")
text_gen2=gr.Interface.load("spaces/Omnibus/MagicPrompt-Stable-Diffusion_link")
text_gen3=gr.Interface.load("spaces/Omnibus/MagicPrompt-Stable-Diffusion_link")
text_gen4=gr.Interface.load("spaces/Omnibus/MagicPrompt-Stable-Diffusion_link")
text_gen5=gr.Interface.load("spaces/Omnibus/MagicPrompt-Stable-Diffusion_link")
text_gen6=gr.Interface.load("spaces/Omnibus/MagicPrompt-Stable-Diffusion_link")
text_gen7=gr.Interface.load("spaces/Omnibus/MagicPrompt-Stable-Diffusion_link")
text_gen8=gr.Interface.load("spaces/Omnibus/MagicPrompt-Stable-Diffusion_link")

models2=[
    gr.Interface.load(f"models/{models[0]}",live=True,preprocess=True),
    gr.Interface.load(f"models/{models[1]}",live=True,preprocess=True),
    gr.Interface.load(f"models/{models[2]}",live=True,preprocess=True),
    gr.Interface.load(f"models/{models[3]}",live=True,preprocess=True),
    gr.Interface.load(f"models/{models[4]}",live=True,preprocess=True),
    gr.Interface.load(f"models/{models[5]}",live=True,preprocess=True),
    gr.Interface.load(f"models/{models[6]}",live=True,preprocess=True),
    gr.Interface.load(f"models/{models[7]}",live=True,preprocess=True),
    gr.Interface.load(f"models/{models[8]}",live=True,preprocess=True),
    gr.Interface.load(f"models/{models[9]}",live=True,preprocess=True),
    gr.Interface.load(f"models/{models[10]}",live=True,preprocess=True),
    gr.Interface.load(f"models/{models[11]}",live=True,preprocess=True),
    gr.Interface.load(f"models/{models[12]}",live=True,preprocess=True),
    gr.Interface.load(f"models/{models[13]}",live=True,preprocess=True),
    gr.Interface.load(f"models/{models[14]}",live=True,preprocess=True),
    gr.Interface.load(f"models/{models[15]}",live=True,preprocess=True),   
    gr.Interface.load(f"models/{models[16]}",live=True,preprocess=True),
    gr.Interface.load(f"models/{models[17]}",live=True,preprocess=True),
    gr.Interface.load(f"models/{models[18]}",live=True,preprocess=True),
    gr.Interface.load(f"models/{models[19]}",live=True,preprocess=True),
    gr.Interface.load(f"models/{models[20]}",live=True,preprocess=True),
    gr.Interface.load(f"models/{models[21]}",live=True,preprocess=True),
    gr.Interface.load(f"models/{models[22]}",live=True,preprocess=True),
    gr.Interface.load(f"models/{models[23]}",live=True,preprocess=True),
    gr.Interface.load(f"models/{models[24]}",live=True,preprocess=True),       
    gr.Interface.load(f"models/{models[25]}",live=True,preprocess=True),       

]


def text_it(inputs,text_gen1=text_gen1):
        go_t1=text_gen1(inputs)
        return(go_t1)

def set_model(current_model):
    current_model = models[current_model]
    return gr.update(label=(f"{current_model}")),gr.update(label=(f"{current_model}")),gr.update(label=(f"{current_model}")),gr.update(label=(f"{current_model}")),gr.update(label=(f"{current_model}")),gr.update(label=(f"{current_model}")),gr.update(label=(f"{current_model}")),gr.update(label=(f"{current_model}")),

def prime_the_thing():
    #timestr = time.strftime("%Y%m%d-%H%M%S")
    timestr = bandaid.uuid4()
    if not os.path.exists(f'./frames{timestr}'):
        os.mkdir(f'./frames{timestr}')
        
    frame_box=[]
    frame_file_box=[]
    frame_tar_box=[]
    go=1
    return timestr, go, frame_box, frame_file_box, frame_tar_box

def go_fn():
    num=1
    return num 
         
def the_thing(inputs,input_rand, model_choice,num,top_num,timestr, frame_box, frame_file_box, frame_tar_box):
    if num != 0:
        if int(num) <= int(top_num) and int(num) <= 20:
            #proc1=
            inputs=f"{inputs}{input_rand}"
            proc1=models2[model_choice]
            output=proc1(inputs)
            #output_pro=Image.open(output)
            output_pro=cv2.imread(output)
            cv2.imwrite(f"./frames{timestr}/frame-{timestr}-{num}.png",output_pro)
            frame_file_box.append(Path(f"./frames{timestr}/frame-{timestr}-{num}.png"))
            frame_box.append(output)
            input_rand=f"{input_rand} "
            if int(num) < int(top_num):
                num=int(num)+1
            elif int(num)==int(top_num):
                #frame_tar_box=[]
                with tarfile.open(f'frames{timestr}.tar.gz','w:gz') as tar:
                    tar.add(f"./frames{timestr}",arcname=os.path.basename(f"./frames{timestr}"))
                frame_tar_box.append(Path(f'frames{timestr}.tar.gz'))
            else:
                pass
        else:
            num=0
            pass
            
    else:
        print("ending")
    return frame_box,frame_file_box,frame_tar_box,num,input_rand,frame_box,frame_file_box,frame_tar_box


css=""""""
css="""
.max-h-\[55vh\]{
max-height:10vh;!important;
}
""" 
with gr.Blocks(css=css) as myface:
    frame_box = gr.State([])
    frame_file_box = gr.State([])
    frame_tar_box = gr.State([])
    with gr.Row():
        with gr.Tab("Title"):
                gr.HTML("""    <title>Diffusion Flood</title>            
                <div style="text-align: center;text-shadow:0px 0px 2px white,0px 0px 5px cornflowerblue;max-width:1500px;margin-top:5px;font-size:50px;height:50px;">
                <h1>Diffusion Flood</h1></div>
                <br>
                <div style="text-align:center;font-size:30px;margin-bottom:5px;"><h4>Grab a bucket!</h4></div>""")
        with gr.Tab("Description"):
            gr.HTML("""<div style="text-align:center;">
                <h4>Developing...</h4>
                <br><h4>Select how many image you would like returned</h4>
                <h4>Enter your Prompt</h4>  
                <h4>Select a Model (some are fast, others are slow)</h4>  
                <h4>Send it!</h4>  
                       </div>""")

        with gr.Tab("Tools"):
                    with gr.Tab("View"):
                      with gr.Row():
                        with gr.Column(style="width=50%, height=70%"):
                                gr.Pil(label="Crop")
                        with gr.Column(style="width=50%, height=70%"):
                                gr.Pil(label="Crop")
                    with gr.Tab("Draw"):
                        with gr.Column(style="width=50%, height=70%"):
                                gr.Pil(label="Crop")
                        with gr.Column(style="width=50%, height=70%"):
                                gr.Pil(label="Draw")
                                gr.ImagePaint(label="Draw")
                    with gr.Tab("Text"):
                        with gr.Row():
                            with gr.Column(scale=50):
                                gr.Textbox(label="", lines=8, interactive=True)            
                            with gr.Column(scale=50):
                                gr.Textbox(label="", lines=8, interactive=True)
                    with gr.Tab("Color Picker"):
                        with gr.Row():
                            with gr.Column(scale=50):
                                gr.ColorPicker(label="Color", interactive=True)            
                            with gr.Column(scale=50):
                                gr.ImagePaint(label="Draw", interactive=True)      
                    with gr.Tab("Style"):
                        style_switch=gr.Radio(["1", "2", "3"])
                        style_button=gr.Button("Load Style")

 

    
            
            
    with gr.Row():
        with gr.Column():
            with gr.Row():
                frame_num=gr.Textbox(label="Current",value=0,interactive=False)
                time_box=gr.Textbox(label="Unique Bandaid", interactive=False)
                frame_top=gr.Textbox(label="How many images? Max 20 Demo", value=10,interactive=True)
            with gr.Row():    
                model_name1 = gr.Dropdown(show_label=False, choices=[m for m in models], type="index", value=current_model, interactive=True)
                #magic_text=gr.Textbox(label="Magic Prompt",lines=3)
        with gr.Column():
            #use_short=gr.Button("Use Short Prompt")
            #see_prompt=gr.Button("Generate Magic Prompt")
            magic_text=gr.Textbox(label="Short Prompt",lines=1)
            run=gr.Button("Send it!")
 
    with gr.Tab("Bucket"):
        with gr.Column():
            with gr.Row():
                with gr.Column():
                    frames=gr.Gallery(label="Bucket o' Frames", type="filepath").style(grid=10)
                    frame_files=gr.Files()
                    frame_tar=gr.Files()

            with gr.Row():
                batch_bot1=gr.Textbox(label="BB1")
                start_frame1=gr.Textbox(label="Start Frame")                            


            
    rand_box=gr.Textbox(value="",visible=False) 
    go_box=gr.Textbox(value=0,visible=False)
    def short_prompt(inputs):
        return(inputs)

    run.click(prime_the_thing, inputs=[], outputs=[time_box,frame_num, frame_box, frame_file_box, frame_tar_box])
    go_box.change(go_fn,inputs=[],outputs=[frame_num])
    frame_num.change(the_thing, inputs=[magic_text,rand_box, model_name1, frame_num, frame_top,time_box, frame_box, frame_file_box, frame_tar_box], outputs=[frames,frame_files,frame_tar,frame_num,rand_box, frame_box, frame_file_box, frame_tar_box])
    #use_short.click(short_prompt,inputs=[input_text],outputs=magic_text)
    #see_prompt.click(text_it,inputs=[input_text],outputs=[magic_text])
    #model_name1.change(set_model,inputs=model_name1,outputs=[output1,output2,output3,output4,output5,output6,output7,output8])
   

myface.queue(concurrency_count=10)
myface.launch(enable_queue=True, inline=True, max_threads=10, show_api=False)