File size: 3,984 Bytes
3bd82ac
8dd1ace
44fe01c
40abfd4
44fe01c
 
3bd82ac
 
 
5103ff7
 
 
 
 
3bd82ac
 
 
 
 
67c6fae
 
 
 
 
 
5103ff7
 
43bcbe1
 
3bd82ac
3742e25
3bd82ac
 
 
3742e25
 
 
3bd82ac
 
3742e25
 
 
 
 
f7ff2ef
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2489dc3
 
 
 
3742e25
 
e3e9cd0
5103ff7
 
cafe03e
3bd82ac
 
 
 
 
 
 
 
 
 
 
 
 
 
e41e7bb
 
16f2c5e
e41e7bb
 
 
 
 
 
 
3bd82ac
2129c64
 
 
 
 
3bd82ac
e41e7bb
 
2489dc3
3bd82ac
 
 
 
 
 
 
 
 
 
 
 
 
2129c64
3bd82ac
 
cb6bc8d
f6294dd
3bd82ac
2f637bf
3bd82ac
5103ff7
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
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["MAMA_V2"]={
    "model_loc":"galverse/mama-v2:b3c6afa83895d1d590679c2d8d3efa6ce26647e7a2d760b389ebf1546eb792bd",
    "model_trigger": "sks, anime style, in the style of galverse",
}

model_dic["MAMA_V1"]={
    "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["cyber-punk"]={
    "model_loc":"fofr/sdxl-80s-cyberpunk:356b6cbe7f0011970aaa0bfe7a9fcd2e6cd3b84b35d0fd09a840ac1bfc7020d9",
     "model_trigger":"80s cyberpunk in the style of TOK",
}


model_dic["SD3"]={
    "model_loc":"stability-ai/stable-diffusion-3",
    "model_trigger":""
}

model_dic["ms-paint"]={
    "model_loc":"fofr/sdxl-ms-paint:8e36d00024aa9a55c7d8ef0f82ccd82ab4d3225d1e702149179498258177ca3f",
    "model_trigger":"MS-paint"
}

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="MAMA_V2",ls=0.7,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)