aifeifei798 commited on
Commit
a0b5620
·
verified ·
1 Parent(s): 6a7a614

Update feifeiui/feifeiui.py

Browse files
Files changed (1) hide show
  1. feifeiui/feifeiui.py +143 -143
feifeiui/feifeiui.py CHANGED
@@ -1,143 +1,143 @@
1
- import gradio as gr
2
- import numpy as np
3
- import config
4
-
5
- from feifeilib.feifeichat import feifeichat
6
- from feifeilib.feifeitexttoimg import feifeitexttoimg
7
- from feifeilib.feifeiflorence import feifeiflorence
8
-
9
- MAX_SEED = np.iinfo(np.int32).max
10
- MAX_IMAGE_SIZE = 4096
11
-
12
- css = """
13
- #col-container {
14
- width: auto;
15
- height: 750px;
16
- }
17
- """
18
-
19
-
20
- def create_ui():
21
- with gr.Blocks(css=css) as FeiFei:
22
- with gr.Row():
23
- with gr.Column(scale=1):
24
- with gr.Tab("Generator"):
25
- prompt = gr.Text(
26
- label="Prompt",
27
- show_label=False,
28
- placeholder="Enter your prompt",
29
- max_lines=12,
30
- container=False,
31
- )
32
- run_button = gr.Button("Run")
33
- result = gr.Image(label="Result",
34
- show_label=False,
35
- interactive=False)
36
-
37
- with gr.Accordion("Advanced Settings", open=False):
38
- seed = gr.Slider(
39
- label="Seed",
40
- minimum=0,
41
- maximum=MAX_SEED,
42
- step=1,
43
- value=0,
44
- )
45
-
46
- randomize_seed = gr.Checkbox(label="Randomize seed",
47
- value=True)
48
-
49
- with gr.Row():
50
- width = gr.Slider(
51
- label="Width",
52
- minimum=256,
53
- maximum=MAX_IMAGE_SIZE,
54
- step=64,
55
- value=896,
56
- )
57
-
58
- height = gr.Slider(
59
- label="Height",
60
- minimum=256,
61
- maximum=MAX_IMAGE_SIZE,
62
- step=64,
63
- value=1152,
64
- )
65
-
66
- with gr.Row():
67
- num_inference_steps = gr.Slider(
68
- label="Number of inference steps",
69
- minimum=1,
70
- maximum=50,
71
- step=1,
72
- value=4,
73
- )
74
- guidancescale = gr.Slider(
75
- label="Guidance scale",
76
- minimum=0,
77
- maximum=10,
78
- step=0.1,
79
- value=3.5,
80
- )
81
- num_strength = gr.Slider(
82
- label="strength",
83
- minimum=0,
84
- maximum=2,
85
- step=0.01,
86
- value=0.35,
87
- )
88
-
89
- with gr.Tab("Styles"):
90
- quality_select = gr.Checkbox(label="high quality")
91
- sharpened_select = gr.Checkbox(label="Sharpened",
92
- value=True)
93
- FooocusExpansion_select = gr.Checkbox(
94
- label="FooocusExpansion")
95
- styles_name = [
96
- style["name"] for style in config.style_list
97
- ]
98
- styles_Radio = gr.Dropdown(styles_name,
99
- label="Styles",
100
- multiselect=True)
101
- with gr.Tab("Florence-2"):
102
- with gr.Row():
103
- with gr.Column():
104
- output_text = gr.Textbox(label="Output Text",
105
- container=False)
106
- florence_btn = gr.Button(value="Florence")
107
- with gr.Column():
108
- input_img = gr.Image(label="Input Picture")
109
- with gr.Column(scale=3, elem_id="col-container"):
110
- gr.ChatInterface(
111
- feifeichat,
112
- type="messages",
113
- multimodal=True,
114
- additional_inputs=[
115
- gr.Checkbox(label="Feifei"),
116
- ],
117
- )
118
-
119
- run_button.click(
120
- fn=feifeitexttoimg, # Function to run for this button
121
- inputs=[
122
- prompt,
123
- quality_select,
124
- sharpened_select,
125
- styles_Radio,
126
- FooocusExpansion_select,
127
- seed,
128
- randomize_seed,
129
- width,
130
- height,
131
- num_inference_steps,
132
- guidancescale,
133
- num_strength,
134
- ],
135
- outputs=[result, seed],
136
- )
137
-
138
- florence_btn.click(
139
- fn=feifeiflorence, # Function to run when the button is clicked
140
- inputs=[input_img], # Input components for the function
141
- outputs=[output_text], # Output component for the function
142
- )
143
- return FeiFei
 
1
+ import gradio as gr
2
+ import numpy as np
3
+ import config
4
+
5
+ from feifeilib.feifeichat import feifeichat
6
+ from feifeilib.feifeitexttoimg import feifeitexttoimg
7
+ from feifeilib.feifeiflorence import feifeiflorence
8
+
9
+ MAX_SEED = np.iinfo(np.int32).max
10
+ MAX_IMAGE_SIZE = 4096
11
+
12
+ css = """
13
+ #col-container {
14
+ width: auto;
15
+ height: 750px;
16
+ }
17
+ """
18
+
19
+
20
+ def create_ui():
21
+ with gr.Blocks(css=css) as FeiFei:
22
+ with gr.Row():
23
+ with gr.Column(scale=1):
24
+ with gr.Tab("Generator"):
25
+ prompt = gr.Text(
26
+ label="Prompt",
27
+ show_label=False,
28
+ placeholder="Enter your prompt",
29
+ max_lines=12,
30
+ container=False,
31
+ )
32
+ run_button = gr.Button("Run")
33
+ result = gr.Image(label="Result",
34
+ show_label=False,
35
+ interactive=False)
36
+
37
+ with gr.Accordion("Advanced Settings", open=False):
38
+ seed = gr.Slider(
39
+ label="Seed",
40
+ minimum=0,
41
+ maximum=MAX_SEED,
42
+ step=1,
43
+ value=0,
44
+ )
45
+
46
+ randomize_seed = gr.Checkbox(label="Randomize seed",
47
+ value=True)
48
+
49
+ with gr.Row():
50
+ width = gr.Slider(
51
+ label="Width",
52
+ minimum=256,
53
+ maximum=MAX_IMAGE_SIZE,
54
+ step=64,
55
+ value=896,
56
+ )
57
+
58
+ height = gr.Slider(
59
+ label="Height",
60
+ minimum=256,
61
+ maximum=MAX_IMAGE_SIZE,
62
+ step=64,
63
+ value=1152,
64
+ )
65
+
66
+ with gr.Row():
67
+ num_inference_steps = gr.Slider(
68
+ label="Number of inference steps",
69
+ minimum=1,
70
+ maximum=50,
71
+ step=1,
72
+ value=4,
73
+ )
74
+ guidancescale = gr.Slider(
75
+ label="Guidance scale",
76
+ minimum=0,
77
+ maximum=10,
78
+ step=0.1,
79
+ value=3.5,
80
+ )
81
+ num_strength = gr.Slider(
82
+ label="strength",
83
+ minimum=0,
84
+ maximum=2,
85
+ step=0.01,
86
+ value=0.35,
87
+ )
88
+
89
+ with gr.Tab("Styles"):
90
+ quality_select = gr.Checkbox(label="high quality")
91
+ sharpened_select = gr.Checkbox(label="Sharpened")
92
+ FooocusExpansion_select = gr.Checkbox(
93
+ label="FooocusExpansion")
94
+ styles_name = [
95
+ style["name"] for style in config.style_list
96
+ ]
97
+ styles_Radio = gr.Dropdown(styles_name,
98
+ label="Styles",
99
+ multiselect=True)
100
+ with gr.Tab("Florence-2"):
101
+ with gr.Row():
102
+ with gr.Column():
103
+ output_text = gr.Textbox(label="Output Text",
104
+ max_lines=12,
105
+ container=False)
106
+ florence_btn = gr.Button(value="Florence")
107
+ with gr.Column():
108
+ input_img = gr.Image(label="Input Picture")
109
+ with gr.Column(scale=3, elem_id="col-container"):
110
+ gr.ChatInterface(
111
+ feifeichat,
112
+ type="messages",
113
+ multimodal=True,
114
+ additional_inputs=[
115
+ gr.Checkbox(label="Feifei"),
116
+ ],
117
+ )
118
+
119
+ run_button.click(
120
+ fn=feifeitexttoimg, # Function to run for this button
121
+ inputs=[
122
+ prompt,
123
+ quality_select,
124
+ sharpened_select,
125
+ styles_Radio,
126
+ FooocusExpansion_select,
127
+ seed,
128
+ randomize_seed,
129
+ width,
130
+ height,
131
+ num_inference_steps,
132
+ guidancescale,
133
+ num_strength,
134
+ ],
135
+ outputs=[result, seed],
136
+ )
137
+
138
+ florence_btn.click(
139
+ fn=feifeiflorence, # Function to run when the button is clicked
140
+ inputs=[input_img], # Input components for the function
141
+ outputs=[output_text], # Output component for the function
142
+ )
143
+ return FeiFei