JarvisLabs's picture
Update app.py
8dd1ace verified
raw
history blame
2.29 kB
import gradio as gr
from utils import DeepL,Gen_image,send_email,base_model,example_data
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["Ukiyo-e_川瀬巴水"]={
"model_loc":"https://replicate.com/jarvissan22/kawasehasui_backgrounds",
"model_trigger":"Ukiyo-e,KawaseHasu",
}
model_dic["Anime_Galverse"]={
"model_loc":"galverse/setc-t1_label:65a7ee5a8c875fe9f38111699edf72f6c07f84dda7b7be5720e843ebb9f9c876",
"model_trigger":"anime coloring in the style of Galverse",
}
def gradio_gen_process(img,prompt,ps=0.6,style_model=None,ls=0.6,jp=None,recipient_email=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)
img,file_saveloc=Gen_image(prompt,img=img,ps=ps,lr=ls,model=model,save_loc=save_loc)
#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 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")
],
examples=img_loc
)
gradio_interface.launch(debug=True,share=True)