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

Upload 5 files

Browse files
feifeilib/feifeiflorence.py CHANGED
@@ -7,6 +7,7 @@ from transformers import (
7
  )
8
  import torch
9
  import subprocess
 
10
 
11
  subprocess.run(
12
  "pip install flash-attn --no-build-isolation",
@@ -54,4 +55,6 @@ def feifeiflorence(
54
  generated_text,
55
  task=task_prompt,
56
  image_size=(image.width, image.height))
57
- return parsed_answer["<MORE_DETAILED_CAPTION>"]
 
 
 
7
  )
8
  import torch
9
  import subprocess
10
+ from feifeilib.feifeitexttoimg import feifeitexttoimg
11
 
12
  subprocess.run(
13
  "pip install flash-attn --no-build-isolation",
 
55
  generated_text,
56
  task=task_prompt,
57
  image_size=(image.width, image.height))
58
+ out_text=parsed_answer["<MORE_DETAILED_CAPTION>"]
59
+ out_img=feifeitexttoimg(out_text)
60
+ return out_text,out_img
feifeilib/feifeitexttoimg.py CHANGED
@@ -20,27 +20,25 @@ MAX_SEED = np.iinfo(np.int32).max
20
  # 去除每行末尾的换行符
21
  artists = [artist.strip() for artist in artists]
22
 
23
-
24
  @spaces.GPU()
25
  def feifeitexttoimg(
26
  prompt,
27
- quality_select,
28
- sharpened_select,
29
- styles_Radio,
30
- FooocusExpansion_select,
31
- seed=42,
32
  randomize_seed=False,
33
- width=1024,
34
- height=1024,
35
  num_inference_steps=4,
36
  guidance_scale=3.5,
37
  num_strength=0.35,
38
  progress=gr.Progress(track_tqdm=True),
39
  ):
40
- guidance_scale = 3.5
41
  if randomize_seed:
42
  seed = random.randint(0, MAX_SEED)
43
-
44
  generator = torch.Generator().manual_seed(seed)
45
  if not prompt:
46
  prompt = "the photo is a 18 yo jpop girl is looking absolutely adorable and gorgeous, with a playful and mischievous grin, her eyes twinkling with joy. art by __artist__ and __artist__"
 
20
  # 去除每行末尾的换行符
21
  artists = [artist.strip() for artist in artists]
22
 
 
23
  @spaces.GPU()
24
  def feifeitexttoimg(
25
  prompt,
26
+ quality_select=False,
27
+ sharpened_select=False,
28
+ styles_Radio=["(None)"],
29
+ FooocusExpansion_select=False,
30
+ seed=random.randint(0, MAX_SEED),
31
  randomize_seed=False,
32
+ width=896,
33
+ height=1152,
34
  num_inference_steps=4,
35
  guidance_scale=3.5,
36
  num_strength=0.35,
37
  progress=gr.Progress(track_tqdm=True),
38
  ):
39
+
40
  if randomize_seed:
41
  seed = random.randint(0, MAX_SEED)
 
42
  generator = torch.Generator().manual_seed(seed)
43
  if not prompt:
44
  prompt = "the photo is a 18 yo jpop girl is looking absolutely adorable and gorgeous, with a playful and mischievous grin, her eyes twinkling with joy. art by __artist__ and __artist__"
feifeiui/feifeiui.py CHANGED
@@ -1,143 +1,150 @@
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
 
 
 
 
 
 
 
 
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
+ show_label=False,
105
+ container=False)
106
+ florence_btn = gr.Button(value="Florence")
107
+
108
+ with gr.Column(scale=1):
109
+ input_img = gr.Image(label="Input Picture",
110
+ show_label=False)
111
+ with gr.Column(scale=1):
112
+ output_img = gr.Image(label="Input Picture",
113
+ interactive=False,
114
+ show_label=False)
115
+ with gr.Column(scale=3, elem_id="col-container"):
116
+ gr.ChatInterface(
117
+ feifeichat,
118
+ type="messages",
119
+ multimodal=True,
120
+ additional_inputs=[
121
+ gr.Checkbox(label="Feifei"),
122
+ ],
123
+ )
124
+
125
+ run_button.click(
126
+ fn=feifeitexttoimg, # Function to run for this button
127
+ inputs=[
128
+ prompt,
129
+ quality_select,
130
+ sharpened_select,
131
+ styles_Radio,
132
+ FooocusExpansion_select,
133
+ seed,
134
+ randomize_seed,
135
+ width,
136
+ height,
137
+ num_inference_steps,
138
+ guidancescale,
139
+ num_strength,
140
+ ],
141
+ outputs=[result, seed],
142
+ )
143
+
144
+ florence_btn.click(
145
+ fn=feifeiflorence, # Function to run when the button is clicked
146
+ inputs=[input_img], # Input components for the function
147
+ outputs=[output_text,
148
+ output_img], # Output component for the function
149
+ )
150
+ return FeiFei