Spaces:
Sleeping
Sleeping
import gradio as gr | |
from utils import DeepL,Gen_image,send_email,base_model,example_data | |
from datetime import date | |
import os | |
save_loc="Gens/"+date.today().__str__()+"/" | |
os.makedirs(save_loc,exist_ok=True) | |
model_dic={} | |
model_dic["None"]={ | |
"model_loc":base_model, | |
"model_trigger":"high res, 4k", | |
} | |
model_dic["ISS MAP"]={ | |
"model_loc":"jarvissan22/iss_nikond5:6ff0c8d11e33e4e8c91b1b9175a1c03f32fb559641bbbbe7007ac07b22fc5cec", | |
"model_trigger":"Aerial photo taken from the ISS photo taken from the ISS", | |
} | |
model_dic["Anime_Galverse"]={ | |
"model_loc":"galverse/setc-t1_label:65a7ee5a8c875fe9f38111699edf72f6c07f84dda7b7be5720e843ebb9f9c876", | |
"model_trigger":"anime coloring in the style of galverse", | |
} | |
model_dic["Ukiyo-e_川瀬巴水"]={ | |
"model_loc":"jarvissan22/kawasehasui_backgrounds:a4bb8bb1beb503b02c93789381544097dcb70afc92c512ea1500e70ccf704bc4", | |
"model_trigger":"Ukiyo-e,KawaseHasu", | |
} | |
model_dic["Anime_appleseed"]={ | |
"model_loc":"jarvissan22/appleseed:37bb4cac4b257c5a6b01242163057b8d8edce6a41d07b678159bb152d10c0357", | |
"model_trigger":"anime coloring in the style of appleseed", | |
} | |
model_dic["Anime_niji"]={ | |
"model_loc":"jarvissan22/appleseed:37bb4cac4b257c5a6b01242163057b8d8edce6a41d07b678159bb152d10c0357", | |
"model_trigger":"anime coloring in the style of appleseed", | |
} | |
model_dic["FineArt_FrancoisBoucher"]={ | |
"model_loc":"brettimus/sdxl-adelaide:f2d079e9da2b9cd3b527235813f6fe0f0fe6dc815363b5dd1930112fcc442d90", | |
"model_trigger":"in style of francois boucher ", | |
} | |
gallery=[] #Gallery array to hold image outputs | |
def gradio_gen_process(img,prompt,ps=0.6,style_model="Anime_Galverse",ls=0.6,jp=None,model=base_model,model_trigger=None,save_loc=save_loc): | |
#JP Detect | |
if jp: | |
prompt=DeepL(prompt) | |
if style_model: | |
model=model_dic[style_model]["model_loc"] | |
model_trigger=model_dic[style_model]["model_trigger"] | |
if model_trigger: | |
prompt+=", "+model_trigger | |
if type(ps)==str: # error on example detail: - input.prompt_strength: Invalid type. Expected: number, given: string | |
ps=float(ps) | |
#Image gen | |
print(img) | |
try: | |
img,file_saveloc=Gen_image(prompt,img=img,ps=ps,lr=ls,model=model,save_loc=save_loc) | |
gallery.append(img) | |
except: | |
recipient_email=None | |
print("Error:Image gen fail") | |
img=None | |
pass | |
#Send email | |
#if recipient_email: | |
# send_email(file_saveloc,recipient_email,prompt=prompt) | |
# print("Email sent to ",recipient_email) | |
# else: | |
# print("Email not sent") | |
return gallery[::-1] #Flip it so new it at top #img | |
output_placeholder = gr.Label() | |
gradio_interface=gr.Interface( | |
fn=gradio_gen_process, | |
inputs=[ | |
gr.Image(value=example_data[0]["img"],type="filepath"), | |
gr.Textbox(label="Prompt"), | |
gr.Slider(minimum=0.1,maximum=1,value=0.6,label="PS:Image > Prompt"), | |
gr.Dropdown(list(model_dic.keys()),label="Style model"), | |
gr.Slider(minimum=0.1,maximum=1,value=0.6,label="LS:Style strength"), | |
gr.Checkbox(label="日本語", info="Promtは日本語ですか?"), | |
# gr.Textbox(label="Email",placeholder="") | |
], | |
outputs=[ | |
#gr.Image(label="gened image",type="pil"), | |
gr.Gallery(label="gened images",type="pil",object_fit="fill") | |
], | |
examples="Tiles/" | |
) | |
gradio_interface.launch(debug=True) |