Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -26,7 +26,8 @@ qwen_model = Qwen2VLForConditionalGeneration.from_pretrained(
|
|
26 |
).to(device).eval()
|
27 |
qwen_processor = AutoProcessor.from_pretrained("prithivMLmods/JSONify-Flux", trust_remote_code=True)
|
28 |
|
29 |
-
|
|
|
30 |
|
31 |
MAX_SEED = np.iinfo(np.int32).max
|
32 |
MAX_IMAGE_SIZE = 2048
|
@@ -96,7 +97,6 @@ def process_workflow(image, text_prompt, use_enhancer, seed, randomize_seed, wid
|
|
96 |
|
97 |
generator = torch.Generator(device=device).manual_seed(seed)
|
98 |
|
99 |
-
# Clear GPU cache before generating the image
|
100 |
torch.cuda.empty_cache()
|
101 |
|
102 |
try:
|
@@ -138,12 +138,34 @@ title = """<h1 align="center">FLUX.1-dev with Qwen2VL Captioner and Prompt Enhan
|
|
138 |
<p><center>
|
139 |
<a href="https://huggingface.co/black-forest-labs/FLUX.1-dev" target="_blank">[FLUX.1-dev Model]</a>
|
140 |
<a href="https://huggingface.co/prithivMLmods/JSONify-Flux" target="_blank">[JSONify Flux Model]</a>
|
141 |
-
<a href="https://huggingface.co/
|
142 |
<p align="center">Create long prompts from images or enhance your short prompts with prompt enhancer</p>
|
143 |
</center></p>
|
144 |
"""
|
145 |
|
146 |
with gr.Blocks(css=custom_css) as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
gr.HTML(title)
|
148 |
|
149 |
with gr.Row():
|
@@ -159,9 +181,9 @@ with gr.Blocks(css=custom_css) as demo:
|
|
159 |
width = gr.Slider(label="Width", minimum=256, maximum=MAX_IMAGE_SIZE, step=32, value=512)
|
160 |
height = gr.Slider(label="Height", minimum=256, maximum=MAX_IMAGE_SIZE, step=32, value=512)
|
161 |
guidance_scale = gr.Slider(label="Guidance Scale", minimum=1, maximum=15, step=0.1, value=3.5)
|
162 |
-
num_inference_steps = gr.Slider(label="Inference Steps", minimum=1, maximum=50, step=1, value=
|
163 |
|
164 |
-
generate_btn = gr.Button("Generate Image Prompt", elem_classes="submit-btn")
|
165 |
|
166 |
with gr.Column(scale=1):
|
167 |
with gr.Group(elem_classes="output-group"):
|
@@ -178,4 +200,4 @@ with gr.Blocks(css=custom_css) as demo:
|
|
178 |
outputs=[output_image, final_prompt, used_seed]
|
179 |
)
|
180 |
|
181 |
-
demo.launch(debug=True)
|
|
|
26 |
).to(device).eval()
|
27 |
qwen_processor = AutoProcessor.from_pretrained("prithivMLmods/JSONify-Flux", trust_remote_code=True)
|
28 |
|
29 |
+
# Prompt Enhancer
|
30 |
+
enhancer_long = pipeline("summarization", model="gokaygokay/Lamini-Prompt-Enchance-Long", device=device)
|
31 |
|
32 |
MAX_SEED = np.iinfo(np.int32).max
|
33 |
MAX_IMAGE_SIZE = 2048
|
|
|
97 |
|
98 |
generator = torch.Generator(device=device).manual_seed(seed)
|
99 |
|
|
|
100 |
torch.cuda.empty_cache()
|
101 |
|
102 |
try:
|
|
|
138 |
<p><center>
|
139 |
<a href="https://huggingface.co/black-forest-labs/FLUX.1-dev" target="_blank">[FLUX.1-dev Model]</a>
|
140 |
<a href="https://huggingface.co/prithivMLmods/JSONify-Flux" target="_blank">[JSONify Flux Model]</a>
|
141 |
+
<a href="https://huggingface.co/gokaygokay/Lamini-Prompt-Enchance-Long" target="_blank">[Prompt Enhancer Long]</a>
|
142 |
<p align="center">Create long prompts from images or enhance your short prompts with prompt enhancer</p>
|
143 |
</center></p>
|
144 |
"""
|
145 |
|
146 |
with gr.Blocks(css=custom_css) as demo:
|
147 |
+
|
148 |
+
# Sidebar with About details
|
149 |
+
with gr.Sidebar(label="Parameters", open=True):
|
150 |
+
gr.Markdown(
|
151 |
+
"""
|
152 |
+
### About
|
153 |
+
|
154 |
+
#### FLUX.1-Dev
|
155 |
+
FLUX.1 [dev] is a 12 billion parameter rectified flow transformer capable of generating images from text descriptions.
|
156 |
+
FLUX.1 [dev] is an open-weight, guidance-distilled model for non-commercial applications. Directly distilled from FLUX.1 [pro], FLUX.1 [dev] obtains similar quality and prompt adherence capabilities, while being more efficient than a standard model of the same size.
|
157 |
+
[FLUX.1-dev on Hugging Face](https://huggingface.co/black-forest-labs/FLUX.1-dev)
|
158 |
+
|
159 |
+
#### JSONify-Flux
|
160 |
+
JSONify-Flux is a multimodal image-text model based on the dataset of flux-generated images and architectures and built upon the Qwen2VL architecture. The JSON-base instruction has been manually removed to avoid JSON formatted captions.
|
161 |
+
[JSONify-Flux on Hugging Face](https://huggingface.co/prithivMLmods/JSONify-Flux)
|
162 |
+
|
163 |
+
#### t5-Flan-Prompt-Enhance
|
164 |
+
t5-Flan-Prompt-Enhance is a prompt summarization model based on flux synthetic prompts designed to enhance the richness of prompt details.
|
165 |
+
[t5-Flan-Prompt-Enhance on Hugging Face](https://huggingface.co/prithivMLmods/t5-Flan-Prompt-Enhance)
|
166 |
+
"""
|
167 |
+
)
|
168 |
+
|
169 |
gr.HTML(title)
|
170 |
|
171 |
with gr.Row():
|
|
|
181 |
width = gr.Slider(label="Width", minimum=256, maximum=MAX_IMAGE_SIZE, step=32, value=512)
|
182 |
height = gr.Slider(label="Height", minimum=256, maximum=MAX_IMAGE_SIZE, step=32, value=512)
|
183 |
guidance_scale = gr.Slider(label="Guidance Scale", minimum=1, maximum=15, step=0.1, value=3.5)
|
184 |
+
num_inference_steps = gr.Slider(label="Inference Steps", minimum=1, maximum=50, step=1, value=20)
|
185 |
|
186 |
+
generate_btn = gr.Button("Generate Image + Prompt Enhanced", elem_classes="submit-btn")
|
187 |
|
188 |
with gr.Column(scale=1):
|
189 |
with gr.Group(elem_classes="output-group"):
|
|
|
200 |
outputs=[output_image, final_prompt, used_seed]
|
201 |
)
|
202 |
|
203 |
+
demo.launch(debug=True)
|