Spaces:
No application file
No application file
Delete portraitUIFree.py
Browse files- portraitUIFree.py +0 -78
portraitUIFree.py
DELETED
@@ -1,78 +0,0 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
import yaml
|
3 |
-
import os
|
4 |
-
|
5 |
-
def translate(t,a,b):
|
6 |
-
result="none";
|
7 |
-
for i,f in enumerate(a):
|
8 |
-
if f==t:
|
9 |
-
#print(i);
|
10 |
-
#print(a[i]);
|
11 |
-
result=b[i];
|
12 |
-
break;
|
13 |
-
return result;
|
14 |
-
|
15 |
-
#dir = os.path.dirname(__file__); # get current script path
|
16 |
-
#configfile=dir+'\config_en.yml';
|
17 |
-
configfile='config_en.yml';
|
18 |
-
print(configfile)
|
19 |
-
#configfile = './config.yml';
|
20 |
-
#configfile = "d:/MyProjects/python/examples/gradio/sdwebui/config.yml";
|
21 |
-
|
22 |
-
with open(configfile, 'r', encoding="utf8") as f:
|
23 |
-
config = yaml.safe_load(f)
|
24 |
-
|
25 |
-
#import pprint
|
26 |
-
#pp = pprint.PrettyPrinter(indent=1)
|
27 |
-
#pp.pprint(config)
|
28 |
-
|
29 |
-
p_form=config['form'];
|
30 |
-
p_object=config['actorName'];
|
31 |
-
p_lens=config['lens'];
|
32 |
-
p_lighting=config['lighting'];
|
33 |
-
|
34 |
-
gprompt=""
|
35 |
-
for p in config['templatePrompt']:
|
36 |
-
gprompt += p;
|
37 |
-
|
38 |
-
translation=config['translation'];
|
39 |
-
#print(translation[0])
|
40 |
-
t_form=translation[0]['form'];
|
41 |
-
#print(t_form);
|
42 |
-
|
43 |
-
UI_Text=config['UI_Text'];
|
44 |
-
UI=UI_Text[0]['UI'];
|
45 |
-
#print(UI['label']);
|
46 |
-
#print(UI['info']);
|
47 |
-
UI_Label=UI['label'];
|
48 |
-
UI_Info=UI['info'];
|
49 |
-
|
50 |
-
#import sys
|
51 |
-
#sys.exit();
|
52 |
-
|
53 |
-
def prompt_builder(p1, p2, p3, p4):
|
54 |
-
pp1=translate(p1,t_form,p_form);
|
55 |
-
dprompt = gprompt.format(form=pp1,object=p2,lens=p3,lighting=p4);
|
56 |
-
print(dprompt)
|
57 |
-
return dprompt;
|
58 |
-
|
59 |
-
demo = gr.Interface(
|
60 |
-
prompt_builder,
|
61 |
-
[
|
62 |
-
gr.Radio( t_form, label=UI_Label[0], info=UI_Info[0]),
|
63 |
-
gr.Textbox(label=UI_Label[1], info=UI_Info[1]),
|
64 |
-
gr.Radio( p_lens, label=UI_Label[2], info=UI_Info[2]),
|
65 |
-
gr.Dropdown( p_lighting, label=UI_Label[3], info=UI_Info[3]),
|
66 |
-
],
|
67 |
-
"text",
|
68 |
-
examples=[
|
69 |
-
[t_form[0],"Harry Potter","85mm lens,f8","Studio lighting"],
|
70 |
-
[t_form[0],"Hermione Granger","85mm lens,f8","Studio lighting"],
|
71 |
-
[t_form[1],"Hermione Granger","85mm lens,f8","purple neon lighting"],
|
72 |
-
[t_form[2],"Ron Weasley","24mm lens","nostalgic lighting"]
|
73 |
-
]
|
74 |
-
)
|
75 |
-
|
76 |
-
if __name__ == "__main__":
|
77 |
-
#demo.launch(share=True)
|
78 |
-
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|