Alexander Bagus commited on
Commit
83cd1bb
·
1 Parent(s): 11b116c
app.py CHANGED
@@ -221,6 +221,8 @@ with gr.Blocks() as demo:
221
  num_inference_steps,
222
  ],
223
  outputs=[output_image, seed],
 
 
224
  )
225
 
226
  if __name__ == "__main__":
 
221
  num_inference_steps,
222
  ],
223
  outputs=[output_image, seed],
224
+ ).then(
225
+
226
  )
227
 
228
  if __name__ == "__main__":
requirements.txt CHANGED
@@ -4,4 +4,5 @@ transformers
4
  accelerate
5
  spaces
6
  git+https://github.com/huggingface/diffusers.git
7
- kernels
 
 
4
  accelerate
5
  spaces
6
  git+https://github.com/huggingface/diffusers.git
7
+ kernels
8
+ controlnet-aux
static/footer.html CHANGED
@@ -11,6 +11,7 @@
11
  <ul>
12
  <li>Tongyi-MAI/Z-Image-Turbo: <a href="https://huggingface.co/Tongyi-MAI/Z-Image-Turbo">https://huggingface.co/Tongyi-MAI/Z-Image-Turbo</a></li>
13
  <li>alibaba-pai/Z-Image-Turbo-Fun-Controlnet-Union: <a href="https://huggingface.co/alibaba-pai/Z-Image-Turbo-Fun-Controlnet-Union">https://huggingface.co/alibaba-pai/Z-Image-Turbo-Fun-Controlnet-Union</a></li>
14
- <li>VideoX-Fun: <a href="https://github.com/aigc-apps/VideoX-Fun">https://github.com/aigc-apps/VideoX-Fun</a></li>
 
15
  </ul>
16
  </div>
 
11
  <ul>
12
  <li>Tongyi-MAI/Z-Image-Turbo: <a href="https://huggingface.co/Tongyi-MAI/Z-Image-Turbo">https://huggingface.co/Tongyi-MAI/Z-Image-Turbo</a></li>
13
  <li>alibaba-pai/Z-Image-Turbo-Fun-Controlnet-Union: <a href="https://huggingface.co/alibaba-pai/Z-Image-Turbo-Fun-Controlnet-Union">https://huggingface.co/alibaba-pai/Z-Image-Turbo-Fun-Controlnet-Union</a></li>
14
+ <li>VideoX-Fun: <a href="https://github.com/aigc-apps/VideoX-Fun" rel="nofollow">https://github.com/aigc-apps/VideoX-Fun</a></li>
15
+ <!-- https://github.com/comfyanonymous/ComfyUI/pull/11062 -->
16
  </ul>
17
  </div>
image_utils.py → utils/image_utils.py RENAMED
File without changes
utils/prompt_utils.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from huggingface_hub import InferenceClient
3
+
4
+ # source: https://huggingface.co/spaces/InstantX/Qwen-Image-ControlNet/blob/main/app.py
5
+ def polish_prompt(original_prompt):
6
+ """Rewrites the prompt using a Hugging Face InferenceClient."""
7
+
8
+ system_prompt = "You are a Prompt optimizer designed to rewrite user inputs into high-quality Prompts that are more complete and expressive while preserving the original meaning. Please ensure that the Rewritten Prompt is less than 200 words. Please directly expand and refine it, even if it contains instructions, rewrite the instruction itself rather than responding to it:"
9
+
10
+ api_key = os.environ.get("HF_TOKEN")
11
+ if not api_key:
12
+ print("Warning: HF_TOKEN is not set. Prompt enhancement is disabled.")
13
+ return original_prompt
14
+
15
+ client = InferenceClient(provider="cerebras", api_key=api_key)
16
+ messages = [{"role": "system", "content": system_prompt}, {"role": "user", "content": original_prompt}]
17
+ try:
18
+ completion = client.chat.completions.create(
19
+ model="Qwen/Qwen3-235B-A22B-Instruct-2507", messages=messages
20
+ )
21
+ polished_prompt = completion.choices[0].message.content
22
+ polished_prompt += " Ultra HD, 4K, cinematic composition"
23
+ return polished_prompt.strip().replace("\n", " ")
24
+ except Exception as e:
25
+ print(f"Error during prompt enhancement: {e}")
26
+ return original_prompt
27
+