File size: 12,341 Bytes
76ad7cc
 
4b1d965
 
 
 
fab0d6b
da6bf69
4b1d965
14d8fe5
cc237a8
4b1d965
 
 
 
 
1199606
4b1d965
 
 
1199606
4b1d965
 
 
1199606
4b1d965
 
 
1199606
4b1d965
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
553cdcc
4b1d965
 
 
 
ed225e8
4b1d965
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ed225e8
4b1d965
 
553cdcc
76ad7cc
 
 
8792f6c
94cbc2e
 
 
4243534
 
 
 
 
 
 
 
 
 
d4c04cb
4243534
 
6cbef21
 
 
 
 
 
 
 
 
 
b1f206b
0daeb41
 
 
 
 
a305c25
6b34801
 
0daeb41
 
 
78f19fc
 
6b34801
78f19fc
6b34801
78f19fc
49a5657
ed225e8
1e8cdc8
 
78f19fc
 
 
7028f7d
49a5657
6b34801
49a5657
0363582
94cbc2e
49a5657
0363582
49a5657
 
0363582
7791875
0363582
 
 
 
 
 
 
003a717
675fc8f
f70ee0b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
675fc8f
78f19fc
 
0daeb41
29f6329
 
0daeb41
29f6329
 
0daeb41
29f6329
 
0daeb41
29f6329
 
0daeb41
29f6329
0daeb41
29f6329
 
0daeb41
29f6329
 
470c9d3
29f6329
 
470c9d3
29f6329
470c9d3
0daeb41
29f6329
0daeb41
78f19fc
4243534
5ad1ff9
4243534
 
 
 
 
 
 
 
803b8b6
08553ac
0daeb41
 
 
cc237a8
29f6329
ed225e8
553cdcc
94cbc2e
c52d177
8792f6c
 
f53e8e5
8792f6c
 
4b1d965
 
33fad3e
 
 
 
8792f6c
b57939b
8792f6c
c52d177
80b0afc
397283a
8792f6c
14d8fe5
 
 
 
 
d983ba7
 
14d8fe5
 
 
 
 
 
 
 
397283a
6a228d3
 
 
 
 
 
 
 
876f731
c52d177
10cf011
c52d177
 
 
1bb0bee
c52d177
 
 
 
 
 
 
ed225e8
be85ad3
ed225e8
be85ad3
c52d177
 
 
 
 
876f731
 
e0b2de7
d983ba7
 
 
 
 
 
 
a44ac0c
d983ba7
 
21c48d1
a44ac0c
db8eaeb
d983ba7
876f731
 
 
 
 
 
a44ac0c
d983ba7
a44ac0c
 
735f7bd
 
876f731
 
db8eaeb
876f731
c52d177
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
import gradio as gr

import os 
import sys
from pathlib import Path
import time
import random
from PIL import Image

m_pdir="/content/drive/MyDrive/aipic001/"

models =[
    "",
    "CompVis/stable-diffusion-v1-4",
    "runwayml/stable-diffusion-v1-5",
    "prompthero/openjourney",
#4    
    "stabilityai/stable-diffusion-2-1",
    "stabilityai/stable-diffusion-2-1-base",
    "andite/anything-v4.0",

    "Linaqruf/anything-v3.0",
    "eimiss/EimisAnimeDiffusion_1.0v",
    "nitrosocke/Nitro-Diffusion",
#10
    "wavymulder/portraitplus",
    "22h/vintedois-diffusion-v0-1",
    "dreamlike-art/dreamlike-photoreal-2.0",
#11
    "dreamlike-art/dreamlike-diffusion-1.0",
    "wavymulder/Analog-Diffusion",
    "nitrosocke/redshift-diffusion",
    "claudfuen/photorealistic-fuen-v1",
    "prompthero/openjourney-v2",
    "johnslegers/epic-diffusion",
    "nitrosocke/Arcane-Diffusion",
    "darkstorm2150/Protogen_x5.8_Official_Release",

]

model_1=models[1]
model_2=models[2]
model_3=models[3]
model_4=models[4]
model_5=models[5]
model_6=models[6]
model_7=models[7]
model_8=models[8]
model_9=models[9]
model_10=models[10]
model_11=models[11]
model_12=models[12]
model_13=models[13]
model_14=models[14]
model_15=models[15]
model_16=models[16]
model_17=models[17]
model_18=models[18]
model_19=models[19]
model_20=models[20]


text_gen=gr.Interface.load("spaces/Omnibus/MagicPrompt-Stable-Diffusion_link",live=True, preprocess=True)

proc1=gr.Interface.load(f"models/{model_1}",live=False,preprocess=True, postprocess=False)
proc2=gr.Interface.load(f"models/{model_2}",live=False,preprocess=True, postprocess=False)
"""
proc3=gr.Interface.load(f"models/{model_3}",live=False,preprocess=True, postprocess=False)
proc4=gr.Interface.load(f"models/{model_4}",live=False,preprocess=True, postprocess=False)
proc5=gr.Interface.load(f"models/{model_5}",live=False,preprocess=True, postprocess=False)
proc6=gr.Interface.load(f"models/{model_6}",live=False,preprocess=True, postprocess=False)
proc7=gr.Interface.load(f"models/{model_7}",live=False,preprocess=True, postprocess=False)
proc8=gr.Interface.load(f"models/{model_8}",live=False,preprocess=True, postprocess=False)
proc9=gr.Interface.load(f"models/{model_9}",live=False,preprocess=True, postprocess=False)
proc10=gr.Interface.load(f"models/{model_10}",live=False,preprocess=True, postprocess=False)
proc11=gr.Interface.load(f"models/{model_11}",live=False,preprocess=True, postprocess=False)
proc12=gr.Interface.load(f"models/{model_12}",live=False,preprocess=True, postprocess=False)
proc13=gr.Interface.load(f"models/{model_13}",live=False,preprocess=True, postprocess=False)
proc14=gr.Interface.load(f"models/{model_14}",live=False,preprocess=True, postprocess=False)
proc15=gr.Interface.load(f"models/{model_15}",live=False,preprocess=True, postprocess=False)
proc16=gr.Interface.load(f"models/{model_16}",live=False,preprocess=True, postprocess=False)
proc17=gr.Interface.load(f"models/{model_17}",live=False,preprocess=True, postprocess=False)
proc18=gr.Interface.load(f"models/{model_18}",live=False,preprocess=True, postprocess=False)
proc19=gr.Interface.load(f"models/{model_19}",live=False,preprocess=True, postprocess=False)
proc20=gr.Interface.load(f"models/{model_20}",live=False,preprocess=True, postprocess=False)
"""


"""
def greet(name):
    return "Hello " + name + "!!"

iface = gr.Interface(fn=greet, inputs="text", outputs="text")

iface.launch()
"""
state_info = gr.Textbox(label="State", show_label=False, max_lines=2).style(container=False)

def update_state_info(old_state):
  if state and state != old_state:
    return gr.update(value=state)

def update_state(new_state):
  global state
  state = new_state
    
def pipe_callback(step: int, timestep: int, latents: float):#torch.FloatTensor):
    update_state(f"{step}/{current_steps} steps")#\nTime left, sec: {timestep/100:.0f}")

def randStr():
    pp=["a","b","c","d","e","f","g","h"]
    str="";
    str+=random.choice(pp)+random.choice(pp)+random.choice(pp)+random.choice(pp)
    str+=random.choice(pp)+random.choice(pp)+random.choice(pp)+random.choice(pp)
    str+=random.choice(pp)+random.choice(pp)+random.choice(pp)+random.choice(pp)
    str+=random.choice(pp)+random.choice(pp)+random.choice(pp)+random.choice(pp)
    str+=random.choice(pp)+random.choice(pp)+random.choice(pp)+random.choice(pp)
    return str
    
m_ddStr=["a","b","c","d","e","f","g","h"]
def saveImg(imga,filename):
    try:
        img = Image.open(imga) # ์ด๋ฏธ์ง€ ํŒŒ์ผ๋ช… ๋˜๋Š” ํŒŒ์ผ ์œ„์น˜
        img=img.convert("RGB")
        img.save(filename,"JPEG")
        print("save img "+filename)
        print("save img "+filename)
        print("------------")
        return True
    except:
        return False
def imgTry(funcAny,prompt,filename):
    try:
        print("--------------try")
        output=funcAny(prompt)
        print("prompt "+prompt)
        saveImg(output,m_pdir+filename)
        time.sleep(1)
        return output
    except Exception as e:
        print("error "+prompt+" ",e)
        print("e "+filename)
        print("------------")
        return False

global m_num,m_btime
m_num=0        
m_btime=time.time()

def image_mod(image):
    global m_num,m_btime
    
    print("image_mod "+str(m_num)+str(time.time()-m_btime))
    m_btime=time.time()
    
    while True: 
        m_num += 1
        ppStr=random.choice(m_ddStr)+random.choice(m_ddStr)+random.choice(m_ddStr)+random.choice(m_ddStr)+random.choice(m_ddStr)+random.choice(m_ddStr)
        output1=imgTry(proc1,"full body girl "+ppStr,'bbba_01_'+str(m_num)+"_"+ppStr+'.jpg')
        ppStr=random.choice(m_ddStr)+random.choice(m_ddStr)+random.choice(m_ddStr)+random.choice(m_ddStr)+random.choice(m_ddStr)+random.choice(m_ddStr)
        output1=imgTry(proc1,"full body girl "+ppStr,'bbbb_01_'+str(m_num)+"_"+ppStr+'.jpg')
        ppStr=random.choice(m_ddStr)+random.choice(m_ddStr)+random.choice(m_ddStr)+random.choice(m_ddStr)+random.choice(m_ddStr)+random.choice(m_ddStr)
        output1=imgTry(proc1,"full body girl "+ppStr,'bbbc_01_'+str(m_num)+"_"+ppStr+'.jpg')
    
    """
        imgTry(proc2,"full body girl "+ppStr,'save_02_'+str(m_num)+"_"+ppStr+'.jpg')
        imgTry(proc3,"full body girl "+ppStr,'save_03_'+str(m_num)+"_"+ppStr+'.jpg')
        imgTry(proc4,"full body girl "+ppStr,'save_04_'+str(m_num)+"_"+ppStr+'.jpg')
        imgTry(proc5,"full body girl "+ppStr,'save_05_'+str(m_num)+"_"+ppStr+'.jpg')
        imgTry(proc6,"full body girl "+ppStr,'save_06_'+str(m_num)+"_"+ppStr+'.jpg')
        imgTry(proc7,"full body girl "+ppStr,'save_07_'+str(m_num)+"_"+ppStr+'.jpg')
        imgTry(proc8,"full body girl "+ppStr,'save_08_'+str(m_num)+"_"+ppStr+'.jpg')
        imgTry(proc9,"full body girl "+ppStr,'save_09_'+str(m_num)+"_"+ppStr+'.jpg')
        imgTry(proc10,"full body girl "+ppStr,'save_10_'+str(m_num)+"_"+ppStr+'.jpg')
        imgTry(proc11,"full body girl "+ppStr,'save_11_'+str(m_num)+"_"+ppStr+'.jpg')
        imgTry(proc12,"full body girl "+ppStr,'save_12_'+str(m_num)+"_"+ppStr+'.jpg')
        imgTry(proc13,"full body girl "+ppStr,'save_13_'+str(m_num)+"_"+ppStr+'.jpg')
        imgTry(proc14,"full body girl "+ppStr,'save_14_'+str(m_num)+"_"+ppStr+'.jpg')
        imgTry(proc15,"full body girl "+ppStr,'save_15_'+str(m_num)+"_"+ppStr+'.jpg')
        imgTry(proc16,"full body girl "+ppStr,'save_16_'+str(m_num)+"_"+ppStr+'.jpg')
        imgTry(proc17,"full body girl "+ppStr,'save_17_'+str(m_num)+"_"+ppStr+'.jpg')
        imgTry(proc18,"full body girl "+ppStr,'save_18_'+str(m_num)+"_"+ppStr+'.jpg')
        imgTry(proc19,"full body girl "+ppStr,'save_19_'+str(m_num)+"_"+ppStr+'.jpg')
        imgTry(proc20,"full body girl "+ppStr,'save_20_'+str(m_num)+"_"+ppStr+'.jpg')
    """

    """
    output1=proc1("full body girl "+ppStr)
    saveImg(output1,m_pdir+'save_1_'+ppStr+'.jpg')
    
    output2=proc2("full body girl "+ppStr)
    saveImg(output2,m_pdir+'save_2_'+ppStr+'.jpg')
    
    output3=proc3("full body girl "+ppStr)
    saveImg(output3,m_pdir+'save_3_'+ppStr+'.jpg')
    
    output4=proc4("full body girl "+ppStr)
    saveImg(output4,m_pdir+'save_4_'+ppStr+'.jpg')
    
    output5=proc5("full body girl "+ppStr)
    saveImg(output5,m_pdir+'save_5_'+ppStr+'.jpg')
    output6=proc6("full body girl "+ppStr)
    saveImg(output6,m_pdir+'save_6_'+ppStr+'.jpg')
    
    output7=proc7("full body girl "+ppStr)
    saveImg(output7,m_pdir+'save_7_'+ppStr+'.jpg')
    
    output8=proc8("full body girl "+ppStr)
    saveImg(output8,m_pdir+'save_8_'+ppStr+'.jpg')
    
    output9=proc9("full body girl "+ppStr)
    saveImg(output9,m_pdir+'save_9_'+ppStr+'.jpg')
    
    output11=proc11("full body girl "+ppStr)
    saveImg(output11,m_pdir+'save_11_'+ppStr+'.jpg')
    
    
    output1 = proc11(
      "full body sexy girl",
      negative_prompt = "bad anatomy",
      num_images_per_prompt=1,
      num_inference_steps = int(10),
      guidance_scale = 25,
      width = 512,
      height = 800,
      generator = 0,
      callback=pipe_callback)
    """
    #output1.save("save_"+ppStr+".png")
    #img = Image.open(output1) # ์ด๋ฏธ์ง€ ํŒŒ์ผ๋ช… ๋˜๋Š” ํŒŒ์ผ ์œ„์น˜
    #img=img.convert("RGB")
    #img.save('save_'+ppStr+'.jpg',"JPEG")
    

    return output1
    #return image.rotate(45)

"""
demo = gr.Interface(
    image_mod,
    
    gr.Image(type="pil"),
    "image",
    flagging_options=["blurry", "incorrect", "other"],
    examples=[
        #os.path.join(os.path.dirname(__file__), "images/cheetah1.jpg"),
        #os.path.join(os.path.dirname(__file__), "images/lion.jpg"),
        #os.path.join(os.path.dirname(__file__), "images/logo.png"),
        #os.path.join(os.path.dirname(__file__), "images/tower.jpg"),
    ],
    
)
"""
#demo.load(update_state_info, inputs=state_info, outputs=state_info, every=0.5, show_progress=False)


def saveTest():
    try:
        img = Image.open("nsfw.PNG")
        img=img.convert("RGB")
        #img.show() # ์ด๋ฏธ์ง€ ํ™•์ธ
        img.save('memic001_save_01.jpg',"JPEG") # ํ˜„์žฌ ํ™˜๊ฒฝ์— memi_save๋ผ๋Š” ์ด๋ฆ„์œผ๋กœ ์ €์žฅ
        img.save(m_pdir+'memicb001_save_01.jpg',"JPEG") # ํ˜„์žฌ ํ™˜๊ฒฝ์— memi_save๋ผ๋Š” ์ด๋ฆ„์œผ๋กœ ์ €์žฅ

        return True
    except:
        return False
        

#image_mod(img)
saveTest()

def is_google_colab():
    try:
        import google.colab
        return True
    except:
        return False

is_colab=is_google_colab()


def sesh_start(arg01):
    img = Image.open("nsfw.PNG")
    img2=image_mod(img)
    return img2
    
with gr.Blocks() as demo:
    with gr.Row():
        with gr.Column():
            english = gr.Textbox(label="English text")
            translate_btn = gr.Button(value="Translate")
        with gr.Column():
            german = gr.Textbox(label="German Text")
        with gr.Row():
            imag1=gr.Image()
            
    translate_btn.click(sesh_start,inputs=english,outputs=imag1)#,gr.Image(type="pil"),"image")
   

demo.launch(debug=is_colab, share=is_colab) 

"""
def emb():
    with gr.Blocks(css="cake.css") as myface:
        gr.HTML("<head><meta http-equiv='refresh' content='180'></head>")
        run=gr.Button("Launch")

    with gr.Row():
        aoutput17=gr.Image(label=(f"{model_17}"),visible=True)
        aoutput18=gr.Image(label=(f"{model_18}"),visible=True)
        aoutput19=gr.Image(label=(f"{model_19}"),visible=True)
        aoutput20=gr.Image(label=(f"{model_20}"),visible=True)
    with gr.Row():#(visible=False):
        start_box=gr.Number(interactive=False)
        end_box=gr.Number(interactive=False)
        #prompt=gr.Textbox(label="Text to Image",visible=True)
        #tog_box=gr.Textbox(value=0,interactive=False)
        #tog_box2=gr.Textbox(value2="aaaa",interactive=False)

    def sesh_start():
        img = Image.open("nsfw.PNG")
        image_mod(img)
        #t = time.gmtime()
        t_stamp = time.time()
        #current_time = time.strftime("%H:%M:%S", t)
        return #gr.update(value=t_stamp),gr.update(value=t_stamp),gr.update(value=0)
    
    #run.click(sesh_start,None,[start_box,end_box,tog_box])
    run.click(sesh_start)
    myface.queue(concurrency_count=400,status_update_rate=1)
    myface.launch(debug=is_colab, share=is_colab,inline=True,show_api=False)
#demo.launch(debug=is_colab, share=is_colab) 
#(inline=True,show_api=False)
##############################################
emb()
"""