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

Fixes / adding more options

Browse files
Files changed (1) hide show
  1. app.py +27 -4
app.py CHANGED
@@ -59,6 +59,23 @@ def save_image_to_hf_space(image_np, image_name):
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">
@@ -91,9 +108,15 @@ article = f"""
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>',
@@ -107,4 +130,4 @@ gr.Interface(fn=genie,
107
  display: inline-block;
108
  }
109
  """
110
- ).launch(debug=True, max_threads=10)
 
59
  shutil.copy(local_image_path, persistent_storage_path)
60
 
61
 
62
+
63
+
64
+ def genie(prompt, negative_prompt, prompt_2, negative_prompt_2, scale, guidance_scale, aesthetic_score, negative_aesthetic_score, steps, seed):
65
+ torch.cuda.empty_cache()
66
+ generator = torch.Generator(device=device).manual_seed(seed)
67
+ int_images = pipe1(prompt=prompt, prompt_2=prompt_2, negative_prompt=negative_prompt, negative_prompt_2=negative_prompt_2, num_inference_steps=steps, guidance_scale=scale, num_images_per_prompt=1, generator=generator).images
68
+ torch.cuda.empty_cache()
69
+ refined_images = pipe2(prompt=prompt, prompt_2=prompt_2, image=int_images, guidance_scale=guidance_scale, aesthetic_score=aesthetic_score, negative_aesthetic_score=negative_aesthetic_score).images
70
+ int_image_np = np.array(int_images[0])
71
+ refined_image_np = np.array(refined_images[0])
72
+
73
+ # Save the generated images to Hugging Face Spaces
74
+ save_image_to_hf_space(int_image_np, "int_image")
75
+ save_image_to_hf_space(refined_image_np, "refined_image")
76
+
77
+ return int_image_np, refined_image_np
78
+
79
  article = f"""
80
  <div style="text-align: center;">
81
  <img src="https://cdn-uploads.huggingface.co/production/uploads/6380cf05f496d57325c12194/LIONhgnyxUuEynNivGsME.jpeg" alt="ffusionAI-FFusionXL-SDXL-preview" width="100%" height="600">
 
108
  # Create the Gradio interface
109
  gr.Interface(fn=genie,
110
  inputs=[gr.Textbox(label='Describe your FFusion idea. 77 Token Limit.', lines=2),
111
+ gr.Textbox(label='Things the AI should not create (negative prompt)', lines=2),
112
+ gr.Textbox(label='Additional prompt for text-encoder 2 (optional)', lines=2, optional=True),
113
+ gr.Textbox(label='Negative prompt for text-encoder 2 (optional)', lines=2, optional=True),
114
+ gr.Slider(1, 15, 10, label='Scale'),
115
+ gr.Slider(1, 10, 5, label='Guidance Scale'),
116
+ gr.Slider(1, 10, 6, label='Aesthetic Score'),
117
+ gr.Slider(1, 10, 2.5, label='Negative Aesthetic Score'),
118
+ gr.Slider(25, maximum=5, value=50, step=1, label='Steps'),
119
+ gr.Slider(minimum=1, step=1, maximum=999999999999999999, randomize=True, label='Seed')],
120
  outputs=[gc.Image(type='numpy', label="FFusionXL Base Image"), gc.Image(type='numpy', label="Refined Image")],
121
  title="FFusionXL Base - Generate and Refine",
122
  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>',
 
130
  display: inline-block;
131
  }
132
  """
133
+ ).launch(debug=True, max_threads=10)