idlebg commited on
Commit
33f0157
1 Parent(s): 67435e0

design change

Browse files
Files changed (1) hide show
  1. app.py +45 -41
app.py CHANGED
@@ -22,7 +22,7 @@ device = "cuda" if torch.cuda.is_available() else "cpu"
22
 
23
  torch.cuda.max_memory_allocated(device=device)
24
 
25
- pipe1 = DiffusionPipeline.from_pretrained("FFusion/FFbasetest", torch_dtype=torch.float16, use_safetensors=True)
26
  pipe2 = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-1.0", torch_dtype=torch.float16, variant="fp16", use_safetensors=True)
27
 
28
  pipe1 = pipe1.to(device)
@@ -58,49 +58,53 @@ def save_image_to_hf_space(image_np, image_name):
58
  persistent_storage_path = f"/data/{image_name_with_timestamp}"
59
  shutil.copy(local_image_path, persistent_storage_path)
60
 
61
-
62
- def genie (prompt, negative_prompt, scale, steps, seed):
63
- torch.cuda.empty_cache()
64
- generator = torch.Generator(device=device).manual_seed(seed)
65
- int_images = pipe1(prompt, negative_prompt=negative_prompt, num_inference_steps=steps, guidance_scale=scale, num_images_per_prompt=1, generator=generator).images
66
- torch.cuda.empty_cache()
67
- refined_images = pipe2(prompt=prompt, image=int_images).images
68
- int_image_np = np.array(int_images[0])
69
- refined_image_np = np.array(refined_images[0])
70
-
71
- # Save the generated images to Hugging Face Spaces
72
- save_image_to_hf_space(int_image_np, "int_image")
73
- save_image_to_hf_space(refined_image_np, "refined_image")
74
-
75
- return int_image_np, refined_image_np
76
-
77
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  gr.Interface(fn=genie,
79
- inputs=[gr.Textbox(label='Describe your FFusion idea. 77 Token Limit.'),
80
- gr.Textbox(label='Things the AI should not create (negative prompt)'),
81
  gr.Slider(1, 15, 10), gr.Slider(25, maximum=100, value=50, step=1),
82
  gr.Slider(minimum=1, step=1, maximum=999999999999999999, randomize=True)],
83
  outputs=[gc.Image(type='numpy', label="FFusionXL Base Image"), gc.Image(type='numpy', label="Refined Image")],
84
  title="FFusionXL Base - Generate and Refine",
85
- description='<div style="display: flex; flex-wrap: wrap; gap: 2px;"><a href="https://huggingface.co/FFusion/FFusionXL-BASE" target="_new" rel="ugc"><img src="https://img.shields.io/badge/FFusionXL--BASE--SDXL-Model-pink" alt="FFusionXL-BASE-SDXL"></a> <a href="https://huggingface.co/FFusion/FFusionXL-09-SDXL/blob/main/LICENSE.md" target="_new" rel="ugc"><img src="https://img.shields.io/badge/License-FFXL%20Research%20License-blue"></a></div>',
86
- article = '**Citation** \
87
- Please note that the demo is intended for academic and research purposes ONLY. Any use of the demo for generating inappropriate content is strictly prohibited. The responsibility for any misuse or inappropriate use of the demo lies solely with the users who generated such content, and this demo shall not be held liable for any such use. Original code: Manjushri. By interacting within this environment, you hereby acknowledge and agree to the terms of the SDXL 0.9 Research License. \
88
- Attribution: SDXL 0.9 is licensed under the SDXL Research License, Copyright (c) Stability AI Ltd. All Rights Reserved. \
89
- **License** \
90
- [SDXL 0.9 Research License](https://huggingface.co/stabilityai/stable-diffusion-xl-base-0.9/blob/main/LICENSE.md) \
91
- [FFXL 0.9 Research License](https://huggingface.co/FFusion/FFusionXL-09-SDXL/blob/main/LICENSE.md) \
92
- <div style="display: flex; flex-wrap: wrap; gap: 2px;">\
93
- <img src="https://img.shields.io/badge/%F0%9F%94%A5%20Refiner%20Compatible-Yes-success"> \
94
- <img src="https://img.shields.io/badge/%F0%9F%92%BB%20CLIP--ViT%2FG%20and%20CLIP--ViT%2FL%20tested-Yes-success"> \
95
- <img src="https://img.shields.io/badge/%F0%9F%A7%A8%20FFXL%20Diffusers-available-brightgreen"> \
96
- </div>\
97
- \
98
- <div style="display: flex; flex-wrap: wrap; gap: 2px;">\
99
- <a href="https://github.com/1e-2" target="_new" rel="ugc"><img src="https://img.shields.io/badge/GitHub-1e--2-green"></a> \
100
- <a href="https://www.facebook.com/FFusionAI/" target="_new" rel="ugc"><img src="https://img.shields.io/badge/Facebook-FFusionAI-blue"></a> \
101
- <a href="https://civitai.com/models/82039/ffusion-ai-sd-21" target="_new" rel="ugc"><img src="https://img.shields.io/badge/Civitai-FFusionAI-blue"></a> \
102
- </div>\
103
- \
104
- ![ffusionAI-FFusionXL-SDXL-preview.jpg](https://cdn-uploads.huggingface.co/production/uploads/6380cf05f496d57325c12194/LIONhgnyxUuEynNivGsME.jpeg) \
105
- \
106
- <a href="mailto:[email protected]"><img src="https://img.shields.io/badge/Email-di%40ffusion.ai-blue?style=for-the-badge&logo=gmail"></a>').launch(debug=True, max_threads=10)
 
22
 
23
  torch.cuda.max_memory_allocated(device=device)
24
 
25
+ pipe1 = DiffusionPipeline.from_pretrained("FFusion/FFusionXL-BASE", torch_dtype=torch.float16, use_safetensors=True)
26
  pipe2 = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-1.0", torch_dtype=torch.float16, variant="fp16", use_safetensors=True)
27
 
28
  pipe1 = pipe1.to(device)
 
58
  persistent_storage_path = f"/data/{image_name_with_timestamp}"
59
  shutil.copy(local_image_path, persistent_storage_path)
60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
 
62
+ article = f"""
63
+ <div style="text-align: center;">
64
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/6380cf05f496d57325c12194/LIONhgnyxUuEynNivGsME.jpeg" alt="ffusionAI-FFusionXL-SDXL-preview" width="100%" height="600">
65
+ </div>
66
+ <div style="display: flex; flex-direction: column; align-items: center; gap: 10px;">
67
+ <h2>Citation</h2>
68
+ <p>Please note that the demo is intended solely for academic and research purposes. This demo features the FFusionXL-BASE model developed by FFusion.AI, a division of Source Code Bulgaria Ltd.</p>
69
+ <h2>Acknowledgement of Original Work and Modifications</h2>
70
+ <p>This Software is based on the Stable Diffusion XL Base 1.0 model developed by Stability AI Ltd. FFusion AI and Source Code Bulgaria Ltd. have made modifications and enhancements to the original Software for the creation of the FFusionXL-BASE model...</p>
71
+ <h2>Warning and Compliance</h2>
72
+ <p><span style="color: red; font-weight: bold;">All images and content generated through this demo are logged in a Hugging Face repository, and we actively monitor for violations of these terms.</span> Any use of the demo for generating inappropriate or unlawful content is strictly prohibited...</p>
73
+ <h2>License</h2>
74
+ <p><a href="https://huggingface.co/stabilityai/stable-diffusion-xl-base-0.9/blob/main/LICENSE.md">SDXL 0.9 Research License</a></p>
75
+ <p><a href="https://huggingface.co/FFusion/FFusionXL-09-SDXL/blob/main/LICENSE.md">FFXL 0.9 Research License</a></p>
76
+ <div style="display: flex; flex-wrap: wrap; gap: 2px;">
77
+ <img src="https://img.shields.io/badge/🔥 Refiner Compatible-Yes-success">
78
+ <img src="https://img.shields.io/badge/💻 CLIP--ViT%2FG and CLIP--ViT%2FL tested-Yes-success">
79
+ <img src="https://img.shields.io/badge/🧨 FFXL Diffusers-available-brightgreen">
80
+ </div>
81
+ <div style="display: flex; flex-wrap: wrap; gap: 2px;">
82
+ <a href="https://github.com/1e-2" target="_new" rel="ugc"><img src="https://img.shields.io/badge/GitHub-1e--2-green"></a>
83
+ <a href="https://www.facebook.com/FFusionAI/" target="_new" rel="ugc"><img src="https://img.shields.io/badge/Facebook-FFusionAI-blue"></a>
84
+ <a href="https://civitai.com/models/82039/ffusion-ai-sd-21" target="_new" rel="ugc"><img src="https://img.shields.io/badge/Civitai-FFusionAI-blue"></a>
85
+ </div>
86
+ <a href="mailto:[email protected]"><img src="https://img.shields.io/badge/Email-di%40ffusion.ai-blue?style=for-the-badge&logo=gmail"></a>
87
+ </div>
88
+
89
+ """
90
+
91
+ # Create the Gradio interface
92
  gr.Interface(fn=genie,
93
+ inputs=[gr.Textbox(label='Describe your FFusion idea. 77 Token Limit.', lines=2),
94
+ gr.Textbox(label='Things the AI should not create (negative prompt)', lines=2),
95
  gr.Slider(1, 15, 10), gr.Slider(25, maximum=100, value=50, step=1),
96
  gr.Slider(minimum=1, step=1, maximum=999999999999999999, randomize=True)],
97
  outputs=[gc.Image(type='numpy', label="FFusionXL Base Image"), gc.Image(type='numpy', label="Refined Image")],
98
  title="FFusionXL Base - Generate and Refine",
99
+ description='<div style="display: flex; flex-wrap: wrap; gap: 2px; justify-content: center;"><a href="https://huggingface.co/FFusion/FFusionXL-BASE" target="_new" rel="ugc"><img src="https://img.shields.io/badge/FFusionXL--BASE--SDXL-Model-pink" alt="FFusionXL-BASE-SDXL"></a> <a href="https://huggingface.co/FFusion/FFusionXL-09-SDXL/blob/main/LICENSE.md" target="_new" rel="ugc"><img src="https://img.shields.io/badge/License-FFXL%20Research%20License-blue"></a></div>',
100
+ article=article,
101
+ css="""
102
+ .gr-textbox {
103
+ width: 100%;
104
+ }
105
+ .gr-image {
106
+ max-width: 50%;
107
+ display: inline-block;
108
+ }
109
+ """
110
+ ).launch(debug=True, max_threads=10)