K00B404 commited on
Commit
4cfa403
1 Parent(s): 4195937

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -0
app.py CHANGED
@@ -14,6 +14,17 @@ API_URL_DEV = "https://api-inference.huggingface.co/models/black-forest-labs/FLU
14
  API_URL = "https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-schnell"
15
  timeout = 100
16
 
 
 
 
 
 
 
 
 
 
 
 
17
  def enhance_prompt_with_qwen(prompt):
18
  client = Client("Qwen/Qwen2.5-72B-Instruct")
19
  result = client.predict(
@@ -24,7 +35,11 @@ def enhance_prompt_with_qwen(prompt):
24
  )
25
  return result['output'] # Assuming the enhanced prompt is under 'output'
26
 
 
27
  def query(prompt, is_negative=False, steps=30, cfg_scale=7, sampler="DPM++ 2M Karras", seed=-1, strength=0.7, huggingface_api_key=None, use_dev=False):
 
 
 
28
  # Enhance the prompt before translation
29
  enhanced_prompt = enhance_prompt_with_qwen(prompt)
30
 
 
14
  API_URL = "https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-schnell"
15
  timeout = 100
16
 
17
+ # Function to set the system prompt once
18
+ def set_system_prompt():
19
+ client = Client("Qwen/Qwen2.5-72B-Instruct")
20
+ result = client.predict(
21
+ system="You are Qwen, an image generation prompt enhancer",
22
+ api_name="/modify_system_session"
23
+ )
24
+ print(f"System session modified: {result}")
25
+ return result
26
+
27
+ # Function to enhance the prompt with Qwen model
28
  def enhance_prompt_with_qwen(prompt):
29
  client = Client("Qwen/Qwen2.5-72B-Instruct")
30
  result = client.predict(
 
35
  )
36
  return result['output'] # Assuming the enhanced prompt is under 'output'
37
 
38
+ # Image generation query function
39
  def query(prompt, is_negative=False, steps=30, cfg_scale=7, sampler="DPM++ 2M Karras", seed=-1, strength=0.7, huggingface_api_key=None, use_dev=False):
40
+ # Set system prompt first
41
+ set_system_prompt()
42
+
43
  # Enhance the prompt before translation
44
  enhanced_prompt = enhance_prompt_with_qwen(prompt)
45