daniel-dona commited on
Commit
64b6943
·
verified ·
1 Parent(s): 4d2f992

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -1
app.py CHANGED
@@ -40,8 +40,28 @@ def get_image_size(aspect_ratio):
40
  else:
41
  return 640, 640
42
 
43
- @spaces.GPU(duration=45)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
 
 
45
  def infer(
46
  prompt,
47
  negative_prompt=" ",
 
40
  else:
41
  return 640, 640
42
 
43
+ def polish_prompt_en(original_prompt):
44
+
45
+ SYSTEM_PROMPT = open("improve_prompt.txt").read()
46
+
47
+ original_prompt = original_prompt.strip()
48
+ prompt = f"{SYSTEM_PROMPT}\n\nUser Input: {original_prompt}\n\n Rewritten Prompt:"
49
+ success=False
50
+
51
+ while not success:
52
+ try:
53
+ polished_prompt = api(prompt, model='qwen-plus')
54
+ polished_prompt = polished_prompt.strip()
55
+ polished_prompt = polished_prompt.replace("\n", " ")
56
+ success = True
57
+
58
+ except Exception as e:
59
+ print(f"Error during API call: {e}")
60
+
61
+ return polished_prompt
62
+
63
 
64
+ @spaces.GPU(duration=45)
65
  def infer(
66
  prompt,
67
  negative_prompt=" ",