aiqtech commited on
Commit
f25970f
·
verified ·
1 Parent(s): e4b485f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -94
app.py CHANGED
@@ -1,17 +1,3 @@
1
- # Copyright (c) 2025 Bytedance Ltd. and/or its affiliates. All rights reserved.
2
-
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
-
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
-
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
  import os
16
 
17
  import gradio as gr
@@ -184,40 +170,10 @@ def generate_image(
184
  def generate_examples(id_image, control_image, prompt_text, seed, enable_realism, enable_anti_blur, model_version):
185
  return generate_image(id_image, control_image, prompt_text, seed, 864, 1152, 3.5, 30, 1.0, 0.0, 1.0, enable_realism, enable_anti_blur, model_version)
186
 
187
-
188
- sample_list = [
189
- ['./assets/examples/yann-lecun_resize.jpg', None, 'A sophisticated gentleman exuding confidence. He is dressed in a 1990s brown plaid jacket with a high collar, paired with a dark grey turtleneck. His trousers are tailored and charcoal in color, complemented by a sleek leather belt. The background showcases an elegant library with bookshelves, a marble fireplace, and warm lighting, creating a refined and cozy atmosphere. His relaxed posture and casual hand-in-pocket stance add to his composed and stylish demeanor', 666, False, False, 'aes_stage2'],
190
- ['./assets/examples/yann-lecun_resize.jpg', './assets/examples/man_pose.jpg', 'A man, portrait, cinematic', 42, True, False, 'aes_stage2'],
191
- ['./assets/examples/yann-lecun_resize.jpg', './assets/examples/yann-lecun_resize.jpg', 'A man, portrait, cinematic', 12345, False, False, 'sim_stage1'],
192
- ['./assets/examples/yangmi.jpg', None, 'A woman, portrait, cinematic', 1621695706, False, False, 'sim_stage1'],
193
- ['./assets/examples/yangmi.jpg', None, 'A young woman holding a sign with the text "InfiniteYou", "Infinite" in black and "You" in red, pure background', 3724009366, False, False, 'aes_stage2'],
194
- ['./assets/examples/yangmi.jpg', None, 'A photo of an elegant Javanese bride in traditional attire, with long hair styled into intricate a braid made of many fresh flowers, wearing a delicate headdress made from sequins and beads. She\'s holding flowers, light smiling at the camera, against a backdrop adorned with orchid blooms. The scene captures her grace as she stands amidst soft pastel colors, adding to its dreamy atmosphere', 42, True, False, 'aes_stage2'],
195
- ['./assets/examples/yangmi.jpg', None, 'A photo of an elegant Javanese bride in traditional attire, with long hair styled into intricate a braid made of many fresh flowers, wearing a delicate headdress made from sequins and beads. She\'s holding flowers, light smiling at the camera, against a backdrop adorned with orchid blooms. The scene captures her grace as she stands amidst soft pastel colors, adding to its dreamy atmosphere', 42, False, False, 'sim_stage1'],
196
- ]
197
-
198
  with gr.Blocks() as demo:
199
  session_state = gr.State({})
200
  default_model_version = "v1.0"
201
 
202
- gr.HTML("""
203
- <div style="text-align: center; max-width: 900px; margin: 0 auto;">
204
- <h1 style="font-size: 1.5rem; font-weight: 700; display: block;">InfiniteYou-FLUX</h1>
205
- <h2 style="font-size: 1.2rem; font-weight: 300; margin-bottom: 1rem; display: block;">Official Gradio Demo for <a href="https://arxiv.org/abs/2503.16418">InfiniteYou: Flexible Photo Recrafting While Preserving Your Identity</a></h2>
206
- <a href="https://bytedance.github.io/InfiniteYou">[Project Page]</a>&ensp;
207
- <a href="https://arxiv.org/abs/2503.16418">[Paper]</a>&ensp;
208
- <a href="https://github.com/bytedance/InfiniteYou">[Code]</a>&ensp;
209
- <a href="https://huggingface.co/ByteDance/InfiniteYou">[Model]</a>
210
- </div>
211
- """)
212
-
213
- gr.Markdown("""
214
- ### 💡 How to Use This Demo:
215
- 1. **Upload an identity (ID) image containing a human face.** For multiple faces, only the largest face will be detected. The face should ideally be clear and large enough, without significant occlusions or blur.
216
- 2. **Enter the text prompt to describe the generated image and select the model version.** Please refer to **important usage tips** under the Generated Image field.
217
- 3. *[Optional] Upload a control image containing a human face.* Only five facial keypoints will be extracted to control the generation. If not provided, we use a black control image, indicating no control.
218
- 4. *[Optional] Adjust advanced hyperparameters or apply optional LoRAs to meet personal needs.* Please refer to **important usage tips** under the Generated Image field.
219
- 5. **Click the "Generate" button to generate an image.** Enjoy!
220
- """)
221
 
222
  with gr.Row():
223
  with gr.Column(scale=3):
@@ -255,15 +211,7 @@ with gr.Blocks() as demo:
255
 
256
  with gr.Column(scale=2):
257
  image_output = gr.Image(label="Generated Image", interactive=False, height=550, format='png')
258
- gr.Markdown(
259
- """
260
- ### ❗️ Important Usage Tips:
261
- - **Model Version**: `aes_stage2` is used by default for better text-image alignment and aesthetics. For higher ID similarity, try `sim_stage1`.
262
- - **Useful Hyperparameters**: Usually, there is NO need to adjust too much. If necessary, try a slightly larger `--infusenet_guidance_start` (*e.g.*, `0.1`) only (especially helpful for `sim_stage1`). If still not satisfactory, then try a slightly smaller `--infusenet_conditioning_scale` (*e.g.*, `0.9`).
263
- - **Optional LoRAs**: `realism` and `anti-blur`. To enable them, please check the corresponding boxes. If needed, try `realism` only first. They are optional and were NOT used in our paper.
264
- - **Gender Prompt**: If the generated gender is not preferred, add specific words in the prompt, such as 'a man', 'a woman', *etc*. We encourage using inclusive and respectful language.
265
- """
266
- )
267
 
268
  gr.Examples(
269
  sample_list,
@@ -295,47 +243,6 @@ with gr.Blocks() as demo:
295
  concurrency_id="gpu"
296
  )
297
 
298
- with gr.Accordion("Local Gradio Demo for Developers", open=False):
299
- gr.Markdown(
300
- 'Please refer to our GitHub repository to [run the InfiniteYou-FLUX gradio demo locally](https://github.com/bytedance/InfiniteYou#local-gradio-demo).'
301
- )
302
-
303
- gr.Markdown(
304
- """
305
- ---
306
- ### 📜 Disclaimer and Licenses
307
- Some images in this demo are from public domains or generated by models. These pictures are intended solely to show the capabilities of our research. If you have any concerns, please contact us, and we will promptly remove any inappropriate content.
308
-
309
- The use of the released code, model, and demo must strictly adhere to the respective licenses.
310
- Our code is released under the [Apache 2.0 License](https://github.com/bytedance/InfiniteYou/blob/main/LICENSE),
311
- and our model is released under the [Creative Commons Attribution-NonCommercial 4.0 International Public License](https://huggingface.co/ByteDance/InfiniteYou/blob/main/LICENSE)
312
- for academic research purposes only. Any manual or automatic downloading of the face models from [InsightFace](https://github.com/deepinsight/insightface),
313
- the [FLUX.1-dev](https://huggingface.co/black-forest-labs/FLUX.1-dev) base model, LoRAs, *etc.*, must follow their original licenses and be used only for academic research purposes.
314
-
315
- This research aims to positively impact the Generative AI field. Users are granted freedom to create images using this tool, but they must comply with local laws and use it responsibly. The developers do not assume any responsibility for potential misuse.
316
- """
317
- )
318
-
319
- gr.Markdown(
320
- """
321
- ### 📖 Citation
322
-
323
- If you find InfiniteYou useful for your research or applications, please cite our paper:
324
-
325
- ```bibtex
326
- @article{jiang2025infiniteyou,
327
- title={{InfiniteYou}: Flexible Photo Recrafting While Preserving Your Identity},
328
- author={Jiang, Liming and Yan, Qing and Jia, Yumin and Liu, Zichuan and Kang, Hao and Lu, Xin},
329
- journal={arXiv preprint},
330
- volume={arXiv:2503.16418},
331
- year={2025}
332
- }
333
- ```
334
-
335
- We also appreciate it if you could give a star ⭐ to our [Github repository](https://github.com/bytedance/InfiniteYou). Thanks a lot!
336
- """
337
- )
338
-
339
 
340
  huggingface_hub.login(os.getenv('PRIVATE_HF_TOKEN'))
341
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import os
2
 
3
  import gradio as gr
 
170
  def generate_examples(id_image, control_image, prompt_text, seed, enable_realism, enable_anti_blur, model_version):
171
  return generate_image(id_image, control_image, prompt_text, seed, 864, 1152, 3.5, 30, 1.0, 0.0, 1.0, enable_realism, enable_anti_blur, model_version)
172
 
 
 
 
 
 
 
 
 
 
 
 
173
  with gr.Blocks() as demo:
174
  session_state = gr.State({})
175
  default_model_version = "v1.0"
176
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
177
 
178
  with gr.Row():
179
  with gr.Column(scale=3):
 
211
 
212
  with gr.Column(scale=2):
213
  image_output = gr.Image(label="Generated Image", interactive=False, height=550, format='png')
214
+
 
 
 
 
 
 
 
 
215
 
216
  gr.Examples(
217
  sample_list,
 
243
  concurrency_id="gpu"
244
  )
245
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
246
 
247
  huggingface_hub.login(os.getenv('PRIVATE_HF_TOKEN'))
248