Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -37,6 +37,7 @@ def enable_lora(lora_add):
|
|
37 |
|
38 |
async def generate_image(
|
39 |
prompt:str,
|
|
|
40 |
model:str,
|
41 |
lora_word:str,
|
42 |
width:int=768,
|
@@ -50,12 +51,14 @@ async def generate_image(
|
|
50 |
seed = int(seed)
|
51 |
print(f'prompt:{prompt}')
|
52 |
|
53 |
-
text = str(translator.translate(prompt, 'English')) + lora_word
|
|
|
54 |
|
55 |
client = AsyncInferenceClient()
|
56 |
|
57 |
image = await client.text_to_image(
|
58 |
prompt=text,
|
|
|
59 |
height=height,
|
60 |
width=width,
|
61 |
guidance_scale=scales,
|
@@ -70,6 +73,7 @@ async def gen(
|
|
70 |
prompt:str,
|
71 |
lora_add:str="",
|
72 |
lora_word:str="",
|
|
|
73 |
width:int=768,
|
74 |
height:int=1024,
|
75 |
scales:float=3.5,
|
@@ -79,22 +83,22 @@ async def gen(
|
|
79 |
):
|
80 |
model = enable_lora(lora_add)
|
81 |
print(model)
|
82 |
-
image, seed = await generate_image(prompt,model,lora_word,width,height,scales,steps,seed)
|
83 |
return image, seed
|
84 |
|
85 |
examples = [
|
86 |
["A cartoon-style blonde European-American woman wearing sunglasses stood in front of the triumphant door to take a selfie, the upper bodyartistic style","Shakker-Labs/FLUX.1-dev-LoRA-blended-realistic-illustration","artistic style blends elements of reality and illustration"],
|
87 |
["A cartoon style European woman wearing glasses is eating a table of seafood,including lobster,oysters,and other shellfish,in a well lit modern restaurant. The background of the restaurant is very blurry,and she is holding the utensils ready to eat. There is a glass of red wine and various dishes on the table. The illustrations contrast with the real food and environment,creating a unique mixed media effect and high angle perspective","Shakker-Labs/FLUX.1-dev-LoRA-blended-realistic-illustration","artistic style blends elements of reality and illustration"],
|
88 |
-
["
|
89 |
-
["
|
90 |
]
|
91 |
|
92 |
|
93 |
# Gradio Interface
|
94 |
|
95 |
with gr.Blocks(css=CSS, js=JS, theme="Nymbo/Nymbo_Theme") as demo:
|
96 |
-
gr.HTML("<h1><center>Flux
|
97 |
-
gr.HTML("<p><center>
|
98 |
with gr.Row():
|
99 |
with gr.Column(scale=4):
|
100 |
with gr.Row():
|
@@ -139,6 +143,11 @@ with gr.Blocks(css=CSS, js=JS, theme="Nymbo/Nymbo_Theme") as demo:
|
|
139 |
step=1,
|
140 |
value=-1,
|
141 |
)
|
|
|
|
|
|
|
|
|
|
|
142 |
lora_add = gr.Textbox(
|
143 |
label="Add Flux LoRA",
|
144 |
info="Copy the HF LoRA model name here",
|
@@ -171,6 +180,7 @@ with gr.Blocks(css=CSS, js=JS, theme="Nymbo/Nymbo_Theme") as demo:
|
|
171 |
prompt,
|
172 |
lora_add,
|
173 |
lora_word,
|
|
|
174 |
width,
|
175 |
height,
|
176 |
scales,
|
|
|
37 |
|
38 |
async def generate_image(
|
39 |
prompt:str,
|
40 |
+
negative_prompt:str,
|
41 |
model:str,
|
42 |
lora_word:str,
|
43 |
width:int=768,
|
|
|
51 |
seed = int(seed)
|
52 |
print(f'prompt:{prompt}')
|
53 |
|
54 |
+
text = str(translator.translate(prompt, 'English')) + "," + lora_word
|
55 |
+
negative_prompt = str(translator.translate(negative_prompt, 'English'))
|
56 |
|
57 |
client = AsyncInferenceClient()
|
58 |
|
59 |
image = await client.text_to_image(
|
60 |
prompt=text,
|
61 |
+
negative_prompt=negative_prompt,
|
62 |
height=height,
|
63 |
width=width,
|
64 |
guidance_scale=scales,
|
|
|
73 |
prompt:str,
|
74 |
lora_add:str="",
|
75 |
lora_word:str="",
|
76 |
+
negative_prompt:str="",
|
77 |
width:int=768,
|
78 |
height:int=1024,
|
79 |
scales:float=3.5,
|
|
|
83 |
):
|
84 |
model = enable_lora(lora_add)
|
85 |
print(model)
|
86 |
+
image, seed = await generate_image(prompt,negative_prompt,model,lora_word,width,height,scales,steps,seed)
|
87 |
return image, seed
|
88 |
|
89 |
examples = [
|
90 |
["A cartoon-style blonde European-American woman wearing sunglasses stood in front of the triumphant door to take a selfie, the upper bodyartistic style","Shakker-Labs/FLUX.1-dev-LoRA-blended-realistic-illustration","artistic style blends elements of reality and illustration"],
|
91 |
["A cartoon style European woman wearing glasses is eating a table of seafood,including lobster,oysters,and other shellfish,in a well lit modern restaurant. The background of the restaurant is very blurry,and she is holding the utensils ready to eat. There is a glass of red wine and various dishes on the table. The illustrations contrast with the real food and environment,creating a unique mixed media effect and high angle perspective","Shakker-Labs/FLUX.1-dev-LoRA-blended-realistic-illustration","artistic style blends elements of reality and illustration"],
|
92 |
+
["photograph, background of Earth from space, red car on the Moon watching Earth","martintomov/retrofuturism-flux","retrofuturism"],
|
93 |
+
["red sports car with `SPACE RIDER` on its frontal hood, frontal view with a person visible inside through the windshield, car is emerging from a circular radiant portal with bright orange and red hues against a dark background, sense of high-speed motion and a tunnel-like effect","martintomov/retrofuturism-flux","retrofuturism"]
|
94 |
]
|
95 |
|
96 |
|
97 |
# Gradio Interface
|
98 |
|
99 |
with gr.Blocks(css=CSS, js=JS, theme="Nymbo/Nymbo_Theme") as demo:
|
100 |
+
gr.HTML("<h1><center>Flux Lab Light</center></h1>")
|
101 |
+
gr.HTML("<p><center>Powered By HF Inference API</center></p>")
|
102 |
with gr.Row():
|
103 |
with gr.Column(scale=4):
|
104 |
with gr.Row():
|
|
|
143 |
step=1,
|
144 |
value=-1,
|
145 |
)
|
146 |
+
negative_prompt = gr.Textbox(
|
147 |
+
label="Negative prompt",
|
148 |
+
lines=1,
|
149 |
+
value="low quality"
|
150 |
+
)
|
151 |
lora_add = gr.Textbox(
|
152 |
label="Add Flux LoRA",
|
153 |
info="Copy the HF LoRA model name here",
|
|
|
180 |
prompt,
|
181 |
lora_add,
|
182 |
lora_word,
|
183 |
+
negative_prompt,
|
184 |
width,
|
185 |
height,
|
186 |
scales,
|