|
|
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", |
|
|
|
|
|
"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", |
|
|
|
|
|
"wavymulder/portraitplus", |
|
|
"22h/vintedois-diffusion-v0-1", |
|
|
"dreamlike-art/dreamlike-photoreal-2.0", |
|
|
|
|
|
"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): |
|
|
update_state(f"{step}/{current_steps} steps") |
|
|
|
|
|
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) |
|
|
""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return output1 |
|
|
|
|
|
|
|
|
""" |
|
|
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"), |
|
|
], |
|
|
|
|
|
) |
|
|
""" |
|
|
|
|
|
|
|
|
|
|
|
def saveTest(): |
|
|
try: |
|
|
img = Image.open("nsfw.PNG") |
|
|
img=img.convert("RGB") |
|
|
|
|
|
img.save('memic001_save_01.jpg',"JPEG") |
|
|
img.save(m_pdir+'memicb001_save_01.jpg',"JPEG") |
|
|
|
|
|
return True |
|
|
except: |
|
|
return False |
|
|
|
|
|
|
|
|
|
|
|
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) |
|
|
|
|
|
|
|
|
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() |
|
|
""" |